v.25.7Improvement
We get the StorageID, and without taking
InReplicatedMergeTree::executeMetadataAlter, we get the StorageID, and without taking DDLGuard, we try to callIDatabase::alterTable. In between this time we could have technically exchanged the table in question with another table, so when we get the definiton we would get the wrong one. To avoid this we add a separate check for UUIDs to match when we try to callIDatabase::alterTable. #82666 (Nikolay Degterinsky).
Why it matters
This feature addresses a race condition where the table being altered byReplicatedMergeTree::executeMetadataAlter might be replaced with a different table between obtaining its StorageID and executing IDatabase::alterTable. By adding a UUID match check before altering the table, it ensures that metadata changes are applied to the correct table instance, preventing inconsistencies due to table replacement.How to use it
This enhancement is applied internally inReplicatedMergeTree and requires no explicit user action. Users benefit automatically from more reliable ALTER TABLE operations on replicated tables.