diff --git a/unreleased_history/bug_fixes/do_not_add_unprep_seqs_when_write_impl_fails.md b/unreleased_history/bug_fixes/do_not_add_unprep_seqs_when_write_impl_fails.md new file mode 100644 index 0000000000..1b13ed013c --- /dev/null +++ b/unreleased_history/bug_fixes/do_not_add_unprep_seqs_when_write_impl_fails.md @@ -0,0 +1 @@ +Fixed a bug where we set unprep_seqs_ even when WriteImpl() fails. This was caught by stress test write fault injection in WriteImpl(). This may have incorrectly caused iteration creation failure for unvalidated writes or returned wrong result for WriteUnpreparedTxn::GetUnpreparedSequenceNumbers(). diff --git a/utilities/transactions/write_unprepared_txn.cc b/utilities/transactions/write_unprepared_txn.cc index e1fcd3f639..11caa17701 100644 --- a/utilities/transactions/write_unprepared_txn.cc +++ b/utilities/transactions/write_unprepared_txn.cc @@ -395,7 +395,9 @@ Status WriteUnpreparedTxn::FlushWriteBatchToDBInternal(bool prepared) { // unprep_seqs_ will also contain prepared seqnos since they are treated in // the same way in the prepare/commit callbacks. See the comment on the // definition of unprep_seqs_. - unprep_seqs_[prepare_seq] = prepare_batch_cnt_; + if (s.ok()) { + unprep_seqs_[prepare_seq] = prepare_batch_cnt_; + } // Reset transaction state. if (!prepared) {