Repository navigation
Fix crash due to exception inside NOEXCEPT_SCOPE in Transaction::commit - #96023
Merged
Merged
Conversation
The server was crashing with `std::terminate()` when a `SERIALIZATION_ERROR` exception was thrown inside `NOEXCEPT_SCOPE` in `MergeTreeData::Transaction::commit()`. The issue occurred in the non-transactional code path (`txn == nullptr`): - `addNewPartAndRemoveCovered` with `NO_TRANSACTION_RAW` was called inside `NOEXCEPT_SCOPE` - This function calls `lockRemovalTID(Tx::PrehistoricTID, ...)` for covered parts - `lockRemovalTID` throws `SERIALIZATION_ERROR` when a part is already locked by another transaction - Throwing inside `NOEXCEPT_SCOPE` triggers `std::terminate()` The transactional code path (`txn != nullptr`) was already correct - it called `addNewPartAndRemoveCovered` before entering `NOEXCEPT_SCOPE`. The fix unifies both code paths: 1. Before `NOEXCEPT_SCOPE`: collect covered parts and call `addNewPartAndRemoveCovered` for all precommitted parts (when there's no covering part), regardless of whether there's a transaction 2. Store the covered parts in `covered_parts_for_commit` vector 3. Inside `NOEXCEPT_SCOPE`: use the pre-computed covered parts instead of calling the potentially-throwing function This ensures that `lockRemovalTID` (which can throw) is always called outside of `NOEXCEPT_SCOPE`, allowing the exception to propagate normally instead of causing the server to crash. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Contributor
|
Workflow [PR], commit [fb5ed85] Summary: ❌
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The server was crashing with
std::terminate()when aSERIALIZATION_ERRORexception was thrown insideNOEXCEPT_SCOPEinMergeTreeData::Transaction::commit().The issue occurred in the non-transactional code path (
txn == nullptr):addNewPartAndRemoveCoveredwithNO_TRANSACTION_RAWwas called insideNOEXCEPT_SCOPElockRemovalTID(Tx::PrehistoricTID, ...)for covered partslockRemovalTIDthrowsSERIALIZATION_ERRORwhen a part is already locked by another transactionNOEXCEPT_SCOPEtriggersstd::terminate()The transactional code path (
txn != nullptr) was already correct - it calledaddNewPartAndRemoveCoveredbefore enteringNOEXCEPT_SCOPE.The fix unifies both code paths:
NOEXCEPT_SCOPE: collect covered parts and calladdNewPartAndRemoveCoveredfor all precommitted parts (when there's no covering part), regardless of whether there's a transactioncovered_parts_for_commitvectorNOEXCEPT_SCOPE: use the pre-computed covered parts instead of calling the potentially-throwing functionThis ensures that
lockRemovalTID(which can throw) is always called outside ofNOEXCEPT_SCOPE, allowing the exception to propagate normally instead of causing the server to crash.Changelog category (leave one):
See https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96013&sha=0e986faabb62200a130d22f5a32c17f9699d1f0e&name_0=PR&name_1=Stateless%20tests%20%28amd_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29
#96013
Need to consult with @tavplubix on whether this is reasonable.
Version info
26.2.1.332