Repository navigation
Roll back partial ColumnArrayT and ColumnTupleT appends on exception - #637
Open
shafiktanbir wants to merge 1 commit into
Open
shafiktanbir wants to merge 1 commit into
shafiktanbir wants to merge 1 commit into
Conversation
Restore nested and element columns to their prior row count when an element append throws in ColumnArrayT::Append or ColumnTupleT::Append. Closes ClickHouse#636
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.
When
ColumnArrayT::AppendorColumnTupleT::Appendthrows after appending earlier elements, those elements remained in the nested columns without a matching array offset or full tuple row. Subsequent rows then read shifted values andSaveBodywrote extra bytes on insert.Record the initial column size and restore modified nested or element columns in place via
SliceandSwapwhen an exception is thrown, which also coversColumnMapT::Append.Closes #636
Note
Medium Risk
Touches core column append paths used during inserts; behavior change is narrower and more correct on errors, but any mistake in rollback could affect data integrity.
Overview
Fixes partial-append corruption when validation fails mid-row on composite columns.
ColumnArrayT::Appendnow records nested data size before appending elements, only updates array offsets on success, and on any exception rolls back partially appended nested values viaSlice+Swapbefore rethrowing.ColumnTupleT::AppendTupleuses the same pattern per tuple field: if a later field throws, earlier fields that already grew are restored in place so row counts stay aligned.Because
ColumnMapT::Appendbuilds on the same array/tuple paths, map inserts get the same safety. New unit tests cover array (including Save/Load after a failed append), tuple (including column order where failure happens on the second field), and map rollback.Reviewed by Cursor Bugbot for commit 307c811. Bugbot is set up for automated code reviews on this repo. Configure here.