mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +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)
|
Coordination::Error tryCreate(const std::string & path, const std::string & data, int32_t mode, std::string & path_created)
|
||||||
{
|
{
|
||||||
|
path_created.clear();
|
||||||
|
|
||||||
auto error = access(
|
auto error = access(
|
||||||
"tryCreate",
|
"tryCreate",
|
||||||
path,
|
path,
|
||||||
[&]() { return keeper->tryCreate(path, data, mode, path_created); },
|
[&]() { return keeper->tryCreate(path, data, mode, path_created); },
|
||||||
[&](Coordination::Error &)
|
[&](Coordination::Error & code)
|
||||||
{
|
{
|
||||||
try
|
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))
|
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)
|
catch (const zkutil::KeeperException & e)
|
||||||
@ -277,10 +280,11 @@ public:
|
|||||||
if (unlikely(logger))
|
if (unlikely(logger))
|
||||||
LOG_TRACE(
|
LOG_TRACE(
|
||||||
logger,
|
logger,
|
||||||
"ZooKeeperWithFaultInjection cleanup FAILED: seed={} func={} path={} code={} message={} ",
|
"ZooKeeperWithFaultInjection cleanup FAILED: seed={} func={} path={} path_created={} code={} message={} ",
|
||||||
seed,
|
seed,
|
||||||
"tryCreate",
|
"tryCreate",
|
||||||
path,
|
path,
|
||||||
|
path_created,
|
||||||
e.code,
|
e.code,
|
||||||
e.message());
|
e.message());
|
||||||
}
|
}
|
||||||
@ -289,8 +293,8 @@ public:
|
|||||||
/// collect ephemeral nodes when no fault was injected (to clean up later)
|
/// collect ephemeral nodes when no fault was injected (to clean up later)
|
||||||
if (unlikely(fault_policy))
|
if (unlikely(fault_policy))
|
||||||
{
|
{
|
||||||
if (mode == zkutil::CreateMode::EphemeralSequential || mode == zkutil::CreateMode::Ephemeral)
|
if (!path_created.empty() && (mode == zkutil::CreateMode::EphemeralSequential || mode == zkutil::CreateMode::Ephemeral))
|
||||||
ephemeral_nodes.push_back(path);
|
ephemeral_nodes.push_back(path_created);
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
|
Loading…
Reference in New Issue
Block a user