YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/tablet/operations/update_txn_operation.cc
Line
Count
Source (jump to first uncovered line)
1
//
2
// Copyright (c) YugaByte, Inc.
3
//
4
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
// in compliance with the License.  You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software distributed under the License
10
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
// or implied.  See the License for the specific language governing permissions and limitations
12
// under the License.
13
//
14
//
15
16
#include "yb/tablet/operations/update_txn_operation.h"
17
18
#include "yb/consensus/consensus.pb.h"
19
20
#include "yb/tablet/tablet.h"
21
#include "yb/tablet/transaction_coordinator.h"
22
#include "yb/tablet/transaction_participant.h"
23
24
#include "yb/util/logging.h"
25
26
using namespace std::literals;
27
28
namespace yb {
29
namespace tablet {
30
31
template <>
32
void RequestTraits<TransactionStatePB>::SetAllocatedRequest(
33
406k
    consensus::ReplicateMsg* replicate, TransactionStatePB* request) {
34
406k
  replicate->set_allocated_transaction_state(request);
35
406k
}
36
37
template <>
38
TransactionStatePB* RequestTraits<TransactionStatePB>::MutableRequest(
39
5.59M
    consensus::ReplicateMsg* replicate) {
40
5.59M
  return replicate->mutable_transaction_state();
41
5.59M
}
42
43
4.49M
Status UpdateTxnOperation::Prepare() {
44
4.49M
  
VLOG_WITH_PREFIX376
(2) << "Prepare"376
;
45
4.49M
  return Status::OK();
46
4.49M
}
47
48
3.18M
TransactionCoordinator& UpdateTxnOperation::transaction_coordinator() const {
49
3.18M
  return *tablet()->transaction_coordinator();
50
3.18M
}
51
52
4.49M
Status UpdateTxnOperation::DoReplicated(int64_t leader_term, Status* complete_status) {
53
4.49M
  
VLOG_WITH_PREFIX1.76k
(2) << "Replicated"1.76k
;
54
55
4.49M
  auto transaction_participant = tablet()->transaction_participant();
56
4.49M
  if (transaction_participant) {
57
1.30M
    TransactionParticipant::ReplicatedData data = {
58
1.30M
        .leader_term = leader_term,
59
1.30M
        .state = *request(),
60
1.30M
        .op_id = op_id(),
61
1.30M
        .hybrid_time = hybrid_time(),
62
1.30M
        .sealed = request()->sealed(),
63
1.30M
        .already_applied_to_regular_db = AlreadyAppliedToRegularDB::kFalse
64
1.30M
    };
65
1.30M
    return transaction_participant->ProcessReplicated(data);
66
3.18M
  } else {
67
3.18M
    TransactionCoordinator::ReplicatedData data = {
68
3.18M
        leader_term,
69
3.18M
        *request(),
70
3.18M
        op_id(),
71
3.18M
        hybrid_time()
72
3.18M
    };
73
3.18M
    return transaction_coordinator().ProcessReplicated(data);
74
3.18M
  }
75
4.49M
}
76
77
52
Status UpdateTxnOperation::DoAborted(const Status& status) {
78
52
  if (tablet()->transaction_coordinator()) {
79
0
    LOG_WITH_PREFIX(INFO) << "Aborted: " << status;
80
0
    TransactionCoordinator::AbortedData data = {
81
0
      .state = *request(),
82
0
      .op_id = op_id(),
83
0
    };
84
0
    transaction_coordinator().ProcessAborted(data);
85
0
  }
86
87
52
  return status;
88
52
}
89
90
} // namespace tablet
91
} // namespace yb