1
0
mirror of https://github.com/google/leveldb.git synced 2025-04-25 14:00:27 +08:00
This commit is contained in:
rockzheng 2025-03-10 15:15:19 +08:00 committed by GitHub
commit 77a6966e2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1233,18 +1233,17 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* updates) {
{
mutex_.Unlock();
status = log_->AddRecord(WriteBatchInternal::Contents(write_batch));
bool sync_error = false;
bool log_error = false;
if (status.ok() && options.sync) {
status = logfile_->Sync();
if (!status.ok()) {
sync_error = true;
}
}
if (status.ok()) {
status = WriteBatchInternal::InsertInto(write_batch, mem_);
} else {
log_error = true;
}
mutex_.Lock();
if (sync_error) {
if (log_error) {
// The state of the log file is indeterminate: the log record we
// just added may or may not show up when the DB is re-opened.
// So we force the DB into a mode where all future writes fail.