mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Set writer_thread_id earlier, when new exclusive owener is waiting for existing readers to finish
This commit is contained in:
parent
55d1656f4d
commit
bb0b29f6e5
@ -31,11 +31,13 @@ void SharedMutex::lock()
|
||||
break;
|
||||
}
|
||||
|
||||
/// The first step of acquiring the exclusive ownership is finished.
|
||||
/// Now we just wait until all readers release the shared ownership.
|
||||
writer_thread_id.store(getThreadId());
|
||||
|
||||
value |= writers;
|
||||
while (value & readers)
|
||||
futexWaitLowerFetch(state, value);
|
||||
|
||||
writer_thread_id.store(getThreadId());
|
||||
}
|
||||
|
||||
bool SharedMutex::try_lock()
|
||||
|
@ -38,7 +38,7 @@ private:
|
||||
|
||||
alignas(64) std::atomic<UInt64> state;
|
||||
std::atomic<UInt32> waiters;
|
||||
/// Is set while the lock is held in exclusive mode only to facilitate debugging
|
||||
/// Is set while the lock is held (or is in the process of being acquired) in exclusive mode only to facilitate debugging
|
||||
std::atomic<UInt64> writer_thread_id;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user