|
@@ -1183,29 +1183,33 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
|
|
|
WriteBatchInternal::SetSequence(updates, last_sequence + 1);
|
|
|
last_sequence += WriteBatchInternal::Count(updates);
|
|
|
|
|
|
- // Add to log and apply to memtable. We can release the lock
|
|
|
- // during this phase since &w is currently responsible for logging
|
|
|
- // and protects against concurrent loggers and concurrent writes
|
|
|
- // into mem_.
|
|
|
- {
|
|
|
- mutex_.Unlock();
|
|
|
- status = log_->AddRecord(WriteBatchInternal::Contents(updates));
|
|
|
- bool sync_error = false;
|
|
|
- if (status.ok() && options.sync) {
|
|
|
- status = logfile_->Sync();
|
|
|
- if (!status.ok()) {
|
|
|
- sync_error = true;
|
|
|
+ if (options.skip_wal) {
|
|
|
+ status = WriteBatchInternal::InsertInto(updates, mem_);
|
|
|
+ } else {
|
|
|
+ // Add to log and apply to memtable. We can release the lock
|
|
|
+ // during this phase since &w is currently responsible for logging
|
|
|
+ // and protects against concurrent loggers and concurrent writes
|
|
|
+ // into mem_.
|
|
|
+ {
|
|
|
+ mutex_.Unlock();
|
|
|
+ status = log_->AddRecord(WriteBatchInternal::Contents(updates));
|
|
|
+ bool sync_error = false;
|
|
|
+ if (status.ok() && options.sync) {
|
|
|
+ status = logfile_->Sync();
|
|
|
+ if (!status.ok()) {
|
|
|
+ sync_error = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (status.ok()) {
|
|
|
+ status = WriteBatchInternal::InsertInto(updates, mem_);
|
|
|
+ }
|
|
|
+ mutex_.Lock();
|
|
|
+ if (sync_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.
|
|
|
+ RecordBackgroundError(status);
|
|
|
}
|
|
|
- }
|
|
|
- if (status.ok()) {
|
|
|
- status = WriteBatchInternal::InsertInto(updates, mem_);
|
|
|
- }
|
|
|
- mutex_.Lock();
|
|
|
- if (sync_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.
|
|
|
- RecordBackgroundError(status);
|
|
|
}
|
|
|
}
|
|
|
if (updates == tmp_batch_) tmp_batch_->Clear();
|