mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 19:12:03 +00:00
dbms: fixed race condition in SingleBarrier [#METR-18510]
This commit is contained in:
parent
18930e5bb5
commit
b62b499a9c
@ -41,6 +41,22 @@ SingleBarrier::SingleBarrier(GetZooKeeper get_zookeeper_, const std::string & pa
|
|||||||
if ((code != ZOK) && (code != ZNODEEXISTS))
|
if ((code != ZOK) && (code != ZNODEEXISTS))
|
||||||
throw KeeperException{code};
|
throw KeeperException{code};
|
||||||
|
|
||||||
|
if (code == ZNODEEXISTS)
|
||||||
|
{
|
||||||
|
/// This barrier is already being created by another node.
|
||||||
|
/// Wait until it has been fully created so that it is usable.
|
||||||
|
if (!zookeeper->exists(path + "/lock", nullptr, event))
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
abortIfRequested();
|
||||||
|
}
|
||||||
|
while (!event->tryWait(wait_duration));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// List of tokens.
|
/// List of tokens.
|
||||||
code = zookeeper->tryCreate(path + "/tokens", "", CreateMode::Persistent);
|
code = zookeeper->tryCreate(path + "/tokens", "", CreateMode::Persistent);
|
||||||
if ((code != ZOK) && (code != ZNODEEXISTS))
|
if ((code != ZOK) && (code != ZNODEEXISTS))
|
||||||
|
Loading…
Reference in New Issue
Block a user