File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -1241,7 +1241,7 @@ Status DBImpl::HandleMaxWalSize(WriteContext* write_context) {
1241
1241
}
1242
1242
}
1243
1243
}
1244
- if (cfd_picked != nullptr ) {
1244
+ if (cfd_picked != nullptr && cfd_picked-> mem ()-> SwitchFlushScheduled () ) {
1245
1245
uint64_t alive_log_files_back_size = alive_log_files_.back ().size ;
1246
1246
uint64_t max_wal_size = GetMaxWalSize ();
1247
1247
ROCKS_LOG_BUFFER (
Original file line number Diff line number Diff line change @@ -149,6 +149,16 @@ class MemTable {
149
149
std::memory_order_relaxed);
150
150
}
151
151
152
+ bool SwitchFlushScheduled () {
153
+ auto state = flush_state_.load (std::memory_order_relaxed);
154
+ if (state == FLUSH_NOT_REQUESTED) {
155
+ flush_state_.compare_exchange_strong (state, FLUSH_REQUESTED,
156
+ std::memory_order_relaxed,
157
+ std::memory_order_relaxed);
158
+ }
159
+ return MarkFlushScheduled ();
160
+ }
161
+
152
162
// Return an iterator that yields the contents of the memtable.
153
163
//
154
164
// The caller must ensure that the underlying MemTable remains live
You can’t perform that action at this time.
0 commit comments