Do not fuzz queries with implicit transactions by antaljanosbenjamin · Pull Request #97861 · ClickHouse/ClickHouse · GitHub
Skip to content

Do not fuzz queries with implicit transactions#97861

Closed
antaljanosbenjamin wants to merge 3 commits into
masterfrom
do-not-fuzz-queries-with-implicit-transactions
Closed

Do not fuzz queries with implicit transactions#97861
antaljanosbenjamin wants to merge 3 commits into
masterfrom
do-not-fuzz-queries-with-implicit-transactions

Conversation

@antaljanosbenjamin

@antaljanosbenjamin antaljanosbenjamin commented Feb 24, 2026

Copy link
Copy Markdown
Member

#97568 introduced server side fuzzing, but it is broken with implicit transactions.

Implicit transactions cause issues with fuzzing because we copy the query context which can contain an already committed transaction. Because of the different assertions in setCurrentTransaction, initCurrentTransaction and MergeTreeTransactionHolder, it is not trivial how to start a new transaction in the same session context for a new query, thus let's just not fuzz queries with implicit transactions.

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a [user-readable short description]

Do not use server side query fuzzer with implicit transactions because it violates the logic around transactions.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@antaljanosbenjamin antaljanosbenjamin marked this pull request as ready for review February 24, 2026 13:50
@clickhouse-gh

clickhouse-gh Bot commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Feb 24, 2026
@antaljanosbenjamin antaljanosbenjamin mentioned this pull request Feb 24, 2026
1 task
@pamarcos pamarcos self-requested a review February 24, 2026 14:19
@pamarcos pamarcos self-assigned this Feb 24, 2026
@pamarcos

Copy link
Copy Markdown
Member

but it is broken with implicit transactions

@antaljanosbenjamin care to elaborate or provide a proof to understand why it's broken with implicit transactions?

Comment thread src/Interpreters/executeQuery.cpp Outdated
Comment on lines +2116 to +2119
// Implicit transactions cause issues with fuzzing because we copy the query context which can contain an already
// committed transaction. Because of the different assertions in setCurrentTransaction, initCurrentTransaction and
// MergeTreeTransactionHolder, it is not trivial how to start a new transaction in the same session context for a
// new query, thus let's just not fuzz queries with implicit transactions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see. The explanation is here. I think this comment should use /// as per the coding style. Also, this same explanation could have been added to the commit message itself, and definitely should have been added to the description (and IMHO also in the changelog)

Comment thread src/Interpreters/executeQuery.cpp Outdated
@antaljanosbenjamin

Copy link
Copy Markdown
Member Author

Maybe #97835 is better

@alexey-milovidov

Copy link
Copy Markdown
Member

Interesting - if we disable transactions and clean up the copied context from the in-progress transaction, will it be better?

@antaljanosbenjamin

Copy link
Copy Markdown
Member Author

I am not sure how to make that work. I am not sure if having different transactions in session and query context is okay or not. Second, to make it work properly, we have to use MergeTreeTransactionHolder which can be used only with session context as far as I understood. I opted to disable it, because it is an experimental feature. Azat's PR might make it work though.

@azat azat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's merge this one first to fix CI, I will finish mine later (need to solve leaking of transaction from session context)

@azat

azat commented Feb 24, 2026

Copy link
Copy Markdown
Member

Although last version should work

@antaljanosbenjamin

Copy link
Copy Markdown
Member Author

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

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants