YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/tablet/remove_intents_task.cc
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#include "yb/tablet/remove_intents_task.h"
15
16
#include "yb/tablet/running_transaction.h"
17
#include "yb/tablet/transaction_participant_context.h"
18
#include "yb/util/logging.h"
19
20
namespace yb {
21
namespace tablet {
22
23
RemoveIntentsTask::RemoveIntentsTask(TransactionIntentApplier* applier,
24
                                     TransactionParticipantContext* participant_context,
25
                                     RunningTransactionContext* running_transaction_context,
26
                                     const TransactionId& id)
27
    : applier_(*applier), participant_context_(*participant_context),
28
968k
      running_transaction_context_(*running_transaction_context), id_(id) {}
29
30
968k
bool RemoveIntentsTask::Prepare(RunningTransactionPtr transaction) {
31
968k
  bool expected = false;
32
968k
  if (!used_.compare_exchange_strong(expected, true, std::memory_order_acq_rel)) {
33
0
    return false;
34
0
  }
35
36
968k
  transaction_ = std::move(transaction);
37
756
  LOG_IF_WITH_PREFIX(DFATAL, transaction_->ProcessingApply())
38
756
      << "Remove intents for transaction that is processing apply";
39
968k
  return true;
40
968k
}
41
42
968k
void RemoveIntentsTask::Run() {
43
24
  VLOG_WITH_PREFIX(2) << "Remove intents";
44
45
968k
  RemoveIntentsData data;
46
968k
  participant_context_.GetLastReplicatedData(&data);
47
968k
  auto status = applier_.RemoveIntents(data, id_);
48
239
  LOG_IF_WITH_PREFIX(WARNING, !status.ok())
49
239
      << "Failed to remove intents of aborted transaction : " << status;
50
283
  VLOG_WITH_PREFIX(2) << "Removed intents";
51
968k
}
52
53
968k
void RemoveIntentsTask::Done(const Status& status) {
54
968k
  if (!status.ok()) {
55
10
    YB_LOG_EVERY_N_SECS(WARNING, 1) << "Remove intents task failed: " << status;
56
10
  }
57
968k
  transaction_.reset();
58
968k
}
59
60
0
std::string RemoveIntentsTask::LogPrefix() const {
61
0
  return transaction_ ? transaction_->LogPrefix() : running_transaction_context_.LogPrefix();
62
0
}
63
64
} // namespace tablet
65
} // namespace yb