Skip to content

fix(sql): memory leak when querying a table which is being ALTERed concurrently#6055

Merged
bluestreak01 merged 3 commits intomasterfrom
jh_leak_filter_alter_race
Aug 15, 2025
Merged

fix(sql): memory leak when querying a table which is being ALTERed concurrently#6055
bluestreak01 merged 3 commits intomasterfrom
jh_leak_filter_alter_race

Conversation

@jerrinot
Copy link
Copy Markdown
Contributor

@jerrinot jerrinot commented Aug 15, 2025

In rare cases where queries execute while a table is being ALTERed simultaneously, memory could leak during internal query retries. This edge case only affected systems with concurrent schema modifications and queries on the same table. While queries completed successfully through automatic retries, memory from failed attempts was not released.

Implementation details

The issue occurred when the SQL compiler attempted to create a filter during query compilation:

  1. Compiler creates a factory
  2. Attempts to wrap it in a filter
  3. Filter creation tries to obtain a cursor, which can fail due to TableReferenceOutOfDateException
  4. On failure, the factory wasn't being freed before the retry

@jerrinot jerrinot added Bug Incorrect or unexpected behavior SQL Issues or changes relating to SQL execution Java Improvements that update Java code labels Aug 15, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Aug 15, 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 jh_leak_filter_alter_race

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@bluestreak01 bluestreak01 merged commit 5935cce into master Aug 15, 2025
6 of 8 checks passed
@bluestreak01 bluestreak01 deleted the jh_leak_filter_alter_race branch August 15, 2025 14:13
@glasstiger
Copy link
Copy Markdown
Contributor

[PR Coverage check]

😞 fail : 0 / 5 (00.00%)

file detail

path covered line new line coverage
🔵 io/questdb/griffin/SqlCodeGenerator.java 0 5 00.00%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Incorrect or unexpected behavior Java Improvements that update Java code SQL Issues or changes relating to SQL execution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants