This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push: new 53574ce0ea [Bug] (fix) DeltaWriter::mem_consumption() coredump (#9245) 53574ce0ea is described below commit 53574ce0ea1a7e6c4103b741e3121eafb3f5e4db Author: chenlinzhong <490103...@qq.com> AuthorDate: Sat May 7 19:13:08 2022 +0800 [Bug] (fix) DeltaWriter::mem_consumption() coredump (#9245) --- be/src/olap/delta_writer.cpp | 9 +++++++++ be/src/olap/delta_writer.h | 9 ++++++++- be/src/runtime/tablets_channel.cpp | 3 ++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/be/src/olap/delta_writer.cpp b/be/src/olap/delta_writer.cpp index efd9d06212..1890efd0e9 100644 --- a/be/src/olap/delta_writer.cpp +++ b/be/src/olap/delta_writer.cpp @@ -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. diff --git a/be/src/olap/delta_writer.h b/be/src/olap/delta_writer.h index e095fff132..6e4ef8fdb6 100644 --- a/be/src/olap/delta_writer.h +++ b/be/src/olap/delta_writer.h @@ -89,6 +89,10 @@ public: 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 @@ private: // 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 \ No newline at end of file diff --git a/be/src/runtime/tablets_channel.cpp b/be/src/runtime/tablets_channel.cpp index d74b03342a..72999fe3af 100644 --- a/be/src/runtime/tablets_channel.cpp +++ b/be/src/runtime/tablets_channel.cpp @@ -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. --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org