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 7aff10b93ba [Fix](inverted index) fix race condition for column reader
load inverted index reader (#34922) (#35040)
7aff10b93ba is described below
commit 7aff10b93bad45b7a8e191be130a25c1d96f0b6e
Author: airborne12 <[email protected]>
AuthorDate: Mon May 20 09:52:22 2024 +0800
[Fix](inverted index) fix race condition for column reader load inverted
index reader (#34922) (#35040)
---
be/src/olap/rowset/segment_v2/column_reader.cpp | 11 +++++++----
be/src/olap/rowset/segment_v2/column_reader.h | 2 +-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/be/src/olap/rowset/segment_v2/column_reader.cpp
b/be/src/olap/rowset/segment_v2/column_reader.cpp
index 9d19d1a64b4..6d5c28b8d6d 100644
--- a/be/src/olap/rowset/segment_v2/column_reader.cpp
+++ b/be/src/olap/rowset/segment_v2/column_reader.cpp
@@ -262,9 +262,12 @@ Status ColumnReader::new_inverted_index_iterator(
std::shared_ptr<InvertedIndexFileReader> index_file_reader, const
TabletIndex* index_meta,
const StorageReadOptions& read_options,
std::unique_ptr<InvertedIndexIterator>* iterator) {
RETURN_IF_ERROR(_ensure_inverted_index_loaded(index_file_reader,
index_meta));
- if (_inverted_index) {
- RETURN_IF_ERROR(_inverted_index->new_iterator(read_options.stats,
-
read_options.runtime_state, iterator));
+ {
+ std::shared_lock<std::shared_mutex> rlock(_load_index_lock);
+ if (_inverted_index) {
+ RETURN_IF_ERROR(_inverted_index->new_iterator(read_options.stats,
+
read_options.runtime_state, iterator));
+ }
}
return Status::OK();
}
@@ -536,7 +539,7 @@ Status ColumnReader::_load_bitmap_index(bool
use_page_cache, bool kept_in_memory
Status ColumnReader::_load_inverted_index_index(
std::shared_ptr<InvertedIndexFileReader> index_file_reader, const
TabletIndex* index_meta) {
- std::lock_guard<std::mutex> wlock(_load_index_lock);
+ std::unique_lock<std::shared_mutex> wlock(_load_index_lock);
if (_inverted_index && index_meta &&
_inverted_index->get_index_id() == index_meta->index_id()) {
diff --git a/be/src/olap/rowset/segment_v2/column_reader.h
b/be/src/olap/rowset/segment_v2/column_reader.h
index 9c889b848fd..30f916d00cd 100644
--- a/be/src/olap/rowset/segment_v2/column_reader.h
+++ b/be/src/olap/rowset/segment_v2/column_reader.h
@@ -249,7 +249,7 @@ private:
// meta for various column indexes (null if the index is absent)
std::unique_ptr<ZoneMapPB> _segment_zone_map;
- mutable std::mutex _load_index_lock;
+ mutable std::shared_mutex _load_index_lock;
std::unique_ptr<ZoneMapIndexReader> _zone_map_index;
std::unique_ptr<OrdinalIndexReader> _ordinal_index;
std::unique_ptr<BitmapIndexReader> _bitmap_index;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]