diff --git a/src/yb/tablet/tablet_peer.cc b/src/yb/tablet/tablet_peer.cc index 578ca0f54e5e..a9094665d0a8 100644 --- a/src/yb/tablet/tablet_peer.cc +++ b/src/yb/tablet/tablet_peer.cc @@ -720,7 +720,7 @@ void TabletPeer::Submit(std::unique_ptr operation, int64_t term) { } Status TabletPeer::SubmitUpdateTransaction( - std::unique_ptr operation, int64_t term) { + std::unique_ptr& operation, int64_t term) { if (!operation->tablet_is_set()) { auto tablet = VERIFY_RESULT(shared_tablet_safe()); operation->SetTablet(tablet); diff --git a/src/yb/tablet/tablet_peer.h b/src/yb/tablet/tablet_peer.h index 85cab240e0d9..ae8d15404973 100644 --- a/src/yb/tablet/tablet_peer.h +++ b/src/yb/tablet/tablet_peer.h @@ -220,8 +220,9 @@ class TabletPeer : public std::enable_shared_from_this, std::unique_ptr CreateUpdateTransaction( std::shared_ptr request) override; + // `operation` is moved from in the event of success, and left alive in event of failure. Status SubmitUpdateTransaction( - std::unique_ptr operation, int64_t term) override; + std::unique_ptr& operation, int64_t term) override; HybridTime SafeTimeForTransactionParticipant() override; Result WaitForSafeTime(HybridTime safe_time, CoarseTimePoint deadline) override; diff --git a/src/yb/tablet/transaction_coordinator.cc b/src/yb/tablet/transaction_coordinator.cc index 0acca36ffb2d..3582f52c9d0b 100644 --- a/src/yb/tablet/transaction_coordinator.cc +++ b/src/yb/tablet/transaction_coordinator.cc @@ -1730,7 +1730,7 @@ class TransactionCoordinator::Impl : public TransactionStateContext, for (auto& update : actions->updates) { auto submit_status = - context_.SubmitUpdateTransaction(std::move(update), actions->leader_term); + context_.SubmitUpdateTransaction(update, actions->leader_term); if (!submit_status.ok()) { LOG_WITH_PREFIX(DFATAL) << "Could not submit transaction status update operation: " diff --git a/src/yb/tablet/transaction_coordinator.h b/src/yb/tablet/transaction_coordinator.h index cedb935524ba..3406c937f262 100644 --- a/src/yb/tablet/transaction_coordinator.h +++ b/src/yb/tablet/transaction_coordinator.h @@ -69,7 +69,7 @@ class TransactionCoordinatorContext { virtual std::unique_ptr CreateUpdateTransaction( std::shared_ptr request) = 0; virtual Status SubmitUpdateTransaction( - std::unique_ptr operation, int64_t term) = 0; + std::unique_ptr& operation, int64_t term) = 0; server::Clock& clock() const { return *clock_ptr(); diff --git a/src/yb/tablet/transaction_participant.cc b/src/yb/tablet/transaction_participant.cc index a62282b5ea6e..6a7c5505e57d 100644 --- a/src/yb/tablet/transaction_participant.cc +++ b/src/yb/tablet/transaction_participant.cc @@ -1882,7 +1882,7 @@ class TransactionParticipant::Impl void SubmitUpdateTransaction( std::unique_ptr operation, int64_t term) { WARN_NOT_OK( - participant_context_.SubmitUpdateTransaction(std::move(operation), term), + participant_context_.SubmitUpdateTransaction(operation, term), Format("Could not submit transaction status update operation: $0", operation->ToString())); } diff --git a/src/yb/tablet/transaction_participant_context.h b/src/yb/tablet/transaction_participant_context.h index ca3d130bb06e..546c54899874 100644 --- a/src/yb/tablet/transaction_participant_context.h +++ b/src/yb/tablet/transaction_participant_context.h @@ -43,7 +43,7 @@ class TransactionParticipantContext { virtual void UpdateClock(HybridTime hybrid_time) = 0; virtual bool IsLeader() = 0; virtual Status SubmitUpdateTransaction( - std::unique_ptr state, int64_t term) = 0; + std::unique_ptr& state, int64_t term) = 0; // Returns hybrid time that lower than any future transaction apply record. virtual HybridTime SafeTimeForTransactionParticipant() = 0;