rocksdb/utilities/transactions
Xingbo Wang bcaf2794dc Fix TSAN data race in InjectedErrorLog by suppressing benign races (#14467)
Summary:
InjectedErrorLog is a lock-free circular ring buffer designed to be safe to call from signal handlers (which cannot use locks). It has an intentional benign data race between Record() (called by worker threads) and PrintAll() (called by the main thread from a signal/termination handler). The code documents this trade-off in comments, but was missing TSAN suppression annotations.

Simply adding TSAN_SUPPRESSION (__attribute__((no_sanitize("thread")))) is insufficient because TSAN still intercepts libc functions like vsnprintf/snprintf -- accesses through these interceptors are still tracked even when the calling function is annotated.

The fix:
1. Add TSAN_SUPPRESSION to both Record() and PrintAll() to suppress direct field reads/writes in the function body.
2. Restructure both functions to use local stack buffers for vsnprintf/snprintf operations instead of operating directly on shared entry data. This avoids passing shared memory through TSAN-intercepted libc functions.

Also adds fault_injection_fs_test with a ConcurrentRecordAndPrintAll test that exercises the concurrent Record() + PrintAll() pattern and verifies no TSAN race is reported.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/14467

Test Plan:
- fault_injection_fs_test passes under TSAN (buck2 test fbcode//mode/dbg-tsan)
- Reverted fix, re-ran: Fatal (6 TSAN warnings) -- round-trip confirmed
- fault_injection_fs_test passes under debug mode (no regression)

Reviewed By: mszeszko-meta

Differential Revision: D96948483

Pulled By: xingbowang

fbshipit-source-id: efdd5eafa12a5a82f973e40aa327901cc5f95033
2026-03-19 09:40:02 -07:00
..
lock Support Super Block Alignment (#13909) 2025-10-01 18:20:35 -07:00
optimistic_transaction.cc Standardize on clang-format version 18 (#13233) 2024-12-19 10:58:40 -08:00
optimistic_transaction.h Standardize on clang-format version 18 (#13233) 2024-12-19 10:58:40 -08:00
optimistic_transaction_db_impl.cc Remove deprecated DB::Open raw pointer variants (and more) (#14335) 2026-02-17 23:33:39 -08:00
optimistic_transaction_db_impl.h Remove deprecated DB::Open raw pointer variants (and more) (#14335) 2026-02-17 23:33:39 -08:00
optimistic_transaction_test.cc Add a new API Transaction::GetCoalescingIterator (#13128) 2024-11-08 14:14:39 -08:00
pessimistic_transaction.cc Improve efficiency in PointLockManager by using separate Condvar (#13731) 2025-09-08 15:52:54 -07:00
pessimistic_transaction.h Improve efficiency in PointLockManager by using separate Condvar (#13731) 2025-09-08 15:52:54 -07:00
pessimistic_transaction_db.cc Delete max_write_buffer_number_to_maintain (#13491) 2025-04-07 21:44:36 -07:00
pessimistic_transaction_db.h Make transaction name conflict check more robust (#12895) 2024-07-30 12:31:02 -07:00
snapshot_checker.cc Standardize on clang-format version 18 (#13233) 2024-12-19 10:58:40 -08:00
timestamped_snapshot_test.cc Improve efficiency in PointLockManager by using separate Condvar (#13731) 2025-09-08 15:52:54 -07:00
transaction_base.cc Add a new API Transaction::GetCoalescingIterator (#13128) 2024-11-08 14:14:39 -08:00
transaction_base.h Improve efficiency in PointLockManager by using separate Condvar (#13731) 2025-09-08 15:52:54 -07:00
transaction_db_mutex_impl.cc Improve efficiency in PointLockManager by using separate Condvar (#13731) 2025-09-08 15:52:54 -07:00
transaction_db_mutex_impl.h Standardize on clang-format version 18 (#13233) 2024-12-19 10:58:40 -08:00
transaction_test.cc Remove deprecated DB::Open raw pointer variants (and more) (#14335) 2026-02-17 23:33:39 -08:00
transaction_test.h Fix TSAN data race in InjectedErrorLog by suppressing benign races (#14467) 2026-03-19 09:40:02 -07:00
transaction_util.cc Standardize on clang-format version 18 (#13233) 2024-12-19 10:58:40 -08:00
transaction_util.h Standardize on clang-format version 18 (#13233) 2024-12-19 10:58:40 -08:00
write_committed_transaction_ts_test.cc Improve efficiency in PointLockManager by using separate Condvar (#13731) 2025-09-08 15:52:54 -07:00
write_prepared_transaction_seqno_test.cc Rename write_prepared_transaction_test_seqno to write_prepared_transaction_seqno_test (#14453) 2026-03-16 14:33:13 -07:00
write_prepared_transaction_test.cc Remove deprecated DB::Open raw pointer variants (and more) (#14335) 2026-02-17 23:33:39 -08:00
write_prepared_txn.cc Add a new API Transaction::GetCoalescingIterator (#13128) 2024-11-08 14:14:39 -08:00
write_prepared_txn.h Bug fix for bg error recovery in TransactionDB (#14313) 2026-02-17 14:52:00 -08:00
write_prepared_txn_db.cc Typo fix (#14024) 2025-10-03 14:28:37 -07:00
write_prepared_txn_db.h Properly disable MultiCFIterator in WritePrepared/UnPreparedTxnDBs (#12883) 2024-07-24 16:50:12 -07:00
write_unprepared_transaction_test.cc Improve efficiency in PointLockManager by using separate Condvar (#13731) 2025-09-08 15:52:54 -07:00
write_unprepared_txn.cc Refactor wal related naming and more (#13490) 2025-04-11 10:08:29 -07:00
write_unprepared_txn.h Standardize on clang-format version 18 (#13233) 2024-12-19 10:58:40 -08:00
write_unprepared_txn_db.cc Standardize on clang-format version 18 (#13233) 2024-12-19 10:58:40 -08:00
write_unprepared_txn_db.h Remove 'virtual' when implied by 'override' (#12319) 2024-01-31 13:14:42 -08:00