This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 090474a815d [branch-2.1](load) Lower lock granularity to reduce
loading CPU pressure (#40135)
090474a815d is described below
commit 090474a815d361261c4ca0465b47e450df38c5f9
Author: zclllhhjj <[email protected]>
AuthorDate: Thu Aug 29 23:22:58 2024 +0800
[branch-2.1](load) Lower lock granularity to reduce loading CPU pressure
(#40135)
pick https://github.com/apache/doris/pull/40134
---
be/src/runtime/tablets_channel.cpp | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/be/src/runtime/tablets_channel.cpp
b/be/src/runtime/tablets_channel.cpp
index 06bd73a3b20..db3d558a1b9 100644
--- a/be/src/runtime/tablets_channel.cpp
+++ b/be/src/runtime/tablets_channel.cpp
@@ -585,12 +585,15 @@ Status BaseTabletsChannel::add_batch(const
PTabletWriterAddBlockRequest& request
// add_batch may concurrency with inc_open but not under _lock.
// so need to protect it with _tablet_writers_lock.
- std::lock_guard<SpinLock> l(_tablet_writers_lock);
-
- auto tablet_writer_it = _tablet_writers.find(tablet_id);
- if (tablet_writer_it == _tablet_writers.end()) {
- return Status::InternalError("unknown tablet to append data,
tablet={}", tablet_id);
+ decltype(_tablet_writers.find(tablet_id)) tablet_writer_it;
+ {
+ std::lock_guard<SpinLock> l(_tablet_writers_lock);
+ tablet_writer_it = _tablet_writers.find(tablet_id);
+ if (tablet_writer_it == _tablet_writers.end()) {
+ return Status::InternalError("unknown tablet to append data,
tablet={}", tablet_id);
+ }
}
+
Status st = write_func(tablet_writer_it->second.get());
if (!st.ok()) {
auto err_msg =
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]