Skip to content

Commit

Permalink
[fix](load) fix nullptr when getting memtable flush running count (ap…
Browse files Browse the repository at this point in the history
…ache#28942)

* [fix](load) fix nullptr when getting memtable flush running count

* style
  • Loading branch information
kaijchen authored Dec 25, 2023
1 parent 1d984e0 commit c2eabbd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions be/src/olap/delta_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ Status BaseDeltaWriter::write(const vectorized::Block* block, const std::vector<
if (!_is_init && !_is_cancelled) {
RETURN_IF_ERROR(init());
}
while (_memtable_writer->get_flush_token_stats().flush_running_count >=
config::memtable_flush_running_count_limit) {
while (_memtable_writer->flush_running_count() >= config::memtable_flush_running_count_limit) {
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
return _memtable_writer->write(block, row_idxs, is_append);
Expand Down
4 changes: 1 addition & 3 deletions be/src/olap/delta_writer_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "gutil/strings/numbers.h"
#include "io/fs/file_writer.h" // IWYU pragma: keep
#include "olap/data_dir.h"
#include "olap/memtable_flush_executor.h"
#include "olap/olap_define.h"
#include "olap/rowset/beta_rowset.h"
#include "olap/rowset/beta_rowset_writer_v2.h"
Expand Down Expand Up @@ -153,8 +152,7 @@ Status DeltaWriterV2::write(const vectorized::Block* block, const std::vector<ui
if (!_is_init && !_is_cancelled) {
RETURN_IF_ERROR(init());
}
while (_memtable_writer->get_flush_token_stats().flush_running_count >=
config::memtable_flush_running_count_limit) {
while (_memtable_writer->flush_running_count() >= config::memtable_flush_running_count_limit) {
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
SCOPED_RAW_TIMER(&_write_memtable_time);
Expand Down
4 changes: 4 additions & 0 deletions be/src/olap/memtable_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ const FlushStatistic& MemTableWriter::get_flush_token_stats() {
return _flush_token->get_stats();
}

uint64_t MemTableWriter::flush_running_count() const {
return _flush_token == nullptr ? 0 : _flush_token->get_stats().flush_running_count.load();
}

int64_t MemTableWriter::mem_consumption(MemType mem) {
if (!_is_init) {
// This method may be called before this writer is initialized.
Expand Down
2 changes: 2 additions & 0 deletions be/src/olap/memtable_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class MemTableWriter {

const FlushStatistic& get_flush_token_stats();

uint64_t flush_running_count() const;

private:
// push a full memtable to flush executor
Status _flush_memtable_async();
Expand Down

0 comments on commit c2eabbd

Please sign in to comment.