Skip to content

Commit 9cf0db2

Browse files
Backport #83095 to 25.6: hold the temporary part lock when executeReplaceRange
1 parent c35db65 commit 9cf0db2

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/Storages/StorageReplicatedMergeTree.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3089,8 +3089,6 @@ bool StorageReplicatedMergeTree::executeReplaceRange(LogEntry & entry)
30893089
}
30903090
}
30913091

3092-
static const String TMP_PREFIX = "tmp_replace_from_";
3093-
30943092
auto obtain_part = [&] (PartDescriptionPtr & part_desc)
30953093
{
30963094
/// Fetches with zero-copy-replication are cheap, but cloneAndLoadDataPart(must_on_same_disk=true) will do full copy.
@@ -3114,7 +3112,7 @@ bool StorageReplicatedMergeTree::executeReplaceRange(LogEntry & entry)
31143112
};
31153113
auto [res_part, temporary_part_lock] = cloneAndLoadDataPart(
31163114
part_desc->src_table_part,
3117-
TMP_PREFIX + "clone_",
3115+
TMP_PREFIX_REPLACE_PARTITION_FROM + "clone_",
31183116
part_desc->new_part_info,
31193117
metadata_snapshot,
31203118
clone_params,
@@ -3132,19 +3130,18 @@ bool StorageReplicatedMergeTree::executeReplaceRange(LogEntry & entry)
31323130

31333131
auto credentials = getContext()->getInterserverCredentials();
31343132
String interserver_scheme = getContext()->getInterserverScheme();
3135-
scope_guard part_temp_directory_lock;
31363133

31373134
if (interserver_scheme != address.scheme)
31383135
throw Exception(ErrorCodes::LOGICAL_ERROR,
31393136
"Interserver schemas are different '{}' != '{}', can't fetch part from {}",
31403137
interserver_scheme, address.scheme, address.host);
31413138

3142-
auto [fetched_part, lock] = fetcher.fetchSelectedPart(
3139+
auto [fetched_part, temporary_part_lock] = fetcher.fetchSelectedPart(
31433140
metadata_snapshot, getContext(), part_desc->found_new_part_name, zookeeper_info.zookeeper_name, source_replica_path,
31443141
address.host, address.replication_port, timeouts, credentials->getUser(), credentials->getPassword(),
3145-
interserver_scheme, replicated_fetches_throttler, false, TMP_PREFIX + "fetch_");
3142+
interserver_scheme, replicated_fetches_throttler, false, TMP_PREFIX_REPLACE_PARTITION_FROM + "fetch_");
31463143
part_desc->res_part = fetched_part;
3147-
part_temp_directory_lock = std::move(lock);
3144+
part_desc->temporary_part_lock = std::move(temporary_part_lock);
31483145

31493146
/// TODO: check columns_version of fetched part
31503147

0 commit comments

Comments
 (0)