Skip to content

Commit c966bdc

Browse files
[enhancement](memtable) merge redundant mutex locks in _flush_memtable_async
The two consecutive lock_guard blocks were locking the same mutex (_mem_table_ptr_lock) with no operations in between, which is redundant. This commit merges them into a single lock scope to: 1. Reduce unnecessary lock/unlock overhead 2. Improve code readability
1 parent f926421 commit c966bdc

1 file changed

Lines changed: 0 additions & 3 deletions

File tree

be/src/olap/memtable_writer.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,6 @@ Status MemTableWriter::_flush_memtable_async() {
160160
std::lock_guard<std::mutex> l(_mem_table_ptr_lock);
161161
memtable = _mem_table;
162162
_mem_table = nullptr;
163-
}
164-
{
165-
std::lock_guard<std::mutex> l(_mem_table_ptr_lock);
166163
memtable->update_mem_type(MemType::WRITE_FINISHED);
167164
_freezed_mem_tables.push_back(memtable);
168165
}

0 commit comments

Comments
 (0)