Skip to content

Commit

Permalink
Avoid chaos between NotifyOnMemTableSealed and NotifyOnFlushCompleted (
Browse files Browse the repository at this point in the history
…#347)

Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
  • Loading branch information
SpadeA-Tang committed Sep 9, 2023
1 parent e2f6ec7 commit 20225a4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions db/db_impl/db_impl_write.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2254,11 +2254,16 @@ Status DBImpl::SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context) {
mutable_cf_options);

#ifndef ROCKSDB_LITE
mutex_.Unlock();
// From above, the memtable has been converted to imm memtable and apended to
// memlist. If we unlock here, it has possibility to be picked by a concurrent
// flush job. Furthermore, that flush job may even be completed and calls
// NotifyOnFlushCompleted before the following NotifyOnMemTableSealed which
// can cause troubles.
// So, unlike Facebook/Rocksdb, we does not unlock here.

// Notify client that memtable is sealed, now that we have successfully
// installed a new memtable
NotifyOnMemTableSealed(cfd, memtable_info);
mutex_.Lock();
#endif // ROCKSDB_LITE
// It is possible that we got here without checking the value of i_os, but
// that is okay. If we did, it most likely means that s was already an error.
Expand Down

0 comments on commit 20225a4

Please sign in to comment.