Ray's Knowledge Base
Unlock

TraceIndex::initialize deletes the whole index root on any exception while checking staleness

PitfallVerified 30 Sep 2026Holds project: dftracer-utils
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A valid index disappears after an ordinary open failure, such as RocksDB lock contention or a temporary I/O error.

Cause#

TraceIndex::initialize (trace_index.cpp:66-82) catches every exception from IndexDatabase db(root); db.find_stale_files(paths), sets stale = true, and calls fs::remove_all(root). IndexDatabase opens ReadWrite by default (index_database.h:25-28), and RocksDatabase::open throws when DB::Open fails (database.cpp:203-210). A failed open is therefore treated as a stale index.

Fix#

Not applied when this was found. Do not treat an open failure as staleness; only delete after find_stale_files returns a real stale result.

Evidence#

A review agent read the code of the PR 96 head (llnl-asr/dftracer-utils) and confirmed it. No run reproduced it.

Also found by searching

  • index directory deleted after RocksDB IO error: lock hold by current process
  • a valid trace index vanished after a failed open due to lock contention
  • why does TraceIndex initialize wipe the whole index root on an exception
  • find_stale_files throws, catch-all treats it as stale and fs::remove_all
  • my RocksDB index disappeared after a transient open error, whole index root deleted
  • TraceIndex::initialize remove_all(root) after lock contention exception
  • why does a failing IndexDatabase open make dftracer treat the index as stale and delete it?
  • find_stale_files throws RocksDB LOCK held, index wiped, catch (...) stale = true