Skip to content

Commit 211088d

Browse files
Cheng Changfacebook-github-bot
Cheng Chang
authored andcommitted
Remove redundant update of txn_state_ in transaction Prepare (facebook#6778)
Summary: When expiration is set in a pessimistic transaction, `txn_state_` is already updated to `AWAITING_PREPARE` in the `if (expiration_time_ > 0)` block, there is no need to update the state in `if (can_prepare)` block again. Pull Request resolved: facebook#6778 Test Plan: make check Reviewed By: lth Differential Revision: D21335319 Pulled By: cheng-chang fbshipit-source-id: 251d634cc7d1a0e86e673a59f0bda8584da5a35f
1 parent c8643ed commit 211088d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

utilities/transactions/pessimistic_transaction.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ Status PessimisticTransaction::Prepare() {
191191
AWAITING_PREPARE);
192192
} else if (txn_state_ == STARTED) {
193193
// expiration and lock stealing is not possible
194+
txn_state_.store(AWAITING_PREPARE);
194195
can_prepare = true;
195196
}
196197

197198
if (can_prepare) {
198-
txn_state_.store(AWAITING_PREPARE);
199199
// transaction can't expire after preparation
200200
expiration_time_ = 0;
201201
assert(log_number_ == 0 ||

0 commit comments

Comments
 (0)