Repository navigation
Fix dangling PrehistoricTID removal locks on concurrent TRUNCATE failure - #97211
Merged
Merged
Conversation
…failure In `MergeTreeData::Transaction::commit`, the pre-NOEXCEPT loop calls `lockRemovalTID(PrehistoricTID)` on covered parts via `addNewPartAndRemoveCovered`. If a later iteration throws (e.g., `SERIALIZATION_ERROR` because a concurrent transaction already locked a part), the removal TID locks set in previous iterations were never cleaned up. This left dangling `PrehistoricTID` locks that caused subsequent non-transactional operations to fail with the LOGICAL_ERROR exception "Tried to lock part for removal second time". The fix adds a try-catch around the loop that tracks which parts had their removal TID locked by non-transactional operations, and unlocks them all on failure before rethrowing. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=8aaa13be4cb6810d70d58f144c97cafc344ec674&name_0=MasterCI&name_1=Stateless%20tests%20%28arm_binary%2C%20sequential%29 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
|
Workflow [PR], commit [8635872] Summary: ❌
|
alexey-milovidov
marked this pull request as draft
February 17, 2026 16:04
alexey-milovidov
marked this pull request as ready for review
February 17, 2026 16:07
tuanpach
approved these changes
Feb 18, 2026
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.
Summary
MergeTreeData::Transaction::commit, the pre-NOEXCEPT loop callslockRemovalTID(PrehistoricTID)on covered parts. If a later iteration throws (e.g.,SERIALIZATION_ERRORfrom a concurrent transaction), the removal TID locks from previous iterations were never cleaned up.PrehistoricTIDlocks causing subsequent non-transactionalTRUNCATEoperations to fail with the LOGICAL_ERROR exception "Tried to lock part for removal second time", killing the server in debug builds.Related issue: #59103
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=8aaa13be4cb6810d70d58f144c97cafc344ec674&name_0=MasterCI&name_1=Stateless%20tests%20%28arm_binary%2C%20sequential%29
Test plan
03811_parallel_truncate_race4 times on debug build — all passedChangelog category (leave one):
Changelog entry:
Fix LOGICAL_ERROR exception "Tried to lock part for removal second time" on concurrent
TRUNCATEoperations.Version info
26.2.1.869