mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
logbroker-import: develop partition release
This commit is contained in:
parent
34b27dbbe4
commit
aaf4207c38
@ -59,6 +59,7 @@ namespace zkutil
|
||||
Status tryCheck() const;
|
||||
|
||||
void unlock();
|
||||
void unlockAndMoveIfFailed(std::vector<zkutil::Lock> & failed_to_unlock_locks);
|
||||
|
||||
bool tryLock();
|
||||
|
||||
|
@ -58,6 +58,7 @@ void Lock::unlock()
|
||||
{
|
||||
size_t attempt;
|
||||
int32_t code = zookeeper->tryRemoveEphemeralNodeWithRetries(lock_path, -1, &attempt);
|
||||
|
||||
if (attempt)
|
||||
{
|
||||
if (code != ZOK)
|
||||
@ -119,3 +120,21 @@ std::string Lock::status2String(Status status)
|
||||
return names[status];
|
||||
}
|
||||
|
||||
void Lock::unlockAndMoveIfFailed(std::vector<zkutil::Lock> & failed_to_unlock_locks)
|
||||
{
|
||||
try
|
||||
{
|
||||
unlock();
|
||||
}
|
||||
catch (const zkutil::KeeperException & e)
|
||||
{
|
||||
if (e.isTemporaryError())
|
||||
{
|
||||
LOG_WARNING(log, "Fail to unlock lock. Move lock to vector to remove later. Path: " << getPath());
|
||||
failed_to_unlock_locks.emplace_back(std::move(*this));
|
||||
}
|
||||
else
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user