You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/05/15 17:08:20 UTC
[incubator-doris] 05/05: [Bug] (fix) DeltaWriter::mem_consumption() coredump (#9245)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 162b8492e1acc6413deb9ae4ed4095615b13f8e1
Author: chenlinzhong <49...@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 | 7 +++++++
be/src/runtime/tablets_channel.cpp | 8 ++++----
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/be/src/olap/delta_writer.cpp b/be/src/olap/delta_writer.cpp
index 9738f8f55b..8446340d5a 100644
--- a/be/src/olap/delta_writer.cpp
+++ b/be/src/olap/delta_writer.cpp
@@ -338,6 +338,15 @@ OLAPStatus DeltaWriter::cancel() {
return OLAP_SUCCESS;
}
+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 dbea5694a7..c765d03115 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, const std::shared_ptr<MemTracker>& parent,
StorageEngine* storage_engine);
@@ -121,6 +125,9 @@ private:
int64_t _segment_counter = 0;
std::mutex _lock;
+
+ //only used for std::sort more detail see issue(#9237)
+ int64_t _mem_consumption_snapshot = 0;
};
} // namespace doris
diff --git a/be/src/runtime/tablets_channel.cpp b/be/src/runtime/tablets_channel.cpp
index e8e2990267..75f9936e9b 100644
--- a/be/src/runtime/tablets_channel.cpp
+++ b/be/src/runtime/tablets_channel.cpp
@@ -216,12 +216,12 @@ 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();
- });
+ std::sort(writers.begin(), writers.end(), [](const DeltaWriter* lhs, const DeltaWriter* rhs) {
+ return lhs->get_mem_consumption_snapshot() > rhs->get_mem_consumption_snapshot();
+ });
// Decide which writes should be flushed to reduce mem consumption.
// The main idea is to flush at least one third of the mem_limit.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org