From 211088df6e997d2d73ceba4395f570df5f856737 Mon Sep 17 00:00:00 2001 From: Cheng Chang Date: Fri, 1 May 2020 17:35:41 -0700 Subject: [PATCH] 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 --- utilities/transactions/pessimistic_transaction.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/transactions/pessimistic_transaction.cc b/utilities/transactions/pessimistic_transaction.cc index a33e5df51..d9851f4cd 100644 --- a/utilities/transactions/pessimistic_transaction.cc +++ b/utilities/transactions/pessimistic_transaction.cc @@ -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 ||