Sync MANIFEST before closing in db_impl when creating a new DB.
Add logging with debugging information when failing to load a version set. PiperOrigin-RevId: 351432332
This commit is contained in:
parent
8cce47e450
commit
8f1861462b
@ -196,6 +196,9 @@ Status DBImpl::NewDB() {
|
|||||||
std::string record;
|
std::string record;
|
||||||
new_db.EncodeTo(&record);
|
new_db.EncodeTo(&record);
|
||||||
s = log.AddRecord(record);
|
s = log.AddRecord(record);
|
||||||
|
if (s.ok()) {
|
||||||
|
s = file->Sync();
|
||||||
|
}
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
s = file->Close();
|
s = file->Close();
|
||||||
}
|
}
|
||||||
@ -301,6 +304,8 @@ Status DBImpl::Recover(VersionEdit* edit, bool* save_manifest) {
|
|||||||
|
|
||||||
if (!env_->FileExists(CurrentFileName(dbname_))) {
|
if (!env_->FileExists(CurrentFileName(dbname_))) {
|
||||||
if (options_.create_if_missing) {
|
if (options_.create_if_missing) {
|
||||||
|
Log(options_.info_log, "Creating DB %s since it was missing.",
|
||||||
|
dbname_.c_str());
|
||||||
s = NewDB();
|
s = NewDB();
|
||||||
if (!s.ok()) {
|
if (!s.ok()) {
|
||||||
return s;
|
return s;
|
||||||
|
@ -898,6 +898,7 @@ Status VersionSet::Recover(bool* save_manifest) {
|
|||||||
uint64_t log_number = 0;
|
uint64_t log_number = 0;
|
||||||
uint64_t prev_log_number = 0;
|
uint64_t prev_log_number = 0;
|
||||||
Builder builder(this, current_);
|
Builder builder(this, current_);
|
||||||
|
int read_records = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
LogReporter reporter;
|
LogReporter reporter;
|
||||||
@ -907,6 +908,7 @@ Status VersionSet::Recover(bool* save_manifest) {
|
|||||||
Slice record;
|
Slice record;
|
||||||
std::string scratch;
|
std::string scratch;
|
||||||
while (reader.ReadRecord(&record, &scratch) && s.ok()) {
|
while (reader.ReadRecord(&record, &scratch) && s.ok()) {
|
||||||
|
++read_records;
|
||||||
VersionEdit edit;
|
VersionEdit edit;
|
||||||
s = edit.DecodeFrom(record);
|
s = edit.DecodeFrom(record);
|
||||||
if (s.ok()) {
|
if (s.ok()) {
|
||||||
@ -981,6 +983,10 @@ Status VersionSet::Recover(bool* save_manifest) {
|
|||||||
} else {
|
} else {
|
||||||
*save_manifest = true;
|
*save_manifest = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
std::string error = s.ToString();
|
||||||
|
Log(options_->info_log, "Error recovering version set with %d records: %s",
|
||||||
|
read_records, error.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user