Skip to content

Commit

Permalink
WritePrepared: fix snapshot sequence in rollback (#4851)
Browse files Browse the repository at this point in the history
Summary:
The rollback algorithm in WritePrepared transactions requires reading the values before the transaction start. Currently it uses the prepare_seq -1 as the snapshot sequence number for the read. This is not correct since the passed sequence number must be for a valid snapshot. The patch fixes it by passing kMaxSequenceNumber instead. This is fine since all the writes done by the aborted transaction will be skipped during the read anyway.
Pull Request resolved: #4851

Differential Revision: D13592773

Pulled By: maysamyabandeh

fbshipit-source-id: ff1bf92ea9909d4cccb173bdff49febc0e9eb7a2
  • Loading branch information
Maysam Yabandeh authored and facebook-github-bot committed Jan 7, 2019
1 parent 4213552 commit 0ed98bf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions utilities/transactions/write_prepared_txn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ Status WritePreparedTxn::RollbackInternal() {
assert(GetId() > 0);
auto cf_map_shared_ptr = wpt_db_->GetCFHandleMap();
auto cf_comp_map_shared_ptr = wpt_db_->GetCFComparatorMap();
// In WritePrepared, the txn is is the same as prepare seq
auto last_visible_txn = GetId() - 1;
auto read_at_seq = kMaxSequenceNumber;
struct RollbackWriteBatchBuilder : public WriteBatch::Handler {
DBImpl* db_;
ReadOptions roptions;
Expand Down Expand Up @@ -308,7 +307,7 @@ Status WritePreparedTxn::RollbackInternal() {

protected:
virtual bool WriteAfterCommit() const override { return false; }
} rollback_handler(db_impl_, wpt_db_, last_visible_txn, &rollback_batch,
} rollback_handler(db_impl_, wpt_db_, read_at_seq, &rollback_batch,
*cf_comp_map_shared_ptr.get(), *cf_map_shared_ptr.get(),
wpt_db_->txn_db_options_.rollback_merge_operands);
auto s = GetWriteBatch()->GetWriteBatch()->Iterate(&rollback_handler);
Expand Down

0 comments on commit 0ed98bf

Please sign in to comment.