Skip to content

fix(core): fix incorrect error handling, which can leave table reader in an inconsistent state#6108

Merged
bluestreak01 merged 3 commits intomasterfrom
vi_fix_fuzz
Sep 8, 2025
Merged

fix(core): fix incorrect error handling, which can leave table reader in an inconsistent state#6108
bluestreak01 merged 3 commits intomasterfrom
vi_fix_fuzz

Conversation

@bluestreak01
Copy link
Copy Markdown
Member

@bluestreak01 bluestreak01 commented Sep 6, 2025

found by a fuzz test:

testWalWriteTinyO3Memory - random seeds: 990968392657L, 1757173721663L

Removed implicit contract that failure to extend memory will close the memory.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 6, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch vi_fix_fuzz

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@bluestreak01
Copy link
Copy Markdown
Member Author

@CodeRabbit review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 6, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
core/src/main/java/io/questdb/griffin/SqlOptimiser.java (1)

2782-2807: Don’t bypass QueryModel’s invariants: use addBottomUpColumn instead of mutating maps/lists directly

Directly writing to aliasToColumnMap and bottomUpColumns risks leaving columnNameToAliasMap, alias indexes, wildcard lists, etc., out of sync. This can later break column resolution and rewrites. Also, keep source position when replacing ORDER BY with a literal, and avoid var for codebase consistency.

-                if (node.type == FUNCTION || node.type == OPERATION) {
-                    var qc = findQueryColumnByAst(model.getBottomUpColumns(), node);
+                if (node.type == FUNCTION || node.type == OPERATION) {
+                    QueryColumn qc = findQueryColumnByAst(model.getBottomUpColumns(), node);
                     if (qc == null) {
                         // add this function to bottom-up columns and replace this expression with index
-                        CharSequence alias = SqlUtil.createColumnAlias(
+                        CharSequence alias = SqlUtil.createColumnAlias(
                                 characterStore,
                                 node.token,
                                 Chars.indexOfLastUnquoted(node.token, '.'),
                                 model.getAliasToColumnMap(),
                                 true
                         );
-                        qc = queryColumnPool.next().of(
-                                alias,
-                                node,
-                                false
-                        );
-                        model.getAliasToColumnMap().put(alias, qc);
-                        model.getBottomUpColumns().add(qc);
+                        qc = queryColumnPool.next().of(alias, node, false);
+                        // Keep QueryModel internal structures consistent
+                        model.addBottomUpColumn(qc);
                         moved = true;
                     }
                     // on "else" branch, when order by expression matched projection
                     // we can just replace order by with projection alias without having to
                     // add an extra model
-                    orderBy.setQuick(i, nextLiteral(qc.getAlias()));
+                    orderBy.setQuick(i, nextLiteral(qc.getAlias(), node.position));
                 }
🧹 Nitpick comments (1)
core/src/main/java/io/questdb/griffin/SqlOptimiser.java (1)

2312-2320: Annotate nullable return for clarity

This returns null when no match is found. Add an explicit @nullable to improve readability and static analysis.

-    private QueryColumn findQueryColumnByAst(ObjList<QueryColumn> bottomUpColumns, ExpressionNode node) {
+    private @Nullable QueryColumn findQueryColumnByAst(ObjList<QueryColumn> bottomUpColumns, ExpressionNode node) {
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 38047a6 and 6f29e98.

📒 Files selected for processing (2)
  • core/src/main/java/io/questdb/cairo/vm/MemoryCMRImpl.java (1 hunks)
  • core/src/main/java/io/questdb/griffin/SqlOptimiser.java (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (28)
  • GitHub Check: New pull request (SelfHosted Griffin And Fuzz tests on linux-arm64)
  • GitHub Check: New pull request (SelfHosted Griffin And Fuzz tests on linux-x64-zfs)
  • GitHub Check: New pull request (SelfHosted Other tests on linux-x64-zfs)
  • GitHub Check: New pull request (SelfHosted Other tests on linux-arm64)
  • GitHub Check: New pull request (Rust Test and Lint on linux-jdk17)
  • GitHub Check: New pull request (Hosted Running tests on windows-other)
  • GitHub Check: New pull request (Hosted Running tests on windows-pgwire)
  • GitHub Check: New pull request (Hosted Running tests on windows-cairo)
  • GitHub Check: New pull request (Hosted Running tests on windows-fuzz2)
  • GitHub Check: New pull request (Hosted Running tests on windows-fuzz1)
  • GitHub Check: New pull request (Hosted Running tests on windows-griffin)
  • GitHub Check: New pull request (Hosted Running tests with cover on linux-other)
  • GitHub Check: New pull request (Hosted Running tests on mac-other)
  • GitHub Check: New pull request (Hosted Running tests with cover on linux-pgwire)
  • GitHub Check: New pull request (Hosted Running tests on mac-pgwire)
  • GitHub Check: New pull request (Hosted Running tests with cover on linux-cairo)
  • GitHub Check: New pull request (Hosted Running tests on mac-cairo-fuzz)
  • GitHub Check: New pull request (Hosted Running tests with cover on linux-fuzz)
  • GitHub Check: New pull request (Hosted Running tests on mac-cairo)
  • GitHub Check: New pull request (SelfHosted Other tests Start X64Zfs Agent)
  • GitHub Check: New pull request (Hosted Running tests on mac-griffin)
  • GitHub Check: New pull request (Hosted Running tests with cover on linux-griffin)
  • GitHub Check: New pull request (SelfHosted Griffin And Fuzz tests Start X64Zfs Agent)
  • GitHub Check: New pull request (SelfHosted Other tests Start ARM Agent)
  • GitHub Check: New pull request (SelfHosted Griffin And Fuzz tests Start ARM Agent)
  • GitHub Check: New pull request (Check Changes Check changes)
  • GitHub Check: build
  • GitHub Check: build

bluestreak01 and others added 2 commits September 6, 2025 20:36
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@glasstiger
Copy link
Copy Markdown
Contributor

[PR Coverage check]

😍 pass : 14 / 14 (100.00%)

file detail

path covered line new line coverage
🔵 io/questdb/cairo/vm/MemoryCMRImpl.java 6 6 100.00%
🔵 io/questdb/griffin/SqlOptimiser.java 8 8 100.00%

@bluestreak01 bluestreak01 merged commit 4aeca59 into master Sep 8, 2025
35 checks passed
@bluestreak01 bluestreak01 deleted the vi_fix_fuzz branch September 8, 2025 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants