Hardcoding temp file name for Identity file to 000000.dbtmp just like it's done for CURRENT file

Summary: as per Dhruba's suggestion

Test Plan: make all check; Seen the Id getting generated properly in db_repl_stress

Reviewers: dhruba, kailiu

Reviewed By: dhruba

CC: leveldb

Differential Revision: https://reviews.facebook.net/D13635
main
Mayank Agarwal 11 years ago
parent b37fda842d
commit e56ce03691
  1. 5
      db/filename.cc

@ -92,7 +92,7 @@ std::string LockFileName(const std::string& dbname) {
} }
std::string TempFileName(const std::string& dbname, uint64_t number) { std::string TempFileName(const std::string& dbname, uint64_t number) {
assert(number > 0); assert(number >= 0);
return MakeFileName(dbname, number, "dbtmp"); return MakeFileName(dbname, number, "dbtmp");
} }
@ -234,7 +234,8 @@ Status SetCurrentFile(Env* env, const std::string& dbname,
Status SetIdentityFile(Env* env, const std::string& dbname) { Status SetIdentityFile(Env* env, const std::string& dbname) {
std::string id = env->GenerateUniqueId(); std::string id = env->GenerateUniqueId();
assert(!id.empty()); assert(!id.empty());
std::string tmp = TempFileName(dbname, id.size()); // Reserve the filename dbname/000000.dbtmp for the temporary identity file
std::string tmp = TempFileName(dbname, 0);
Status s = WriteStringToFileSync(env, id, tmp); Status s = WriteStringToFileSync(env, id, tmp);
if (s.ok()) { if (s.ok()) {
s = env->RenameFile(tmp, IdentityFileName(dbname)); s = env->RenameFile(tmp, IdentityFileName(dbname));

Loading…
Cancel
Save