Repository navigation
Description
✅ I checked the Altinity Stable Builds lifecycle table, and the Altinity Stable Build version I'm using is still supported.
Type of problem
Bug report - something's broken
Describe the situation
CASDecommission.FenceLossOnAListPageStillRunsTheConfirm aborts Unit tests (tsan) with a ThreadSanitizer data race. The test body is not the failure. Decommission opens the admin pool, the lease renewer starts, and then the test clock is written into CasRequests::now_ms while that renewer is calling the same std::function.
This issue:
- Fails only the ThreadSanitizer unit-test job.
Unit tests (asan_ubsan)on the same commit passed, 0 failures of 15325. - Is a data race on
std::functionassignment versus invocation. ASan and release builds do not report it. SYSTEM CAS DROP POOL MEMBERdoes not pass a clock, so the racing assignment runs on the unit-test clock path.- Landed with the decommission clock install in CAS: decommission keeps a member's control objects; owner life and epoch nonce #2567 (
decommissionPoolMembersets the clock afterPool::openForDecommission).
@filimonov this is the clock install on the admin pool. @k-morozov the same MasterCI report is the one with the other CAS failures.
How to reproduce the behavior
Environment
- Version: 26.6.8.20003.altinityantalya
- Build type: ThreadSanitizer unit tests (
unit_tests_dbms) - Commit:
e6cbf5f4f147ccfc58858290826c7f97cf39c7f0
Steps
- Build
unit_tests_dbmswith ThreadSanitizer. - Run:
./unit_tests_dbms --gtest_filter='CASDecommission.FenceLossOnAListPageStillRunsTheConfirm'The overlap depends on scheduling. The test immediately before it, FenceDuringTheDrainKeepsTheTombstone, uses the same runOnClock helper and passed in this run. Repeat the filter if the first run stays quiet.
Expected behavior
The test throws from runOnClock, the fake backend records the list, and the owner stays a confirmed tombstone (owner_life == 2, retired, not verified). ThreadSanitizer stays silent.
Actual behavior
On release and ASan builds
No report. Unit tests (asan_ubsan) on this commit: fail 0, passed 15325.
On ThreadSanitizer
WARNING: ThreadSanitizer: data race
Read, thread CasLeaseRenewer, inside an in-flight renewal:
std::function<unsigned long ()>::operator()
DB::Cas::CasOperation::replace
src/Disks/DiskObjectStorage/MetadataStorages/ContentAddressed/Backend/CasRequests.cpp:1149
DB::Cas::MountLeaseRenewer::renewOn
src/Disks/DiskObjectStorage/MetadataStorages/ContentAddressed/Pool/CasServerRoot.cpp:1764
DB::Cas::CasMountRuntime::renewalLoop
src/Disks/DiskObjectStorage/MetadataStorages/ContentAddressed/Pool/CasMountRuntime.cpp:804
Previous write, main thread, installing the fake clock:
std::function<unsigned long ()>::operator=
DB::Cas::CasRequests::setNowFnForTest
src/Disks/DiskObjectStorage/MetadataStorages/ContentAddressed/Backend/CasRequests.cpp:318
DB::Cas::Pool::setCasRequestNowFnForTest
src/Disks/DiskObjectStorage/MetadataStorages/ContentAddressed/Pool/CasPool.cpp:2051
DB::Cas::decommissionPoolMember
CASDecommission::runOnClock
src/Disks/tests/gtest_cas_decommission.cpp:403
CASDecommission_FenceLossOnAListPageStillRunsTheConfirm_Test::TestBody
src/Disks/tests/gtest_cas_decommission.cpp:1900
Root cause analysis
decommissionPoolMember copies drain_now_fn into config.boot_ms_fn before Pool::openForDecommission. That open starts CasLeaseRenewer. After the open returns, the same function is assigned again:
PoolPtr admin = Pool::openForDecommission(...);
if (drain_now_fn && drain_sleep_fn)
admin->setCasRequestNowFnForTest(drain_now_fn);setNowFnForTest assigns CasRequests::now_ms. CasOperation::replace calls now_ms from the renewer with no lock around the std::function. Assignment and invocation of the same std::function are the race.
runOnClock documents that the closures must outlive the call because the renewer can outlive it. The renewer is already inside the call, invoking the function being replaced.
Install the request clock before startBackgroundWorkers, or publish it through a pointer the renewer loads atomically. Every runOnClock test shares this helper, so the same race can fire on another CASDecommission case when the renewer happens to be inside replace.
Additional context
CI failure
- Job: Unit tests (tsan)
- Branch:
v26.6.8.20003.altinityantalya - Commit:
e6cbf5f4f147ccfc58858290826c7f97cf39c7f0 - CI report: ci_run_report.html
- Logs: json.html
- Run: https://github.com/Altinity/ClickHouse/actions/runs/41911689821
Related PR
- PR CAS: decommission keeps a member's control objects; owner life and epoch nonce #2567: CAS member lifecycle. The latest edit of
gtest_cas_decommission.cppon this commit is "Keep the CAS decommission tombstone after a claim lost during the drain".
Activity
Initialize CAS callbacks before starting decommission workers