fix deadlock during fetching part

This commit is contained in:
metahys 2022-05-22 12:00:13 +08:00
parent 74f5301225
commit 6ae8a26fae

View File

@ -453,6 +453,8 @@ MergeTreeData::MutableDataPartPtr Fetcher::fetchPart(
creds.setPassword(password);
}
bool retry_without_zero_copy = false;
{
PooledReadWriteBufferFromHTTP in{
uri,
Poco::Net::HTTPRequest::HTTP_POST,
@ -536,12 +538,12 @@ MergeTreeData::MutableDataPartPtr Fetcher::fetchPart(
throw;
LOG_WARNING(log, fmt::runtime(e.message() + " Will retry fetching part without zero-copy."));
/// Try again but without zero-copy
return fetchPart(metadata_snapshot, context, part_name, replica_path, host, port, timeouts,
user, password, interserver_scheme, throttler, to_detached, tmp_prefix_, nullptr, false, disk);
/// Try again later but without zero-copy
retry_without_zero_copy = true;
}
}
else
{
auto storage_id = data.getStorageID();
String new_part_path = part_type == "InMemory" ? "memory" : fs::path(data.getFullPathOnDisk(disk)) / part_name / "";
auto entry = data.getContext()->getReplicatedFetchList().insert(
@ -559,6 +561,14 @@ MergeTreeData::MutableDataPartPtr Fetcher::fetchPart(
return part_type == "InMemory"
? downloadPartToMemory(part_name, part_uuid, metadata_snapshot, context, disk, in, projections, throttler)
: downloadPartToDisk(part_name, replica_path, to_detached, tmp_prefix_, sync, disk, in, projections, checksums, throttler);
}
}
if (retry_without_zero_copy)
return fetchPart(metadata_snapshot, context, part_name, replica_path, host, port, timeouts,
user, password, interserver_scheme, throttler, to_detached, tmp_prefix_, nullptr, false, disk);
else
throw Exception(ErrorCodes::LOGICAL_ERROR, "Can't fetch part and no retry. It is a bug.");
}
MergeTreeData::MutableDataPartPtr Fetcher::downloadPartToMemory(