Fixed deadlock in test when many replicas on single server try to execute multiple attaches and wait for each other [#METR-23507].

This commit is contained in:
Alexey Milovidov 2016-11-16 09:08:29 +03:00
parent 00fc6f5616
commit 866e64a65e

View File

@ -1207,13 +1207,9 @@ bool StorageReplicatedMergeTree::executeLogEntry(const LogEntry & entry)
} }
if (do_fetch) if (do_fetch)
{
String replica;
try
{ {
String covering_part; String covering_part;
replica = findReplicaHavingCoveringPart(entry.new_part_name, true, covering_part); String replica = findReplicaHavingCoveringPart(entry.new_part_name, true, covering_part);
if (replica.empty() && entry.type == LogEntry::ATTACH_PART) if (replica.empty() && entry.type == LogEntry::ATTACH_PART)
{ {
@ -1226,11 +1222,11 @@ bool StorageReplicatedMergeTree::executeLogEntry(const LogEntry & entry)
throw Exception("Logical error: no source replica specified for ATTACH_PART log entry;" throw Exception("Logical error: no source replica specified for ATTACH_PART log entry;"
" or trying to fetch part on source replica", ErrorCodes::LOGICAL_ERROR); " or trying to fetch part on source replica", ErrorCodes::LOGICAL_ERROR);
/// Подождём, пока реплика-инициатор подцепит кусок. throw Exception("No active replica has attached part " + entry.new_part_name + " or covering part yet", ErrorCodes::NO_REPLICA_HAS_PART);
waitForReplicaToProcessLogEntry(entry.source_replica, entry);
replica = findReplicaHavingCoveringPart(entry.new_part_name, true, covering_part);
} }
try
{
if (replica.empty()) if (replica.empty())
{ {
/** Если кусок должен быть записан с кворумом, и кворум ещё недостигнут, /** Если кусок должен быть записан с кворумом, и кворум ещё недостигнут,