Skip to content
Permalink
Browse files
[Bug] (fix) DeltaWriter::mem_consumption() coredump (#9245)
  • Loading branch information
chenlinzhong committed May 7, 2022
1 parent 882987c commit 53574ce0ea1a7e6c4103b741e3121eafb3f5e4db
Showing 3 changed files with 19 additions and 2 deletions.
@@ -367,6 +367,15 @@ Status DeltaWriter::cancel() {
return Status::OK();
}

int64_t DeltaWriter::save_mem_consumption_snapshot() {
_mem_consumption_snapshot = mem_consumption();
return _mem_consumption_snapshot;
}

int64_t DeltaWriter::get_mem_consumption_snapshot() const {
return _mem_consumption_snapshot;
}

int64_t DeltaWriter::mem_consumption() const {
if (_mem_tracker == nullptr) {
// This method may be called before this writer is initialized.
@@ -89,6 +89,10 @@ class DeltaWriter {

int64_t tablet_id() { return _tablet->tablet_id(); }

int64_t save_mem_consumption_snapshot();

int64_t get_mem_consumption_snapshot() const;

private:
DeltaWriter(WriteRequest* req, StorageEngine* storage_engine, bool is_vec);

@@ -122,6 +126,9 @@ class DeltaWriter {

// use in vectorized load
bool _is_vec;

//only used for std::sort more detail see issue(#9237)
int64_t _mem_consumption_snapshot = 0;
};

} // namespace doris
} // namespace doris
@@ -147,10 +147,11 @@ Status TabletsChannel::reduce_mem_usage(int64_t mem_limit) {
// Sort the DeltaWriters by mem consumption in descend order.
std::vector<DeltaWriter*> writers;
for (auto& it : _tablet_writers) {
it.second->save_mem_consumption_snapshot();
writers.push_back(it.second);
}
std::sort(writers.begin(), writers.end(), [](const DeltaWriter* lhs, const DeltaWriter* rhs) {
return lhs->mem_consumption() > rhs->mem_consumption();
return lhs->get_mem_consumption_snapshot() > rhs->get_mem_consumption_snapshot();
});

// Decide which writes should be flushed to reduce mem consumption.

0 comments on commit 53574ce

Please sign in to comment.