summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorcostan <costan@google.com>2017-07-10 13:32:58 -0700
committerVictor Costan <pwnall@chromium.org>2017-07-10 14:14:00 -0700
commit8415f00eeedd96934d3578572d3802900e61a556 (patch)
tree494ea4cc69aa3cb652f975061e697374116eb595 /include
parent69e2bd224b7f11e021527cb95bab18f1ee6e1b3b (diff)
downloadleveldb-8415f00eeedd96934d3578572d3802900e61a556.tar.gz
leveldb: Report missing CURRENT manifest file as database corruption.
BTRFS reorders rename and write operations, so it is possible that a filesystem crash and recovery results in a situation where the file pointed to by CURRENT does not exist. DB::Open currently reports an I/O error in this case. Reporting database corruption is a better hint to the caller, which can attempt to recover the database or erase it and start over. This issue is not merely theoretical. It was reported as having showed up in the wild at https://github.com/google/leveldb/issues/195 and at https://crbug.com/738961. Also, asides from the BTRFS case described above, incorrect data in CURRENT seems like a possible corruption case that should be handled gracefully. The Env API changes here can be considered backwards compatible, because an implementation that returns Status::IOError instead of Status::NotFound will still get the same functionality as before. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=161432630
Diffstat (limited to 'include')
-rw-r--r--include/leveldb/env.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/leveldb/env.h b/include/leveldb/env.h
index 99b6c21..cb8b6a4 100644
--- a/include/leveldb/env.h
+++ b/include/leveldb/env.h
@@ -43,7 +43,8 @@ class Env {
// Create a brand new sequentially-readable file with the specified name.
// On success, stores a pointer to the new file in *result and returns OK.
// On failure stores NULL in *result and returns non-OK. If the file does
- // not exist, returns a non-OK status.
+ // not exist, returns a non-OK status. Implementations should return a
+ // NotFound status when the file does not exist.
//
// The returned file will only be accessed by one thread at a time.
virtual Status NewSequentialFile(const std::string& fname,
@@ -53,7 +54,8 @@ class Env {
// specified name. On success, stores a pointer to the new file in
// *result and returns OK. On failure stores NULL in *result and
// returns non-OK. If the file does not exist, returns a non-OK
- // status.
+ // status. Implementations should return a NotFound status when the file does
+ // not exist.
//
// The returned file may be concurrently accessed by multiple threads.
virtual Status NewRandomAccessFile(const std::string& fname,