You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by kx...@apache.org on 2023/10/08 14:36:07 UTC
[doris] branch branch-2.0 updated: [branch-2.0-pick][Enhancement](Status) use Status to expose the error info more explicitly in FlushToken #24240 (#25062)
This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 37939a8c547 [branch-2.0-pick][Enhancement](Status) use Status to expose the error info more explicitly in FlushToken #24240 (#25062)
37939a8c547 is described below
commit 37939a8c547d61090d56c1e2d352a757b7e85cf4
Author: bobhan1 <bh...@outlook.com>
AuthorDate: Sun Oct 8 22:36:01 2023 +0800
[branch-2.0-pick][Enhancement](Status) use Status to expose the error info more explicitly in FlushToken #24240 (#25062)
---
be/src/olap/memtable_flush_executor.cpp | 40 +++++++++++++++++++++++----------
be/src/olap/memtable_flush_executor.h | 5 +++--
2 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/be/src/olap/memtable_flush_executor.cpp b/be/src/olap/memtable_flush_executor.cpp
index 36273c8fc35..57c2efb5294 100644
--- a/be/src/olap/memtable_flush_executor.cpp
+++ b/be/src/olap/memtable_flush_executor.cpp
@@ -64,9 +64,11 @@ std::ostream& operator<<(std::ostream& os, const FlushStatistic& stat) {
}
Status FlushToken::submit(std::unique_ptr<MemTable> mem_table) {
- auto s = _flush_status.load();
- if (s != OK) {
- return Status::Error(s, "FlushToken meet error");
+ {
+ std::shared_lock rdlk(_flush_status_lock);
+ if (!_flush_status.ok()) {
+ return _flush_status;
+ }
}
int64_t submit_task_time = MonotonicNanos();
auto task = std::make_shared<MemtableFlushTask>(this, std::move(mem_table), submit_task_time);
@@ -80,28 +82,42 @@ void FlushToken::cancel() {
Status FlushToken::wait() {
_flush_token->wait();
- auto s = _flush_status.load();
- return s == OK ? Status::OK() : Status::Error(s, "FlushToken meet error");
+ {
+ std::shared_lock rdlk(_flush_status_lock);
+ if (!_flush_status.ok()) {
+ return _flush_status;
+ }
+ }
+ return Status::OK();
}
void FlushToken::_flush_memtable(MemTable* memtable, int64_t submit_task_time) {
uint64_t flush_wait_time_ns = MonotonicNanos() - submit_task_time;
_stats.flush_wait_time_ns += flush_wait_time_ns;
// If previous flush has failed, return directly
- if (_flush_status.load() != OK) {
- return;
+ {
+ std::shared_lock rdlk(_flush_status_lock);
+ if (!_flush_status.ok()) {
+ return;
+ }
}
MonotonicStopWatch timer;
timer.start();
size_t memory_usage = memtable->memory_usage();
Status s = memtable->flush();
- if (!s) {
- LOG(WARNING) << "Flush memtable failed with res = " << s;
- // If s is not ok, ignore the code, just use other code is ok
- _flush_status.store(s.code());
+
+ {
+ std::shared_lock rdlk(_flush_status_lock);
+ if (!_flush_status.ok()) {
+ return;
+ }
}
- if (_flush_status.load() != OK) {
+
+ if (!s.ok()) {
+ std::lock_guard wrlk(_flush_status_lock);
+ LOG(WARNING) << "Flush memtable failed with res = " << s;
+ _flush_status = s;
return;
}
diff --git a/be/src/olap/memtable_flush_executor.h b/be/src/olap/memtable_flush_executor.h
index 7608fa4d197..181b63de729 100644
--- a/be/src/olap/memtable_flush_executor.h
+++ b/be/src/olap/memtable_flush_executor.h
@@ -57,7 +57,7 @@ std::ostream& operator<<(std::ostream& os, const FlushStatistic& stat);
class FlushToken {
public:
explicit FlushToken(std::unique_ptr<ThreadPoolToken> flush_pool_token)
- : _flush_token(std::move(flush_pool_token)), _flush_status(ErrorCode::OK) {}
+ : _flush_token(std::move(flush_pool_token)), _flush_status(Status::OK()) {}
Status submit(std::unique_ptr<MemTable> mem_table);
@@ -80,7 +80,8 @@ private:
// Records the current flush status of the tablet.
// Note: Once its value is set to Failed, it cannot return to SUCCESS.
- std::atomic<int> _flush_status;
+ std::shared_mutex _flush_status_lock;
+ Status _flush_status;
FlushStatistic _stats;
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org