v.25.7Improvement

We get the StorageID, and without taking

In ReplicatedMergeTree::executeMetadataAlter, we get the StorageID, and without taking DDLGuard, we try to call IDatabase::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 call IDatabase::alterTable. #82666 (Nikolay Degterinsky).
Improved consistency check in ReplicatedMergeTree to verify table UUIDs before applying metadata alterations.

Why it matters

This feature addresses a race condition where the table being altered by ReplicatedMergeTree::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 in ReplicatedMergeTree and requires no explicit user action. Users benefit automatically from more reliable ALTER TABLE operations on replicated tables.