YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/tablet/cleanup_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/cleanup_intents_task.h"
15
16
#include "yb/tablet/transaction_intent_applier.h"
17
#include "yb/tablet/transaction_participant.h"
18
#include "yb/tablet/transaction_participant_context.h"
19
20
#include "yb/util/status_log.h"
21
22
namespace yb {
23
namespace tablet {
24
25
CleanupIntentsTask::CleanupIntentsTask(
26
    TransactionParticipantContext* participant_context, TransactionIntentApplier* applier,
27
    const TransactionId& id)
28
0
    : participant_context_(*participant_context), applier_(*applier), id_(id) {}
29
30
0
void CleanupIntentsTask::Prepare(std::shared_ptr<CleanupIntentsTask> self) {
31
0
  retain_self_ = std::move(self);
32
0
}
33
34
0
void CleanupIntentsTask::Run() {
35
0
  RemoveIntentsData data;
36
0
  auto status = participant_context_.GetLastReplicatedData(&data);
37
0
  if (status.ok()) {
38
0
    status = applier_.RemoveIntents(data, id_);
39
0
  }
40
0
  WARN_NOT_OK(status,
41
0
              Format("Failed to remove intents of possible completed transaction $0", id_));
42
0
  VLOG(2) << "Cleaned intents for: " << id_;
43
0
}
44
45
0
void CleanupIntentsTask::Done(const Status& status) {
46
0
  retain_self_.reset();
47
0
}
48
49
} // namespace tablet
50
} // namespace yb