Fix fatal exception in loadDataPart for parts with outdated TIDs#96866
Merged
alexey-milovidov merged 1 commit intomasterfrom Feb 14, 2026
Merged
Fix fatal exception in loadDataPart for parts with outdated TIDs#96866alexey-milovidov merged 1 commit intomasterfrom
alexey-milovidov merged 1 commit intomasterfrom
Conversation
During part loading, `getCSNAndAssert` throws a fatal LOGICAL_ERROR when encountering a part whose creation TID has been cleaned up from the transaction log (tail_ptr moved past the TID's start_csn). This happens when a merge transaction fails (e.g., on an Ordinary database that doesn't support transactions) and leaves a part on disk with a TID that was never committed. As other transactions advance the log, the cleanup thread moves tail_ptr past the stale TID. Replace `getCSNAndAssert` with `getCSN` in `loadDataPart` for both creation and removal TIDs. When `getCSN` returns `UnknownCSN` for an outdated TID, the existing code correctly treats the part as from a rolled-back transaction (`RolledBackCSN`), marking it as outdated for removal. This is safe because if the transaction had been committed, its CSN would have been persisted to the part's metadata before the log entry was cleaned up. Fixes the server crash triggered by test `03915_intersecting_parts_rollback` from PR #96635. https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=e9b4a584c40ec53b02093d24df92975e0d72c87f&name_0=MasterCI&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
This was referenced Feb 27, 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
Trying to get CSN for too old TID) that shows up duringATTACH TABLEwhen loading parts with outdated TIDs from rolled-back transactionsgetCSNAndAssertwithgetCSNinloadDataPartfor both creation and removal TID lookups — the existing code already correctly treats unknown CSNs as rolled-back transactions03915_intersecting_parts_rollbackfrom PR Fix intersecting parts on disk from rolled-back merge transactions #96635, where failed merge transactions on an Ordinary database leave parts with stale TIDs that get cleaned up from the transaction log by other concurrent transactionsCI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=e9b4a584c40ec53b02093d24df92975e0d72c87f&name_0=MasterCI&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29
Test plan
03915_intersecting_parts_rollbackshould pass without crashing the serverChangelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
🤖 Generated with Claude Code