Avoid logs_ operation out of DB mutex

Summary:
logs_.back() is called out of DB mutex, which can cause data race. We move the access into the DB mutex protection area.
Closes https://github.com/facebook/rocksdb/pull/1774

Reviewed By: AsyncDBConnMarkedDownDBException

Differential Revision: D4417472

Pulled By: AsyncDBConnMarkedDownDBException

fbshipit-source-id: 2da1f1e
main
sdong 8 years ago committed by Facebook Github Bot
parent a7b13919bf
commit 5dad9d6d28
  1. 3
      db/db_impl.cc

@ -4807,6 +4807,7 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options,
// and protects against concurrent loggers and concurrent writes
// into memtables
}
log::Writer* cur_log_writer = logs_.back().writer;
mutex_.Unlock();
@ -4894,7 +4895,7 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options,
WriteBatchInternal::SetSequence(merged_batch, current_sequence);
Slice log_entry = WriteBatchInternal::Contents(merged_batch);
status = logs_.back().writer->AddRecord(log_entry);
status = cur_log_writer->AddRecord(log_entry);
total_log_size_ += log_entry.size();
alive_log_files_.back().AddSize(log_entry.size());
log_empty_ = false;

Loading…
Cancel
Save