Skip to content

optimizer panic in LogicalTopN::rewrite_with_input during deterministic sqlsmith fuzzing (unwrap on None) #24895

@tabVersion

Description

@tabVersion

Problem

In CI job deterministic simulation e2e, ci-3cn-2fe, fuzzing (pre-generated-queries), frontend panics in optimizer:

related runs (https://buildkite.com/risingwavelabs/pull-request/builds/92521 on release-2.7, https://buildkite.com/risingwavelabs/pull-request/builds/92544#019c9d9f-d6ae-4139-9a02-3d06f1b4be43 on release-2.6)

  • Panic location: src/frontend/src/optimizer/plan_node/logical_topn.rs:203
  • Panic: called Option::unwrap() on a None value
  • Stack shows:
    • LogicalTopN::rewrite_with_input
    • LogicalTopN::logical_rewrite_for_stream

Relevant log fragments from CI:

ERROR ... Failed to schedule tasks error=Expr error: error while evaluating expression `general_mul('192', '9223372036854775807')`: Numeric out of range
...
thread '<unnamed>' panicked at src/frontend/src/optimizer/plan_node/logical_topn.rs:203:14:
called `Option::unwrap()` on a `None` value

Notes about the error sequence

Numeric out of range from sqlsmith is expected/permissible in fuzzing and usually should be skipped.
The CI turns red because of the frontend panic (unwrap(None)), not because of the arithmetic overflow itself.

Root-cause analysis (code-level)

The panic happens at:

core.order = input_col_change
    .rewrite_required_order(self.topn_order())
    .unwrap();

rewrite_required_order returns None if any order key cannot be mapped by input_col_change.
So this panic means TopN order references a column that disappeared after a rewrite/project mapping.

Most likely regression area

The most suspicious change set is the TopN/index-selection rework introduced by:

  • f3581c816a (release-2.7) / 52acc86e9a (main)
    • introduced TopNProjectTransposeRule
    • introduced ProjectTopNTransposeRule
    • changed TopNOnIndexRule to expand scan output with predicate-only columns and then project back

These together increase the chance of transient mismatch between:

  • TopN.order keys, and
  • rewritten input schema / col mapping.

Environment

  • Repo: risingwavelabs/risingwave
  • Failing CI stage: deterministic simulation e2e / ci-3cn-2fe / fuzzing (pre-generated-queries)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions