fix: enable TSAN and resolve detected data races#431
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables ThreadSanitizer (TSAN) coverage in CI and addresses the data races surfaced when running the full test suite under TSAN, while keeping the existing ASAN+UBSAN coverage intact.
Changes:
- Added a dedicated TSAN sanitizer job in CI and updated CI build invocations to use named arguments.
- Updated CMake sanitizer/toolchain configuration so bundled third-party dependencies can be built with TSAN instrumentation where applicable, and added TSAN suppressions for non-instrumented prebuilt shared libraries.
- Fixed concurrency issues in metrics snapshotting and test cache counters, and adjusted an integration test IO counter to be atomic.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/inte/read_inte_test.cpp | Makes the IO counter atomic to avoid TSAN-reported races in the integration test. |
| src/paimon/testing/utils/counting_cache_test_utils.h | Protects cache counter tracking with a mutex for thread-safe access in tests. |
| src/paimon/core/operation/metrics/compaction_metrics.h | Uses atomics for reporter fields to make concurrent metric updates/snapshots TSAN-safe. |
| src/paimon/core/operation/metrics/compaction_metrics_test.cpp | Adds a regression test covering concurrent reporter updates and metric snapshotting. |
| cmake_modules/ThirdpartyToolchain.cmake | Adjusts external-project flags to better support sanitizer builds and TSAN-instrumented dependencies (including Boost). |
| cmake_modules/san-config.cmake | Adds TSAN configuration and prevents enabling ASAN and TSAN simultaneously. |
| cmake_modules/BuildUtils.cmake | Skips -z defs when any sanitizer build is enabled (now including TSAN). |
| ci/scripts/build_paimon.sh | Switches to named CLI arguments; adds separate ASAN/UBSAN/TSAN switches and TSAN-specific Tantivy disablement. |
| build_support/tsan-suppressions.txt | Introduces TSAN suppressions for known non-instrumented prebuilt shared libraries. |
| .github/workflows/test_with_sanitizer.yaml | Adds a matrix to run ASAN+UBSAN and TSAN jobs (with Rust setup only where needed). |
| .github/workflows/gcc8_test.yaml | Updates build script invocation to new named-argument interface. |
| .github/workflows/gcc_test.yaml | Updates build script invocation to new named-argument interface. |
| .github/workflows/clang_test.yaml | Updates build script invocation to new named-argument interface (and preserves clang-tidy behavior). |
| .github/workflows/build_release.yaml | Updates build script invocation to new named-argument interface for Release builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lucasfang
approved these changes
Jul 20, 2026
lxy-9602
pushed a commit
to lxy-9602/paimon-cpp
that referenced
this pull request
Jul 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Linked issue: N/A
Enable ThreadSanitizer coverage, fix the data races exposed by the full test suite, and streamline the compiler and sanitizer CI workflows.
This change:
origin/main;Tests
ctest --test-dir build-pr-final --output-on-failure -j 64(27/27 passed).snappy_eptarget.pre-commit run --files <all changed files>.bash -n ci/scripts/build_paimon.sh.git diff upstream/main...HEAD --check.API and Format
No API, storage format, or protocol changes.
Documentation
No user-facing documentation changes.
Generative AI tooling
Generated-by: Codex (GPT-5)