diff --git a/README.md b/README.md index 9994c5fa23d..04ecbd6bff4 100644 --- a/README.md +++ b/README.md @@ -307,7 +307,9 @@ ninja gtests_libcommon There are known false positives reported from leak sanitizer (which is included in address sanitizer). To suppress these errors, set the following environment variables before running the executables: ```shell -LSAN_OPTIONS=suppressions=test/sanitize/asan.suppression +LSAN_OPTIONS="suppressions=tests/sanitize/asan.suppression" ./dbms/gtests_dbms ... +# or +TSAN_OPTIONS="suppressions=tests/sanitize/tsan.suppression" ./dbms/gtests_dbms ... ``` ## Run Integration Tests diff --git a/dbms/src/Storages/DeltaMerge/DeltaMergeStore.h b/dbms/src/Storages/DeltaMerge/DeltaMergeStore.h index f85758e390e..c547958ab79 100644 --- a/dbms/src/Storages/DeltaMerge/DeltaMergeStore.h +++ b/dbms/src/Storages/DeltaMerge/DeltaMergeStore.h @@ -505,7 +505,7 @@ class DeltaMergeStore : private boost::noncopyable * It is ensured that there are at least 2 elements in the returned vector. * When there is no mergeable segment, the returned vector will be empty. */ - std::vector getMergeableSegments(const DMContextPtr & context, const SegmentPtr & baseSegment); + std::vector getMergeableSegments(const DMContextPtr & context, const SegmentPtr & base_segment); /// Apply schema change on `table_columns` void applySchemaChanges(TableInfo & table_info); diff --git a/dbms/src/Storages/DeltaMerge/DeltaMergeStore_InternalBg.cpp b/dbms/src/Storages/DeltaMerge/DeltaMergeStore_InternalBg.cpp index 909a62e44f7..d570c9dda9e 100644 --- a/dbms/src/Storages/DeltaMerge/DeltaMergeStore_InternalBg.cpp +++ b/dbms/src/Storages/DeltaMerge/DeltaMergeStore_InternalBg.cpp @@ -312,10 +312,10 @@ void DeltaMergeStore::setUpBackgroundTask(const DMContextPtr & dm_context) std::vector DeltaMergeStore::getMergeableSegments( const DMContextPtr & context, - const SegmentPtr & baseSegment) + const SegmentPtr & base_segment) { // Last segment cannot be merged. - if (baseSegment->getRowKeyRange().isEndInfinite()) + if (base_segment->getRowKeyRange().isEndInfinite()) return {}; // We only merge small segments into a larger one. @@ -329,15 +329,15 @@ std::vector DeltaMergeStore::getMergeableSegments( { std::shared_lock lock(read_write_mutex); - if (!isSegmentValid(lock, baseSegment)) + if (!isSegmentValid(lock, base_segment)) return {}; results.reserve(4); // In most cases we will only find <= 4 segments to merge. - results.emplace_back(baseSegment); - auto accumulated_rows = baseSegment->getEstimatedRows(); - auto accumulated_bytes = baseSegment->getEstimatedBytes(); + results.emplace_back(base_segment); + auto accumulated_rows = base_segment->getEstimatedRows(); + auto accumulated_bytes = base_segment->getEstimatedBytes(); - auto it = segments.upper_bound(baseSegment->getRowKeyRange().getEnd()); + auto it = segments.upper_bound(base_segment->getRowKeyRange().getEnd()); while (it != segments.end()) { const auto & this_seg = it->second; @@ -345,6 +345,12 @@ std::vector DeltaMergeStore::getMergeableSegments( const auto this_bytes = this_seg->getEstimatedBytes(); if (accumulated_rows + this_rows >= max_total_rows || accumulated_bytes + this_bytes >= max_total_bytes) break; +#if defined(THREAD_SANITIZER) + // Limit the segments to be merged less than 30, or thread sanitizer will fail + // https://github.com/pingcap/tiflash/issues/9257 + if (results.size() > 30) + break; +#endif results.emplace_back(this_seg); accumulated_rows += this_rows; accumulated_bytes += this_bytes; diff --git a/tests/sanitize/tsan.suppression b/tests/sanitize/tsan.suppression index d50299328d7..e9e99557ce7 100644 --- a/tests/sanitize/tsan.suppression +++ b/tests/sanitize/tsan.suppression @@ -7,3 +7,4 @@ race:fiu_fail race:dbms/src/DataStreams/BlockStreamProfileInfo.h race:StackTrace::toString race:DB::SyncPointCtl::sync +race:XXH3_hashLong_64b_withSeed_selection