WritePrepared Txn: fix a bug in publishing recoverable state seq

Summary:
When using two_write_queue, the published seq and the last allocated sequence could be ahead of the LastSequence, even if both write queues are stopped as in WriteRecoverableState. The patch fixes a bug in WriteRecoverableState in which LastSequence was used as a reference but the result was applied to last fetched sequence and last published seq.
Closes https://github.com/facebook/rocksdb/pull/3665

Differential Revision: D7446099

Pulled By: maysamyabandeh

fbshipit-source-id: 1449bed9aed8e9db6af85946efd347cb8efd3c0b
main
Maysam Yabandeh 7 years ago committed by Facebook Github Bot
parent 3cb591954e
commit 89d989ed75
  1. 9
      db/db_impl_write.cc

@ -965,7 +965,12 @@ Status DBImpl::WriteRecoverableState() {
if (two_write_queues_) { if (two_write_queues_) {
log_write_mutex_.Lock(); log_write_mutex_.Lock();
} }
SequenceNumber seq = versions_->LastSequence(); SequenceNumber seq;
if (two_write_queues_) {
seq = versions_->FetchAddLastAllocatedSequence(0);
} else {
seq = versions_->LastSequence();
}
WriteBatchInternal::SetSequence(&cached_recoverable_state_, seq + 1); WriteBatchInternal::SetSequence(&cached_recoverable_state_, seq + 1);
auto status = WriteBatchInternal::InsertInto( auto status = WriteBatchInternal::InsertInto(
&cached_recoverable_state_, column_family_memtables_.get(), &cached_recoverable_state_, column_family_memtables_.get(),
@ -975,9 +980,9 @@ Status DBImpl::WriteRecoverableState() {
auto last_seq = next_seq - 1; auto last_seq = next_seq - 1;
if (two_write_queues_) { if (two_write_queues_) {
versions_->FetchAddLastAllocatedSequence(last_seq - seq); versions_->FetchAddLastAllocatedSequence(last_seq - seq);
versions_->SetLastPublishedSequence(last_seq);
} }
versions_->SetLastSequence(last_seq); versions_->SetLastSequence(last_seq);
versions_->SetLastPublishedSequence(last_seq);
if (two_write_queues_) { if (two_write_queues_) {
log_write_mutex_.Unlock(); log_write_mutex_.Unlock();
} }

Loading…
Cancel
Save