mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Correctly cleanup sequential node in ZooKeeperWithFaultInjection
This commit is contained in:
parent
66847386df
commit
33cf697028
@ -257,19 +257,22 @@ public:
|
||||
|
||||
Coordination::Error tryCreate(const std::string & path, const std::string & data, int32_t mode, std::string & path_created)
|
||||
{
|
||||
path_created.clear();
|
||||
|
||||
auto error = access(
|
||||
"tryCreate",
|
||||
path,
|
||||
[&]() { return keeper->tryCreate(path, data, mode, path_created); },
|
||||
[&](Coordination::Error &)
|
||||
[&](Coordination::Error & code)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (mode == zkutil::CreateMode::EphemeralSequential || mode == zkutil::CreateMode::Ephemeral)
|
||||
if (!path_created.empty() && (mode == zkutil::CreateMode::EphemeralSequential || mode == zkutil::CreateMode::Ephemeral))
|
||||
{
|
||||
keeper->remove(path);
|
||||
keeper->remove(path_created);
|
||||
if (unlikely(logger))
|
||||
LOG_TRACE(logger, "ZooKeeperWithFaultInjection cleanup: seed={} func={} path={}", seed, "tryCreate", path);
|
||||
LOG_TRACE(logger, "ZooKeeperWithFaultInjection cleanup: seed={} func={} path={} path_created={} code={}",
|
||||
seed, "tryCreate", path, path_created, code);
|
||||
}
|
||||
}
|
||||
catch (const zkutil::KeeperException & e)
|
||||
@ -277,10 +280,11 @@ public:
|
||||
if (unlikely(logger))
|
||||
LOG_TRACE(
|
||||
logger,
|
||||
"ZooKeeperWithFaultInjection cleanup FAILED: seed={} func={} path={} code={} message={} ",
|
||||
"ZooKeeperWithFaultInjection cleanup FAILED: seed={} func={} path={} path_created={} code={} message={} ",
|
||||
seed,
|
||||
"tryCreate",
|
||||
path,
|
||||
path_created,
|
||||
e.code,
|
||||
e.message());
|
||||
}
|
||||
@ -289,8 +293,8 @@ public:
|
||||
/// collect ephemeral nodes when no fault was injected (to clean up later)
|
||||
if (unlikely(fault_policy))
|
||||
{
|
||||
if (mode == zkutil::CreateMode::EphemeralSequential || mode == zkutil::CreateMode::Ephemeral)
|
||||
ephemeral_nodes.push_back(path);
|
||||
if (!path_created.empty() && (mode == zkutil::CreateMode::EphemeralSequential || mode == zkutil::CreateMode::Ephemeral))
|
||||
ephemeral_nodes.push_back(path_created);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
Loading…
Reference in New Issue
Block a user