Repository navigation
Do not apply serialization hints of a type changed by a concurrent ALTER to an INSERT - #133300
Conversation
…LTER` to an `INSERT` An `INSERT` with inline data took the metadata snapshot, then read the serialization hints of the table. A concurrent `ALTER TABLE ... MODIFY COLUMN` between the two gave the input format a hint built for the new type (`String`), applied to the old type of the snapshot (`Tuple`): `Bad cast` exception in debug builds, undefined behaviour in release (`std::bad_alloc` or a hang). `IStorage::getSerializationHints` now takes the metadata snapshot of the caller and, under the parts lock, returns only the hints of the columns whose types are the same in the snapshot and in the current metadata. Closes: #131943
|
Workflow [PR], commit [31a525e] Summary: ✅
AI ReviewSummaryThe PR prevents concurrent Missing context / blind spots
Final VerdictStatus: ✅ Approve |
…ent_alter`: TSV escapes quotes
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units725 translation units recompiled, 4627 s compile time in total, 725 of them have a recent master baseline. |
…ncurrent_alter` An asynchronous insert does not give the serialization hints to the input format, so it never reached the failpoint, and `SYSTEM WAIT FAILPOINT` waited until the timeout in the `AsyncInsert` job.
…y-serialization Conflict resolution: - `master` reverted the sparse serialization of `JSON` typed paths (#133486 reverting #111429), which removed `SerializationInfoNamed` and `SerializationInfoObject`. The `checkKindStacks` and `checkKindStackForType` overrides move back to `SerializationInfoTuple`, the ones of `SerializationInfoObject` are dropped together with the class, and `MutateTask` uses `canUseSparseSerialization` again instead of the removed `shouldCollectSerializationInfo`. - `NativeWriter::getSerializationAndColumn`: keep the materialization of non-native `LowCardinality` columns for old peers on top of the reverted code. - `tryGetSerializationHints` now takes the metadata snapshot (#133300): pass it through in the overrides this branch adds for the wrapper storages. - `tests/parallel_replicas_plan_based_blacklist.txt`: `master` removed the whole `UNIQUE KEY` section, because plan-based parallel replicas now keep such reads local (#133744), so `05449_auto_low_cardinality_serialization_unique_key` is not listed anymore. Co-Authored-By: Claude Fable 5.2 <[email protected]>
An
INSERTwith inline data (HTTP, TSV/CSV/JSONEachRow and other row formats) takes the metadata snapshot of the table, builds the pipeline, and only then readstable->getSerializationHintsfor the input format. A concurrentALTER TABLE ... MODIFY COLUMNbetween the two (#114019 publishes the new types and the hints atomically, but the reader took them at two different moments) gives the format a hint built for the new type, whichBlock::getSerializationshands to the old type of the snapshot. ForTuple->Stringthe baseSerializationInforeachesassert_cast<const SerializationInfoTuple &>inDataTypeTuple::getSerialization: aBad castexception in debug builds, undefined behaviour in release builds (std::bad_allocor a parser thread looping inwrapSerializationBasedOnKindStack).IStorage::getSerializationHints(andtryGetSerializationHints) now take the caller's metadata snapshot.MergeTreeDatareturns, underreadLockParts(the lock under whichsetPropertiesAndResetSerializationHintspublishes metadata and hints together), only the hints of the columns whose types are the same in the snapshot and in the current metadata. The same check replaces the non-atomic type filter ingetSerializationHintsForFileLikeStorage, andsystem.columnspasses its snapshot too.The new test pauses the
INSERTon a new failpointinsert_pause_before_reading_serialization_hints, runs theALTER, and checks that theINSERTsucceeds.Closes: #131943
Related: #114019
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
std::bad_alloc, a hang, or aBad castexception in anINSERTwith inline data (e.g. over HTTP) that ran concurrently withALTER TABLE ... MODIFY COLUMNchanging aTuplecolumn to another type.Workflow [PR]
Sync PR [sync-upstream/pr/133300]
Version info
26.12.1.211-master(included in26.12and later)