mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
Fixed error in ZK library [#CLICKHOUSE-3753]
This commit is contained in:
parent
84532a2a30
commit
ce12f0b37c
@ -996,13 +996,14 @@ void ZooKeeper::receiveEvent()
|
||||
|
||||
void ZooKeeper::finalize(bool error_send, bool error_receive)
|
||||
{
|
||||
std::unique_lock lock(finalize_mutex, std::defer_lock);
|
||||
if (!lock.try_lock())
|
||||
return;
|
||||
{
|
||||
/// Will wait for pushRequest method.
|
||||
std::unique_lock lock(expired_mutex);
|
||||
|
||||
if (expired)
|
||||
return;
|
||||
expired = true;
|
||||
}
|
||||
|
||||
active_session_metric_increment.destroy();
|
||||
|
||||
@ -1020,6 +1021,7 @@ void ZooKeeper::finalize(bool error_send, bool error_receive)
|
||||
/// This happens for example, when "Cannot push request to queue within operation timeout".
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
send_thread.join();
|
||||
}
|
||||
|
||||
@ -1348,7 +1350,7 @@ void ZooKeeper::pushRequest(RequestInfo && info)
|
||||
/// to avoid forgotten operations in the queue when session is expired.
|
||||
/// Invariant: when expired, no new operations will be pushed to the queue in 'pushRequest'
|
||||
/// and the queue will be drained in 'finalize'.
|
||||
std::lock_guard lock(finalize_mutex);
|
||||
std::lock_guard lock(expired_mutex);
|
||||
|
||||
if (expired)
|
||||
throw Exception("Session expired", ZSESSIONEXPIRED);
|
||||
|
@ -573,7 +573,7 @@ private:
|
||||
|
||||
std::atomic<XID> xid {1};
|
||||
std::atomic<bool> expired {false};
|
||||
std::mutex finalize_mutex;
|
||||
std::mutex expired_mutex;
|
||||
|
||||
using clock = std::chrono::steady_clock;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user