Use copy for some operations instead of hardlinks

This commit is contained in:
alesapin 2022-09-27 14:38:13 +02:00
parent 1719e000ea
commit d4d4f92976
2 changed files with 6 additions and 2 deletions

View File

@ -1516,12 +1516,14 @@ void IMergeTreeDataPart::renameToDetached(const String & prefix, DataPartStorage
void IMergeTreeDataPart::makeCloneInDetached(const String & prefix, const StorageMetadataPtr & /*metadata_snapshot*/) const void IMergeTreeDataPart::makeCloneInDetached(const String & prefix, const StorageMetadataPtr & /*metadata_snapshot*/) const
{ {
auto storage_settings = storage.getSettings();
bool copy_instead_of_hardlink = isStoredOnRemoteDiskWithZeroCopySupport() && storage.supportsReplication() && storage_settings->allow_remote_fs_zero_copy_replication;
data_part_storage->freeze( data_part_storage->freeze(
storage.relative_data_path, storage.relative_data_path,
getRelativePathForDetachedPart(prefix), getRelativePathForDetachedPart(prefix),
/*make_source_readonly*/ true, /*make_source_readonly*/ true,
{}, {},
/*copy_instead_of_hardlink*/ false); copy_instead_of_hardlink);
} }
DataPartStoragePtr IMergeTreeDataPart::makeCloneOnDisk(const DiskPtr & disk, const String & directory_name) const DataPartStoragePtr IMergeTreeDataPart::makeCloneOnDisk(const DiskPtr & disk, const String & directory_name) const

View File

@ -1507,8 +1507,10 @@ bool MutateTask::prepare()
if (ctx->source_part->isStoredOnDisk() && !isStorageTouchedByMutations( if (ctx->source_part->isStoredOnDisk() && !isStorageTouchedByMutations(
ctx->storage_from_source_part, ctx->metadata_snapshot, ctx->commands_for_part, Context::createCopy(context_for_reading))) ctx->storage_from_source_part, ctx->metadata_snapshot, ctx->commands_for_part, Context::createCopy(context_for_reading)))
{ {
auto settings_ptr = ctx->data->getSettings();
bool copy_instead_of_hardlink = ctx->data->supportsReplication() && settings_ptr->allow_remote_fs_zero_copy_replication && ctx->source_part->isStoredOnRemoteDiskWithZeroCopySupport();
LOG_TRACE(ctx->log, "Part {} doesn't change up to mutation version {}", ctx->source_part->name, ctx->future_part->part_info.mutation); LOG_TRACE(ctx->log, "Part {} doesn't change up to mutation version {}", ctx->source_part->name, ctx->future_part->part_info.mutation);
auto [part, lock] = ctx->data->cloneAndLoadDataPartOnSameDisk(ctx->source_part, "tmp_clone_", ctx->future_part->part_info, ctx->metadata_snapshot, ctx->txn, &ctx->hardlinked_files, false); auto [part, lock] = ctx->data->cloneAndLoadDataPartOnSameDisk(ctx->source_part, "tmp_clone_", ctx->future_part->part_info, ctx->metadata_snapshot, ctx->txn, &ctx->hardlinked_files, copy_instead_of_hardlink);
ctx->temporary_directory_lock = std::move(lock); ctx->temporary_directory_lock = std::move(lock);
promise.set_value(std::move(part)); promise.set_value(std::move(part));
return false; return false;