diff options
author | ssid <ssid@google.com> | 2015-11-11 03:54:18 -0800 |
---|---|---|
committer | Chris Mumford <cmumford@chromium.org> | 2015-12-09 11:27:50 -0800 |
commit | 706b7f8d43b0aecdc75c5ee49d3e4ef5f27b9faf (patch) | |
tree | ed75013f457e307920f2f250f7efa4807dd168c8 /db/memtable.h | |
parent | 3c9ff3c691bc4ccb6098ed80bd71e33a36892f5a (diff) | |
download | leveldb-706b7f8d43b0aecdc75c5ee49d3e4ef5f27b9faf.tar.gz |
Resolve race when getting approximate-memory-usage property
The write operations in the table happens without holding the mutex
lock, but concurrent writes are avoided using "writers_" queue.
The Arena::MemoryUsage could access the blocks when write happens.
So, the memory usage is cached in atomic word and can be loaded
from any thread safely.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=107573379
Diffstat (limited to 'db/memtable.h')
-rw-r--r-- | db/memtable.h | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/db/memtable.h b/db/memtable.h index 92e90bb..9f41567 100644 --- a/db/memtable.h +++ b/db/memtable.h @@ -36,10 +36,7 @@ class MemTable { } // Returns an estimate of the number of bytes of data in use by this - // data structure. - // - // REQUIRES: external synchronization to prevent simultaneous - // operations on the same MemTable. + // data structure. It is safe to call when MemTable is being modified. size_t ApproximateMemoryUsage(); // Return an iterator that yields the contents of the memtable. |