Fix IceDisk relation table data race - #957
Conversation
8321bf3 to
b33bc40
Compare
|
Read through this one since it is adjacent to what I have been poking at. The race fix looks right to me — the old code read Two things: 1. std::lock_guard lock(indptrDataMutex);
if (!indptrFilePath.empty() && indptrData.empty()) {
initializeIndptrReader(transaction);
if (!indptrReader) // <-- still indented for the removed block
return;Re-indenting the block by one level should make it green. 2. Worth a thought: the fast path now always takes the mutex. The double-checked pattern was If that shows up in a scan benchmark, the usual shapes that keep both correctness and a lock-free |
|
Reproduced the Removing the inner if (!indptrFilePath.empty() && indptrData.empty()) {
initializeIndptrReader(transaction);
- if (!indptrReader)
- return;
+ if (!indptrReader)
+ return;
- // Initialize scan to populate column types
- auto context = transaction->getClientContext();
+ // Initialize scan to populate column types
+ auto context = transaction->getClientContext();and so on to the closing brace. Easiest is to just let the tool do it: which is what CI runs via |
b33bc40 to
32990ad
Compare
Replace the unconditional mutex in loadIndptrData with correct double-checked locking via an atomic loaded flag, so steady-state scans skip the mutex entirely. initializeIndptrReader now takes the held indptrDataMutex as proof and DASSERTs ownership.
This fixes a TSan data race in
IceDiskRelTable.indptrDatais lazily initialized during parallel scans. The existing codechecked
indptrData.empty()before acquiringindptrDataMutex, so that readcould race with another thread filling the vector.
Changed
loadIndptrData()to acquire the existing mutex before checking orinitializing
indptrData.The full TSan suite previously reported 2 remaining races here and now reports 0.
Part of #879.