Improve error message when an SST file in MANIFEST is not found (#11573)

Summary:
I got the following error message when an SST file is recorded in MANIFEST but is missing from the db folder.
It's confusing in two ways:
1. The part about file "./074837.ldb" which RocksDB will attempt to open only after ./074837.sst is not found.
2. The last part about "No such file or directory in file ./MANIFEST-074507" sounds like `074837.ldb` is not found in manifest.

```
ldb --hex --db=. get some_key

Failed: Corruption: Corruption: IO error: No such file or directory: While open a file for random read: ./074837.ldb: No such file or directory in file ./MANIFEST-074507
```

Improving the error message a little bit:

Pull Request resolved: https://github.com/facebook/rocksdb/pull/11573

Test Plan:
run the same command after this PR
```
Failed: Corruption: Corruption: IO error: No such file or directory: While open a file for random read: ./074837.sst: No such file or directory  The file ./MANIFEST-074507 may be corrupted.
```

Reviewed By: ajkr

Differential Revision: D47192056

Pulled By: cbi42

fbshipit-source-id: 06863f376cc4455803cffb2250c41399b4c39467
oxigraph-main
Changyu Bi 1 year ago committed by Facebook GitHub Bot
parent 1a7c741977
commit 854eb76a8c
  1. 14
      db/table_cache.cc
  2. 3
      db/version_edit_handler.cc

@ -111,13 +111,17 @@ Status TableCache::GetTableReader(
RecordTick(ioptions_.stats, NO_FILE_OPENS); RecordTick(ioptions_.stats, NO_FILE_OPENS);
} else if (s.IsPathNotFound()) { } else if (s.IsPathNotFound()) {
fname = Rocks2LevelTableFileName(fname); fname = Rocks2LevelTableFileName(fname);
s = PrepareIOFromReadOptions(ro, ioptions_.clock, fopts.io_options); // If this file is also not found, we want to use the error message
if (s.ok()) { // that contains the table file name which is less confusing.
s = ioptions_.fs->NewRandomAccessFile(fname, file_options, &file, Status temp_s =
nullptr); PrepareIOFromReadOptions(ro, ioptions_.clock, fopts.io_options);
if (temp_s.ok()) {
temp_s = ioptions_.fs->NewRandomAccessFile(fname, file_options, &file,
nullptr);
} }
if (s.ok()) { if (temp_s.ok()) {
RecordTick(ioptions_.stats, NO_FILE_OPENS); RecordTick(ioptions_.stats, NO_FILE_OPENS);
s = temp_s;
} }
} }

@ -86,7 +86,8 @@ void VersionEditHandlerBase::Iterate(log::Reader& reader,
message << ' '; message << ' ';
} }
// append the filename to the corruption message // append the filename to the corruption message
message << "in file " << reader.file()->file_name(); message << " The file " << reader.file()->file_name()
<< " may be corrupted.";
// overwrite the status with the extended status // overwrite the status with the extended status
s = Status(s.code(), s.subcode(), s.severity(), message.str()); s = Status(s.code(), s.subcode(), s.severity(), message.str());
} }

Loading…
Cancel
Save