Enhancements to rocksdb for better support for replication.

Summary:
1. The OpenForReadOnly() call should not lock the db. This is useful
so that multiple processes can open the same database concurrently
for reading.
2. GetUpdatesSince should not error out if the archive directory
does not exist.
3. A new constructor for WriteBatch that can takes a serialized
string as a parameter of the constructor.

Test Plan: make clean check

Reviewers: sheki

Reviewed By: sheki

CC: leveldb

Differential Revision: https://reviews.facebook.net/D7449
main
Dhruba Borthakur 12 years ago
parent 62d48571de
commit 3d1e92b05a
  1. 7
      .arcconfig
  2. 11
      db/db_impl.cc
  3. 5
      include/leveldb/write_batch.h

@ -1,10 +1,5 @@
{ {
"project_id" : "leveldb", "project_id" : "leveldb",
"conduit_uri" : "https://reviews.facebook.net/", "conduit_uri" : "https://reviews.facebook.net/",
"copyright_holder" : "", "copyright_holder" : ""
"load" : [
"linters/src/"
],
"lint_engine" : "FacebookFbcodeLintEngine",
"lint.engine.single.linter" : "FbcodeCppLinter"
} }

@ -512,8 +512,9 @@ Status DBImpl::Recover(VersionEdit* edit, bool no_log_recory,
// Ignore error from CreateDir since the creation of the DB is // Ignore error from CreateDir since the creation of the DB is
// committed only when the descriptor is created, and this directory // committed only when the descriptor is created, and this directory
// may already exist from a previous failed creation attempt. // may already exist from a previous failed creation attempt.
env_->CreateDir(dbname_);
assert(db_lock_ == NULL); assert(db_lock_ == NULL);
if (!no_log_recory) {
env_->CreateDir(dbname_);
Status s = env_->LockFile(LockFileName(dbname_), &db_lock_); Status s = env_->LockFile(LockFileName(dbname_), &db_lock_);
if (!s.ok()) { if (!s.ok()) {
return s; return s;
@ -535,8 +536,9 @@ Status DBImpl::Recover(VersionEdit* edit, bool no_log_recory,
dbname_, "exists (error_if_exists is true)"); dbname_, "exists (error_if_exists is true)");
} }
} }
}
s = versions_->Recover(); Status s = versions_->Recover();
if (s.ok()) { if (s.ok()) {
SequenceNumber max_sequence(0); SequenceNumber max_sequence(0);
@ -897,10 +899,13 @@ Status DBImpl::GetUpdatesSince(SequenceNumber seq,
return s; return s;
} }
// list wal files in archive dir. // list wal files in archive dir.
s = ListAllWALFiles(ArchivalDirectory(dbname_), &walFiles, kArchivedLogFile); std::string archivedir = ArchivalDirectory(dbname_);
if (env_->FileExists(archivedir)) {
s = ListAllWALFiles(archivedir, &walFiles, kArchivedLogFile);
if (!s.ok()) { if (!s.ok()) {
return s; return s;
} }
}
if (walFiles.empty()) { if (walFiles.empty()) {
return Status::IOError(" NO WAL Files present in the db"); return Status::IOError(" NO WAL Files present in the db");

@ -51,9 +51,12 @@ class WriteBatch {
}; };
Status Iterate(Handler* handler) const; Status Iterate(Handler* handler) const;
// Returns the serialized string // Retrive the serialized version of this batch.
std::string Data() { return rep_; } std::string Data() { return rep_; }
// Constructor with a serialized string object
WriteBatch(std::string rep): rep_(rep) {}
private: private:
friend class WriteBatchInternal; friend class WriteBatchInternal;

Loading…
Cancel
Save