[refactor](load) rename flush_memtable_and_wait to flush_async (#23204)

This commit is contained in:
Kaijie Chen
2023-08-22 20:07:50 +08:00
committed by GitHub
parent 1609b6cbf2
commit eeec26d68d
3 changed files with 8 additions and 20 deletions

View File

@ -124,7 +124,7 @@ void MemTableMemoryLimiter::handle_memtable_flush() {
}
int64_t mem_size = mem_item.mem_size;
writers_to_reduce_mem.emplace_back(writer, mem_size);
st = writer->flush_memtable_and_wait(false);
st = writer->flush_async();
if (!st.ok()) {
auto err_msg = fmt::format(
"tablet writer failed to reduce mem consumption by flushing memtable, "

View File

@ -130,7 +130,7 @@ Status MemTableWriter::_flush_memtable_async() {
return _flush_token->submit(std::move(_mem_table));
}
Status MemTableWriter::flush_memtable_and_wait(bool need_wait) {
Status MemTableWriter::flush_async() {
std::lock_guard<std::mutex> l(_lock);
if (!_is_init || _is_closed) {
// This writer is uninitialized or closed before flushing, do nothing.
@ -149,16 +149,7 @@ Status MemTableWriter::flush_memtable_and_wait(bool need_wait) {
<< ", load id: " << print_id(_req.load_id);
auto s = _flush_memtable_async();
_reset_mem_table();
if (UNLIKELY(!s.ok())) {
return s;
}
if (need_wait) {
// wait all memtables in flush queue to be flushed.
SCOPED_RAW_TIMER(&_wait_flush_time_ns);
RETURN_IF_ERROR(_flush_token->wait());
}
return Status::OK();
return s;
}
Status MemTableWriter::wait_flush() {
@ -166,7 +157,7 @@ Status MemTableWriter::wait_flush() {
std::lock_guard<std::mutex> l(_lock);
if (!_is_init || _is_closed) {
// return OK instead of NOT_INITIALIZED or ALREADY_CLOSED for same reason
// as described in flush_memtable_and_wait()
// as described in flush_async()
return Status::OK();
}
if (_is_cancelled) {

View File

@ -91,16 +91,13 @@ public:
Status cancel();
Status cancel_with_status(const Status& st);
// submit current memtable to flush queue, and wait all memtables in flush queue
// to be flushed.
// This is currently for reducing mem consumption of this delta writer.
// If need_wait is true, it will wait for all memtable in flush queue to be flushed.
// Otherwise, it will just put memtables to the flush queue and return.
Status flush_memtable_and_wait(bool need_wait);
int64_t mem_consumption(MemType mem);
int64_t active_memtable_mem_consumption();
// Submit current memtable to flush queue, and return without waiting.
// This is currently for reducing mem consumption of this memtable writer.
Status flush_async();
// Wait all memtable in flush queue to be flushed
Status wait_flush();