Remove redundant update of txn_state_ in transaction Prepare (#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: https://github.com/facebook/rocksdb/pull/6778

Test Plan: make check

Reviewed By: lth

Differential Revision: D21335319

Pulled By: cheng-chang

fbshipit-source-id: 251d634cc7d1a0e86e673a59f0bda8584da5a35f
This commit is contained in:
Cheng Chang 2020-05-01 17:35:41 -07:00 committed by Facebook GitHub Bot
parent c8643edfc3
commit 211088df6e

View File

@ -191,11 +191,11 @@ Status PessimisticTransaction::Prepare() {
AWAITING_PREPARE);
} else if (txn_state_ == STARTED) {
// expiration and lock stealing is not possible
txn_state_.store(AWAITING_PREPARE);
can_prepare = true;
}
if (can_prepare) {
txn_state_.store(AWAITING_PREPARE);
// transaction can't expire after preparation
expiration_time_ = 0;
assert(log_number_ == 0 ||