#15260·rocksdb

Secondary open/catch-up can fail if an obsolete SST disappears during MANIFEST replay with unique-ID verification disabled

Author: zhangsoledadCreated Sep 23, 2026Updated Sep 23, 2026

Summary

I use a Secondary DB for an external indexer while the primary continues to compact. On RocksDB 11.8.1, both DB::OpenAsSecondary() and TryCatchUpWithPrimary() can fail if an SST is present when MANIFEST replay verifies it, but the primary removes it before the Secondary opens its table reader. In my reproducer, the SST is already obsolete: the primary has compacted its contents into a newer, live SST.

This reproduces with max_open_files = -1 and verify_sst_unique_id_in_manifest = false. The latter is not the default; with its default value (true), both paths pass. I am reporting the narrower non-default configuration, not claiming that the default Secondary configuration has this failure.

Reproduction and result

I added two deterministic DBSecondaryTest cases on top of the unmodified v11.8.1 engine:

  1. Disable automatic compactions and primary file deletion. Write foo=old and flush to SST A; write foo=new and flush to SST B.
  2. Compact A and B into SST C. A and B are now obsolete, while C contains foo=new.
  3. Delete B before replay. Use VersionBuilder::Rep::LoadTableHandlers::BeforeFindTable to delete A immediately before its FindTable call. This makes A disappear after the earlier verification saw it.
  4. For the open case, call DB::OpenAsSecondary() after the primary writes. For the catch-up case, open an empty Secondary before the primary writes, then call TryCatchUpWithPrimary() after step 3. Both use max_open_files = -1, max_file_opening_threads = 1, and explicitly set verify_sst_unique_id_in_manifest to false or true for an A/B comparison.

Expected: MANIFEST replay can advance past the unavailable historical version and open the latest complete version; reading foo returns new.

Actual with verify_sst_unique_id_in_manifest = false: both DB::OpenAsSecondary() and TryCatchUpWithPrimary() return IOError(kPathNotFound):

IO error: No such file or directory: While open a file for random read: .../000013.sst: No such file or directory

On unmodified v11.8.1, each path failed 20/20 runs with false and passed 100/100 runs with true. I also removed the explicit assignment and reran the unmodified engine: each path passed another 100/100 runs with the native default. Every successful run read foo=new, and each test asserts that the deletion callback actually fired. This is a Secondary availability failure after primary compaction has completed; it does not demonstrate an incorrect read or primary data corruption.

Code path

max_open_files = -1 protects table readers after they have been opened; it cannot protect A during this replay window when unique-ID verification is disabled.

Related upstream work

I noticed the open PR #14815, which proposes a different initial Secondary recovery path. It may avoid the open-time case, but I have not run either reproducer against that PR. The catch-up case also needs consideration because it calls ManifestTailer. These tests would be useful regression coverage if that change is adopted.

Possible minimal fix

In the point-in-time handler, when a negative edge is saving a pre-edit candidate and LoadTableHandlers() returns PathNotFound/NotFound, treat that candidate as unavailable and continue replaying the subsequent MANIFEST edits, as the existing Corruption branch does. Keep unrelated I/O errors visible, and do not silently accept a missing SST in the final live version.

I tested that narrow condition locally with verify_sst_unique_id_in_manifest = false: both race tests, the existing MissingTableFileDuringOpen test, and a test injecting a generic table-open IOError each passed 20/20 runs. This is a possible small fix, not a request to weaken error handling generally. Pinning or linking the file during ManifestTailer::VerifyFile() may be a more comprehensive approach if that fits the intended contract better.

Separate default-configuration stale-read result (not the missing-SST race above)

I also checked a different Secondary failure on the unmodified v11.8.1 engine through ckb-rocksdb, without assigning verify_sst_unique_id_in_manifest (its native default is true):

  1. Primary writes key=v1 and calls FlushWAL(true); Secondary catches up and reads v1.
  2. Primary writes key=v2 and calls Flush(); the same Secondary's TryCatchUpWithPrimary() returns OK, but Get(key) still returns v1. A second successful catch-up also returns v1.
  3. A newly opened Secondary reads v2.

The same stale result occurs when the Secondary also sets max_open_files=-1. This reproduces the stale-memtable behavior reported separately in #14444 and #15051. The default verify_sst_unique_id_in_manifest=true does not guarantee fresh Secondary reads after a successful catch-up. Conversely, this result does not show that the default option fails the specific obsolete-SST PathNotFound race described in this issue; my 100/100 results for that narrower race still stand. The proposed PathNotFound handling above should not be read as a fix for stale memtables.