diff --git a/db/memtable.h b/db/memtable.h index f1dbb7012088963e198355ba6cb1e4e823345ba9..e4594100781c520d2b46baf6afc6591ecb9055d4 100644 --- a/db/memtable.h +++ b/db/memtable.h @@ -336,6 +336,14 @@ class MemTable { mem_tracker_.DoneAllocating(); } + // Notify the underlying storage that all data it contained has been + // persisted. + // REQUIRES: external synchronization to prevent simultaneous + // operations on the same MemTable. + void MarkFlushed() { + table_->MarkFlushed(); + } + // return true if the current MemTableRep supports merge operator. bool IsMergeOperatorSupported() const { return table_->IsMergeOperatorSupported(); diff --git a/db/memtable_list.cc b/db/memtable_list.cc index d89e31e762096fa18a437d42e509453ed6cbfa69..7c3cad54a959444c95cca51e063fe1c34a804f31 100644 --- a/db/memtable_list.cc +++ b/db/memtable_list.cc @@ -248,6 +248,7 @@ void MemTableListVersion::Remove(MemTable* m, assert(refs_ == 1); // only when refs_ == 1 is MemTableListVersion mutable memlist_.remove(m); + m->MarkFlushed(); if (max_write_buffer_number_to_maintain_ > 0) { memlist_history_.push_front(m); TrimHistory(to_delete); diff --git a/include/rocksdb/memtablerep.h b/include/rocksdb/memtablerep.h index 4b6e897a6d863a47c0bd9b2287373e438dba21dc..4c2a23e0a818ba476fe17bf738116bbd7c5cfdf4 100644 --- a/include/rocksdb/memtablerep.h +++ b/include/rocksdb/memtablerep.h @@ -144,6 +144,14 @@ class MemTableRep { // or any writes done directly to entries accessed through the iterator.) virtual void MarkReadOnly() { } + // Notify this table rep that it has been flushed to stable storage. + // By default, does nothing. + // + // Invariant: MarkReadOnly() is called, before MarkFlushed(). + // Note that this method if overridden, should not run for an extended period + // of time. Otherwise, RocksDB may be blocked. + virtual void MarkFlushed() { } + // Look up key from the mem table, since the first key in the mem table whose // user_key matches the one given k, call the function callback_func(), with // callback_args directly forwarded as the first parameter, and the mem table