Fix processing INSERT after metadata mutations that had not been applied yet

The problem is that right now INSERT may write old columns even after
metadata mutation (i.e. RENAME), because it will simply write the new
block number that is bigger then metadata version, and so this part
won't be mutated.

To fix this, it should get the mutation version from metadata - this is
quite a major change!

Fixes: 2555_davengers_rename_chain
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
Azat Khuzhin 2024-03-06 23:40:40 +01:00
parent be6777bc86
commit c048ab9d6d
2 changed files with 2 additions and 2 deletions

View File

@ -430,7 +430,7 @@ MergeTreeDataWriter::TemporaryPart MergeTreeDataWriter::writeTempPartImpl(
MergeTreePartition partition(block_with_partition.partition);
MergeTreePartInfo new_part_info(partition.getID(metadata_snapshot->getPartitionKey().sample_block), block_number, block_number, 0);
MergeTreePartInfo new_part_info(partition.getID(metadata_snapshot->getPartitionKey().sample_block), block_number, block_number, 0, metadata_snapshot->getMetadataVersion());
String part_name;
if (data.format_version < MERGE_TREE_DATA_MIN_FORMAT_VERSION_WITH_CUSTOM_PARTITIONING)
{

View File

@ -859,7 +859,7 @@ std::pair<std::vector<String>, bool> ReplicatedMergeTreeSinkImpl<async_insert>::
part->info.min_block = block_number;
part->info.max_block = block_number;
part->info.level = 0;
part->info.mutation = 0;
part->info.mutation = metadata_snapshot->getMetadataVersion();
part->setName(part->getNewName(part->info));
retry_context.actual_part_name = part->name;