mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 18:35:46 +02:00
fix: remove fiber guard from non atomic section (#3381)
We might preempt when we serialize a big value and the code in journal was protected by an atomic guard triggering a check failed. * remove fiber guard from non atomic section * move LocalBlockingCounter to common --------- Signed-off-by: kostas <kostas@dragonflydb.io>
This commit is contained in:
parent
e2d65a0900
commit
4b851be57a
3 changed files with 30 additions and 31 deletions
|
@ -542,30 +542,6 @@ class DbSlice {
|
|||
|
||||
void CallChangeCallbacks(DbIndex id, std::string_view key, const ChangeReq& cr) const;
|
||||
|
||||
class LocalBlockingCounter {
|
||||
public:
|
||||
void lock() {
|
||||
++mutating_;
|
||||
}
|
||||
|
||||
void unlock() {
|
||||
DCHECK(mutating_ > 0);
|
||||
--mutating_;
|
||||
if (mutating_ == 0) {
|
||||
cond_var_.notify_one();
|
||||
}
|
||||
}
|
||||
|
||||
void Wait() {
|
||||
util::fb2::NoOpLock noop_lk_;
|
||||
cond_var_.wait(noop_lk_, [this]() { return mutating_ == 0; });
|
||||
}
|
||||
|
||||
private:
|
||||
util::fb2::CondVarAny cond_var_;
|
||||
size_t mutating_ = 0;
|
||||
};
|
||||
|
||||
// We need this because registered callbacks might yield. If RegisterOnChange
|
||||
// gets called after we preempt while iterating over the registered callbacks
|
||||
// (let's say in FlushChangeToEarlierCallbacks) we will get UB, because we pushed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue