Fix LogAndApply() group commit

This commit is contained in:
Igor Canadi 2014-02-28 12:22:45 -08:00
parent f6a257b6a1
commit 12966ec1bb

View File

@ -1580,9 +1580,9 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
// Write new record to MANIFEST log // Write new record to MANIFEST log
if (s.ok()) { if (s.ok()) {
std::string record; for (auto& e : batch_edits) {
for (unsigned int i = 0; i < batch_edits.size(); i++) { std::string record;
batch_edits[i]->EncodeTo(&record); e->EncodeTo(&record);
s = descriptor_log_->AddRecord(record); s = descriptor_log_->AddRecord(record);
if (!s.ok()) { if (!s.ok()) {
break; break;
@ -1601,7 +1601,16 @@ Status VersionSet::LogAndApply(ColumnFamilyData* column_family_data,
} }
if (!s.ok()) { if (!s.ok()) {
Log(options_->info_log, "MANIFEST write: %s\n", s.ToString().c_str()); Log(options_->info_log, "MANIFEST write: %s\n", s.ToString().c_str());
if (ManifestContains(record)) { bool all_records_in = true;
for (auto& e : batch_edits) {
std::string record;
e->EncodeTo(&record);
if (!ManifestContains(record)) {
all_records_in = false;
break;
}
}
if (all_records_in) {
Log(options_->info_log, Log(options_->info_log,
"MANIFEST contains log record despite error; advancing to new " "MANIFEST contains log record despite error; advancing to new "
"version to prevent mismatch between in-memory and logged state" "version to prevent mismatch between in-memory and logged state"