Closed pdillinger closed 3 weeks ago
@pdillinger has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
Crash test failure is a known pre-existing (but undiagnosed) issue.
IIRC when releasing a handle, the cache can tell the caller if the reference was the last one; is this something we could leverage to mark table readers obsolete in a thread-safe manner?
I think there's a cart before the horse problem: ~BlockBasedTableReader is called by releasing the last reference in the table cache. At that point, we don't have the table reader to help us know what block cache entries to clear up. So because of that, and because destructors don't take parameters, our option is to forewarn the reader about the file being obsolete (about to be deleted) before the destructor is (or might be) called. And it's easier to make that forewarning thread safe than to ensure it happens just once. :)
@pdillinger merged this pull request in facebook/rocksdb@961468f92e210d9fa5e3b8ca7aef1d5b2c3d4b5c.
Summary: Data race reported on BlockBasedTableReader::Rep::uncache_aggressiveness because apparently a file can be marked obsolete through multiple table cache references in parallel. Using a relaxed atomic should resolve the race quite reasonably, especially considering this is a rare case and the racing writes should be storing the same value anyway.
Test Plan: watch for TSAN crash test results