Retaining a writable RocksDB handle in RocksDBManager hangs a thread waiting for a ReadWrite open
Symptom#
test_view_duql_joins "a correlated sub-query ..." never ends. A thread sits in cv_.wait inside RocksDBManager::get_or_open (called from open_lookup_db, persist). Also a self-deadlock in reset()/shutdown() when a retained writer is dropped under mutex_.
Cause#
The no-entry wait predicate requires !writers_.contains(path). A retained writer keeps writers_ non-empty, so the waiter never wakes even after the opener published the handle. The writer's deleter also locks mutex_, so dropping a retained writer while holding mutex_ deadlocks.
Fix#
In the wait predicate also return true when databases_ has a live (non-expired) entry. Move dropped retained handles into a local Released vector declared before the lock so they are destroyed after unlock. Regression test: 8 std::async threads call open_lookup_db(ReadWrite) on one new path and must all get the same handle within 60 s.
Evidence#
Found with a temporary watchdog that sent SIGUSR1 to every thread (mach task_threads + pthread_kill) and printed backtrace; lldb and sample were not allowed. With the fix removed the new test times out; with it, test_lookup_store passes.