Fix data race in DDLWorker

This commit is contained in:
Alexey Milovidov 2023-01-01 21:38:31 +01:00
parent 8868a5e944
commit 1f612042dc
3 changed files with 13 additions and 2 deletions

View File

@ -29,6 +29,13 @@ namespace ErrorCodes
extern const int DNS_ERROR;
}
DDLTaskBase::~DDLTaskBase()
{
chassert(completely_processed);
}
HostID HostID::fromString(const String & host_port_str)
{
HostID res;
@ -36,6 +43,7 @@ HostID HostID::fromString(const String & host_port_str)
return res;
}
bool HostID::isLocalAddress(UInt16 clickhouse_port) const
{
try

View File

@ -114,7 +114,7 @@ struct DDLTaskBase
DDLTaskBase(const String & name, const String & path) : entry_name(name), entry_path(path) {}
DDLTaskBase(const DDLTaskBase &) = delete;
virtual ~DDLTaskBase() = default;
virtual ~DDLTaskBase();
virtual void parseQueryFromEntry(ContextPtr context);
void formatRewrittenQuery(ContextPtr context);

View File

@ -279,7 +279,9 @@ void DDLWorker::scheduleTasks(bool reinitialized)
task->completely_processed = true;
}
else
{
processTask(*task, zookeeper);
}
++task_it;
}
else
@ -291,6 +293,7 @@ void DDLWorker::scheduleTasks(bool reinitialized)
/// of log entry number (with leading zeros).
if (!first_failed_task_name || task->entry_name < *first_failed_task_name)
first_failed_task_name = task->entry_name;
task_it = current_tasks.erase(task_it);
}
}
@ -660,8 +663,8 @@ void DDLWorker::processTask(DDLTaskBase & task, const ZooKeeperPtr & zookeeper)
active_node->setAlreadyRemoved();
task.createSyncedNodeIfNeed(zookeeper);
task.completely_processed = true;
updateMaxDDLEntryID(task.entry_name);
task.completely_processed = true;
}