YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/util/cow_object.h
Line
Count
Source (jump to first uncovered line)
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
//
18
// The following only applies to changes made to this file as part of YugaByte development.
19
//
20
// Portions Copyright (c) YugaByte, Inc.
21
//
22
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
23
// in compliance with the License.  You may obtain a copy of the License at
24
//
25
// http://www.apache.org/licenses/LICENSE-2.0
26
//
27
// Unless required by applicable law or agreed to in writing, software distributed under the License
28
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
29
// or implied.  See the License for the specific language governing permissions and limitations
30
// under the License.
31
//
32
#ifndef YB_UTIL_COW_OBJECT_H
33
#define YB_UTIL_COW_OBJECT_H
34
35
#include <fcntl.h>
36
37
#include <algorithm>
38
39
#include <glog/logging.h>
40
41
#include "yb/gutil/macros.h"
42
43
#include "yb/util/fault_injection.h"
44
#include "yb/util/logging.h"
45
#include "yb/util/rwc_lock.h"
46
47
namespace yb {
48
49
// An object which manages its state via copy-on-write.
50
//
51
// Access to this object can be done more conveniently using the
52
// CowLock template class defined below.
53
//
54
// The 'State' template parameter must be swappable using std::swap.
55
template<class State>
56
class CowObject {
57
 public:
58
635k
  CowObject() {}
yb::CowObject<yb::master::PersistentSysConfigInfo>::CowObject()
Line
Count
Source
58
11.2k
  CowObject() {}
yb::CowObject<yb::master::PersistentRedisConfigInfo>::CowObject()
Line
Count
Source
58
189
  CowObject() {}
yb::CowObject<yb::master::PersistentClusterConfigInfo>::CowObject()
Line
Count
Source
58
3.75k
  CowObject() {}
yb::CowObject<yb::master::PersistentTabletInfo>::CowObject()
Line
Count
Source
58
100k
  CowObject() {}
yb::CowObject<yb::master::PersistentTableInfo>::CowObject()
Line
Count
Source
58
499k
  CowObject() {}
yb::CowObject<yb::master::PersistentNamespaceInfo>::CowObject()
Line
Count
Source
58
15.5k
  CowObject() {}
yb::CowObject<yb::master::PersistentUDTypeInfo>::CowObject()
Line
Count
Source
58
48
  CowObject() {}
yb::CowObject<yb::master::PersistentRoleInfo>::CowObject()
Line
Count
Source
58
3.76k
  CowObject() {}
yb::CowObject<yb::master::PersistentUniverseReplicationInfo>::CowObject()
Line
Count
Source
58
4
  CowObject() {}
yb::CowObject<yb::master::PersistentCDCStreamInfo>::CowObject()
Line
Count
Source
58
312
  CowObject() {}
Unexecuted instantiation: yb::CowObject<yb::master::PersistentSnapshotInfo>::CowObject()
59
12.1k
  ~CowObject() {}
yb::CowObject<yb::master::PersistentSysConfigInfo>::~CowObject()
Line
Count
Source
59
2.54k
  ~CowObject() {}
yb::CowObject<yb::master::PersistentRedisConfigInfo>::~CowObject()
Line
Count
Source
59
7
  ~CowObject() {}
yb::CowObject<yb::master::PersistentClusterConfigInfo>::~CowObject()
Line
Count
Source
59
847
  ~CowObject() {}
yb::CowObject<yb::master::PersistentTabletInfo>::~CowObject()
Line
Count
Source
59
2.17k
  ~CowObject() {}
yb::CowObject<yb::master::PersistentTableInfo>::~CowObject()
Line
Count
Source
59
3.71k
  ~CowObject() {}
yb::CowObject<yb::master::PersistentNamespaceInfo>::~CowObject()
Line
Count
Source
59
1.88k
  ~CowObject() {}
yb::CowObject<yb::master::PersistentUDTypeInfo>::~CowObject()
Line
Count
Source
59
48
  ~CowObject() {}
yb::CowObject<yb::master::PersistentRoleInfo>::~CowObject()
Line
Count
Source
59
829
  ~CowObject() {}
yb::CowObject<yb::master::PersistentUniverseReplicationInfo>::~CowObject()
Line
Count
Source
59
2
  ~CowObject() {}
yb::CowObject<yb::master::PersistentCDCStreamInfo>::~CowObject()
Line
Count
Source
59
69
  ~CowObject() {}
Unexecuted instantiation: yb::CowObject<yb::master::PersistentSnapshotInfo>::~CowObject()
60
61
1.11G
  void ReadLock() const {
62
1.11G
    lock_.ReadLock();
63
1.11G
  }
yb::CowObject<yb::master::PersistentTableInfo>::ReadLock() const
Line
Count
Source
61
856M
  void ReadLock() const {
62
856M
    lock_.ReadLock();
63
856M
  }
yb::CowObject<yb::master::PersistentTabletInfo>::ReadLock() const
Line
Count
Source
61
239M
  void ReadLock() const {
62
239M
    lock_.ReadLock();
63
239M
  }
yb::CowObject<yb::master::PersistentSysConfigInfo>::ReadLock() const
Line
Count
Source
61
9.28M
  void ReadLock() const {
62
9.28M
    lock_.ReadLock();
63
9.28M
  }
yb::CowObject<yb::master::PersistentClusterConfigInfo>::ReadLock() const
Line
Count
Source
61
12.1M
  void ReadLock() const {
62
12.1M
    lock_.ReadLock();
63
12.1M
  }
yb::CowObject<yb::master::PersistentNamespaceInfo>::ReadLock() const
Line
Count
Source
61
1.57M
  void ReadLock() const {
62
1.57M
    lock_.ReadLock();
63
1.57M
  }
yb::CowObject<yb::master::PersistentUDTypeInfo>::ReadLock() const
Line
Count
Source
61
3.30k
  void ReadLock() const {
62
3.30k
    lock_.ReadLock();
63
3.30k
  }
yb::CowObject<yb::master::PersistentRedisConfigInfo>::ReadLock() const
Line
Count
Source
61
361
  void ReadLock() const {
62
361
    lock_.ReadLock();
63
361
  }
yb::CowObject<yb::master::PersistentRoleInfo>::ReadLock() const
Line
Count
Source
61
63.2k
  void ReadLock() const {
62
63.2k
    lock_.ReadLock();
63
63.2k
  }
Unexecuted instantiation: yb::CowObject<yb::master::PersistentSnapshotInfo>::ReadLock() const
yb::CowObject<yb::master::PersistentCDCStreamInfo>::ReadLock() const
Line
Count
Source
61
2.33k
  void ReadLock() const {
62
2.33k
    lock_.ReadLock();
63
2.33k
  }
yb::CowObject<yb::master::PersistentUniverseReplicationInfo>::ReadLock() const
Line
Count
Source
61
4
  void ReadLock() const {
62
4
    lock_.ReadLock();
63
4
  }
64
65
  void lock_shared() const {
66
    ReadLock();
67
  }
68
69
1.11G
  void ReadUnlock() const {
70
1.11G
    lock_.ReadUnlock();
71
1.11G
  }
yb::CowObject<yb::master::PersistentTableInfo>::ReadUnlock() const
Line
Count
Source
69
856M
  void ReadUnlock() const {
70
856M
    lock_.ReadUnlock();
71
856M
  }
yb::CowObject<yb::master::PersistentTabletInfo>::ReadUnlock() const
Line
Count
Source
69
239M
  void ReadUnlock() const {
70
239M
    lock_.ReadUnlock();
71
239M
  }
yb::CowObject<yb::master::PersistentSysConfigInfo>::ReadUnlock() const
Line
Count
Source
69
9.29M
  void ReadUnlock() const {
70
9.29M
    lock_.ReadUnlock();
71
9.29M
  }
yb::CowObject<yb::master::PersistentClusterConfigInfo>::ReadUnlock() const
Line
Count
Source
69
12.1M
  void ReadUnlock() const {
70
12.1M
    lock_.ReadUnlock();
71
12.1M
  }
yb::CowObject<yb::master::PersistentNamespaceInfo>::ReadUnlock() const
Line
Count
Source
69
1.57M
  void ReadUnlock() const {
70
1.57M
    lock_.ReadUnlock();
71
1.57M
  }
yb::CowObject<yb::master::PersistentUDTypeInfo>::ReadUnlock() const
Line
Count
Source
69
3.30k
  void ReadUnlock() const {
70
3.30k
    lock_.ReadUnlock();
71
3.30k
  }
yb::CowObject<yb::master::PersistentRedisConfigInfo>::ReadUnlock() const
Line
Count
Source
69
361
  void ReadUnlock() const {
70
361
    lock_.ReadUnlock();
71
361
  }
yb::CowObject<yb::master::PersistentRoleInfo>::ReadUnlock() const
Line
Count
Source
69
62.9k
  void ReadUnlock() const {
70
62.9k
    lock_.ReadUnlock();
71
62.9k
  }
Unexecuted instantiation: yb::CowObject<yb::master::PersistentSnapshotInfo>::ReadUnlock() const
yb::CowObject<yb::master::PersistentCDCStreamInfo>::ReadUnlock() const
Line
Count
Source
69
2.33k
  void ReadUnlock() const {
70
2.33k
    lock_.ReadUnlock();
71
2.33k
  }
yb::CowObject<yb::master::PersistentUniverseReplicationInfo>::ReadUnlock() const
Line
Count
Source
69
4
  void ReadUnlock() const {
70
4
    lock_.ReadUnlock();
71
4
  }
72
73
  void unlock_shared() const {
74
    ReadUnlock();
75
  }
76
77
  // Lock the object for write (preventing concurrent mutators), and make a safe
78
  // copy of the object to mutate.
79
2.19M
  void StartMutation() {
80
2.19M
    lock_.WriteLock();
81
    // Clone our object.
82
2.19M
    dirty_state_.reset(new State(state_));
83
2.19M
  }
yb::CowObject<yb::master::PersistentTableInfo>::StartMutation()
Line
Count
Source
79
1.43M
  void StartMutation() {
80
1.43M
    lock_.WriteLock();
81
    // Clone our object.
82
1.43M
    dirty_state_.reset(new State(state_));
83
1.43M
  }
yb::CowObject<yb::master::PersistentTabletInfo>::StartMutation()
Line
Count
Source
79
689k
  void StartMutation() {
80
689k
    lock_.WriteLock();
81
    // Clone our object.
82
689k
    dirty_state_.reset(new State(state_));
83
689k
  }
yb::CowObject<yb::master::PersistentClusterConfigInfo>::StartMutation()
Line
Count
Source
79
3.94k
  void StartMutation() {
80
3.94k
    lock_.WriteLock();
81
    // Clone our object.
82
3.94k
    dirty_state_.reset(new State(state_));
83
3.94k
  }
yb::CowObject<yb::master::PersistentSysConfigInfo>::StartMutation()
Line
Count
Source
79
22.0k
  void StartMutation() {
80
22.0k
    lock_.WriteLock();
81
    // Clone our object.
82
22.0k
    dirty_state_.reset(new State(state_));
83
22.0k
  }
yb::CowObject<yb::master::PersistentNamespaceInfo>::StartMutation()
Line
Count
Source
79
20.8k
  void StartMutation() {
80
20.8k
    lock_.WriteLock();
81
    // Clone our object.
82
20.8k
    dirty_state_.reset(new State(state_));
83
20.8k
  }
yb::CowObject<yb::master::PersistentRedisConfigInfo>::StartMutation()
Line
Count
Source
79
190
  void StartMutation() {
80
190
    lock_.WriteLock();
81
    // Clone our object.
82
190
    dirty_state_.reset(new State(state_));
83
190
  }
yb::CowObject<yb::master::PersistentUDTypeInfo>::StartMutation()
Line
Count
Source
79
94
  void StartMutation() {
80
94
    lock_.WriteLock();
81
    // Clone our object.
82
94
    dirty_state_.reset(new State(state_));
83
94
  }
yb::CowObject<yb::master::PersistentRoleInfo>::StartMutation()
Line
Count
Source
79
17.2k
  void StartMutation() {
80
17.2k
    lock_.WriteLock();
81
    // Clone our object.
82
17.2k
    dirty_state_.reset(new State(state_));
83
17.2k
  }
Unexecuted instantiation: yb::CowObject<yb::master::PersistentSnapshotInfo>::StartMutation()
yb::CowObject<yb::master::PersistentCDCStreamInfo>::StartMutation()
Line
Count
Source
79
5.62k
  void StartMutation() {
80
5.62k
    lock_.WriteLock();
81
    // Clone our object.
82
5.62k
    dirty_state_.reset(new State(state_));
83
5.62k
  }
yb::CowObject<yb::master::PersistentUniverseReplicationInfo>::StartMutation()
Line
Count
Source
79
4
  void StartMutation() {
80
4
    lock_.WriteLock();
81
    // Clone our object.
82
4
    dirty_state_.reset(new State(state_));
83
4
  }
84
85
  // Abort the current mutation. This drops the write lock without applying any
86
  // changes made to the mutable copy.
87
882k
  void AbortMutation() {
88
882k
    dirty_state_.reset();
89
882k
    is_dirty_ = false;
90
882k
    lock_.WriteUnlock();
91
882k
  }
yb::CowObject<yb::master::PersistentTableInfo>::AbortMutation()
Line
Count
Source
87
874k
  void AbortMutation() {
88
874k
    dirty_state_.reset();
89
874k
    is_dirty_ = false;
90
874k
    lock_.WriteUnlock();
91
874k
  }
yb::CowObject<yb::master::PersistentTabletInfo>::AbortMutation()
Line
Count
Source
87
173
  void AbortMutation() {
88
173
    dirty_state_.reset();
89
173
    is_dirty_ = false;
90
173
    lock_.WriteUnlock();
91
173
  }
yb::CowObject<yb::master::PersistentClusterConfigInfo>::AbortMutation()
Line
Count
Source
87
1
  void AbortMutation() {
88
1
    dirty_state_.reset();
89
1
    is_dirty_ = false;
90
1
    lock_.WriteUnlock();
91
1
  }
Unexecuted instantiation: yb::CowObject<yb::master::PersistentSysConfigInfo>::AbortMutation()
yb::CowObject<yb::master::PersistentNamespaceInfo>::AbortMutation()
Line
Count
Source
87
20
  void AbortMutation() {
88
20
    dirty_state_.reset();
89
20
    is_dirty_ = false;
90
20
    lock_.WriteUnlock();
91
20
  }
Unexecuted instantiation: yb::CowObject<yb::master::PersistentRedisConfigInfo>::AbortMutation()
Unexecuted instantiation: yb::CowObject<yb::master::PersistentUDTypeInfo>::AbortMutation()
yb::CowObject<yb::master::PersistentRoleInfo>::AbortMutation()
Line
Count
Source
87
8.00k
  void AbortMutation() {
88
8.00k
    dirty_state_.reset();
89
8.00k
    is_dirty_ = false;
90
8.00k
    lock_.WriteUnlock();
91
8.00k
  }
Unexecuted instantiation: yb::CowObject<yb::master::PersistentSnapshotInfo>::AbortMutation()
Unexecuted instantiation: yb::CowObject<yb::master::PersistentCDCStreamInfo>::AbortMutation()
Unexecuted instantiation: yb::CowObject<yb::master::PersistentUniverseReplicationInfo>::AbortMutation()
92
93
  // Commit the current mutation. This escalates to the "Commit" lock, which
94
  // blocks any concurrent readers or writers, swaps in the new version of the
95
  // State, and then drops the commit lock.
96
1.31M
  void CommitMutation() {
97
1.31M
    lock_.UpgradeToCommitLock();
98
1.31M
    CHECK(dirty_state_);
99
1.31M
    std::swap(state_, *dirty_state_);
100
1.31M
    dirty_state_.reset();
101
1.31M
    is_dirty_ = false;
102
1.31M
    lock_.CommitUnlock();
103
1.31M
  }
yb::CowObject<yb::master::PersistentTableInfo>::CommitMutation()
Line
Count
Source
96
561k
  void CommitMutation() {
97
561k
    lock_.UpgradeToCommitLock();
98
561k
    CHECK(dirty_state_);
99
561k
    std::swap(state_, *dirty_state_);
100
561k
    dirty_state_.reset();
101
561k
    is_dirty_ = false;
102
561k
    lock_.CommitUnlock();
103
561k
  }
yb::CowObject<yb::master::PersistentTabletInfo>::CommitMutation()
Line
Count
Source
96
689k
  void CommitMutation() {
97
689k
    lock_.UpgradeToCommitLock();
98
689k
    CHECK(dirty_state_);
99
689k
    std::swap(state_, *dirty_state_);
100
689k
    dirty_state_.reset();
101
689k
    is_dirty_ = false;
102
689k
    lock_.CommitUnlock();
103
689k
  }
yb::CowObject<yb::master::PersistentClusterConfigInfo>::CommitMutation()
Line
Count
Source
96
3.94k
  void CommitMutation() {
97
3.94k
    lock_.UpgradeToCommitLock();
98
3.94k
    CHECK(dirty_state_);
99
3.94k
    std::swap(state_, *dirty_state_);
100
3.94k
    dirty_state_.reset();
101
3.94k
    is_dirty_ = false;
102
3.94k
    lock_.CommitUnlock();
103
3.94k
  }
yb::CowObject<yb::master::PersistentSysConfigInfo>::CommitMutation()
Line
Count
Source
96
22.0k
  void CommitMutation() {
97
22.0k
    lock_.UpgradeToCommitLock();
98
22.0k
    CHECK(dirty_state_);
99
22.0k
    std::swap(state_, *dirty_state_);
100
22.0k
    dirty_state_.reset();
101
22.0k
    is_dirty_ = false;
102
22.0k
    lock_.CommitUnlock();
103
22.0k
  }
yb::CowObject<yb::master::PersistentNamespaceInfo>::CommitMutation()
Line
Count
Source
96
20.8k
  void CommitMutation() {
97
20.8k
    lock_.UpgradeToCommitLock();
98
20.8k
    CHECK(dirty_state_);
99
20.8k
    std::swap(state_, *dirty_state_);
100
20.8k
    dirty_state_.reset();
101
20.8k
    is_dirty_ = false;
102
20.8k
    lock_.CommitUnlock();
103
20.8k
  }
yb::CowObject<yb::master::PersistentRedisConfigInfo>::CommitMutation()
Line
Count
Source
96
190
  void CommitMutation() {
97
190
    lock_.UpgradeToCommitLock();
98
190
    CHECK(dirty_state_);
99
190
    std::swap(state_, *dirty_state_);
100
190
    dirty_state_.reset();
101
190
    is_dirty_ = false;
102
190
    lock_.CommitUnlock();
103
190
  }
yb::CowObject<yb::master::PersistentUDTypeInfo>::CommitMutation()
Line
Count
Source
96
94
  void CommitMutation() {
97
94
    lock_.UpgradeToCommitLock();
98
94
    CHECK(dirty_state_);
99
94
    std::swap(state_, *dirty_state_);
100
94
    dirty_state_.reset();
101
94
    is_dirty_ = false;
102
94
    lock_.CommitUnlock();
103
94
  }
yb::CowObject<yb::master::PersistentRoleInfo>::CommitMutation()
Line
Count
Source
96
9.27k
  void CommitMutation() {
97
9.27k
    lock_.UpgradeToCommitLock();
98
9.27k
    CHECK(dirty_state_);
99
9.27k
    std::swap(state_, *dirty_state_);
100
9.27k
    dirty_state_.reset();
101
9.27k
    is_dirty_ = false;
102
9.27k
    lock_.CommitUnlock();
103
9.27k
  }
Unexecuted instantiation: yb::CowObject<yb::master::PersistentSnapshotInfo>::CommitMutation()
yb::CowObject<yb::master::PersistentCDCStreamInfo>::CommitMutation()
Line
Count
Source
96
5.62k
  void CommitMutation() {
97
5.62k
    lock_.UpgradeToCommitLock();
98
5.62k
    CHECK(dirty_state_);
99
5.62k
    std::swap(state_, *dirty_state_);
100
5.62k
    dirty_state_.reset();
101
5.62k
    is_dirty_ = false;
102
5.62k
    lock_.CommitUnlock();
103
5.62k
  }
yb::CowObject<yb::master::PersistentUniverseReplicationInfo>::CommitMutation()
Line
Count
Source
96
4
  void CommitMutation() {
97
4
    lock_.UpgradeToCommitLock();
98
4
    CHECK(dirty_state_);
99
4
    std::swap(state_, *dirty_state_);
100
4
    dirty_state_.reset();
101
4
    is_dirty_ = false;
102
4
    lock_.CommitUnlock();
103
4
  }
104
105
  // Return the current state, not reflecting any in-progress mutations.
106
  State& state() {
107
    DCHECK(lock_.HasReaders() || lock_.HasWriteLock());
108
    return state_;
109
  }
110
111
864M
  const State& state() const {
112
864M
    DCHECK(lock_.HasReaders() || lock_.HasWriteLock());
113
864M
    return state_;
114
864M
  }
yb::CowObject<yb::master::PersistentTableInfo>::state() const
Line
Count
Source
111
658M
  const State& state() const {
112
658M
    DCHECK(lock_.HasReaders() || lock_.HasWriteLock());
113
658M
    return state_;
114
658M
  }
yb::CowObject<yb::master::PersistentTabletInfo>::state() const
Line
Count
Source
111
178M
  const State& state() const {
112
178M
    DCHECK(lock_.HasReaders() || lock_.HasWriteLock());
113
178M
    return state_;
114
178M
  }
yb::CowObject<yb::master::PersistentSysConfigInfo>::state() const
Line
Count
Source
111
13.7M
  const State& state() const {
112
13.7M
    DCHECK(lock_.HasReaders() || lock_.HasWriteLock());
113
13.7M
    return state_;
114
13.7M
  }
yb::CowObject<yb::master::PersistentClusterConfigInfo>::state() const
Line
Count
Source
111
12.1M
  const State& state() const {
112
12.1M
    DCHECK(lock_.HasReaders() || lock_.HasWriteLock());
113
12.1M
    return state_;
114
12.1M
  }
yb::CowObject<yb::master::PersistentNamespaceInfo>::state() const
Line
Count
Source
111
1.63M
  const State& state() const {
112
1.63M
    DCHECK(lock_.HasReaders() || lock_.HasWriteLock());
113
1.63M
    return state_;
114
1.63M
  }
yb::CowObject<yb::master::PersistentUDTypeInfo>::state() const
Line
Count
Source
111
4.14k
  const State& state() const {
112
4.14k
    DCHECK(lock_.HasReaders() || lock_.HasWriteLock());
113
4.14k
    return state_;
114
4.14k
  }
yb::CowObject<yb::master::PersistentRedisConfigInfo>::state() const
Line
Count
Source
111
548
  const State& state() const {
112
548
    DCHECK(lock_.HasReaders() || lock_.HasWriteLock());
113
548
    return state_;
114
548
  }
yb::CowObject<yb::master::PersistentRoleInfo>::state() const
Line
Count
Source
111
88.2k
  const State& state() const {
112
88.2k
    DCHECK(lock_.HasReaders() || lock_.HasWriteLock());
113
88.2k
    return state_;
114
88.2k
  }
Unexecuted instantiation: yb::CowObject<yb::master::PersistentSnapshotInfo>::state() const
yb::CowObject<yb::master::PersistentCDCStreamInfo>::state() const
Line
Count
Source
111
8.66k
  const State& state() const {
112
8.66k
    DCHECK(lock_.HasReaders() || lock_.HasWriteLock());
113
8.66k
    return state_;
114
8.66k
  }
yb::CowObject<yb::master::PersistentUniverseReplicationInfo>::state() const
Line
Count
Source
111
8
  const State& state() const {
112
8
    DCHECK(lock_.HasReaders() || lock_.HasWriteLock());
113
8
    return state_;
114
8
  }
115
116
  // Returns the current dirty state (i.e reflecting in-progress mutations).
117
  // Should only be called by a thread who previously called StartMutation().
118
1.59M
  State* mutable_dirty() {
119
1.59M
    DCHECK(lock_.HasWriteLock());
120
1.59M
    is_dirty_ = true;
121
1.59M
    return DCHECK_NOTNULL(dirty_state_.get());
122
1.59M
  }
yb::CowObject<yb::master::PersistentTableInfo>::mutable_dirty()
Line
Count
Source
118
1.08M
  State* mutable_dirty() {
119
1.08M
    DCHECK(lock_.HasWriteLock());
120
1.08M
    is_dirty_ = true;
121
1.08M
    return DCHECK_NOTNULL(dirty_state_.get());
122
1.08M
  }
yb::CowObject<yb::master::PersistentTabletInfo>::mutable_dirty()
Line
Count
Source
118
422k
  State* mutable_dirty() {
119
422k
    DCHECK(lock_.HasWriteLock());
120
422k
    is_dirty_ = true;
121
422k
    return DCHECK_NOTNULL(dirty_state_.get());
122
422k
  }
yb::CowObject<yb::master::PersistentClusterConfigInfo>::mutable_dirty()
Line
Count
Source
118
4.16k
  State* mutable_dirty() {
119
4.16k
    DCHECK(lock_.HasWriteLock());
120
4.16k
    is_dirty_ = true;
121
4.16k
    return DCHECK_NOTNULL(dirty_state_.get());
122
4.16k
  }
yb::CowObject<yb::master::PersistentSysConfigInfo>::mutable_dirty()
Line
Count
Source
118
28.0k
  State* mutable_dirty() {
119
28.0k
    DCHECK(lock_.HasWriteLock());
120
28.0k
    is_dirty_ = true;
121
28.0k
    return DCHECK_NOTNULL(dirty_state_.get());
122
28.0k
  }
yb::CowObject<yb::master::PersistentNamespaceInfo>::mutable_dirty()
Line
Count
Source
118
25.8k
  State* mutable_dirty() {
119
25.8k
    DCHECK(lock_.HasWriteLock());
120
25.8k
    is_dirty_ = true;
121
25.8k
    return DCHECK_NOTNULL(dirty_state_.get());
122
25.8k
  }
yb::CowObject<yb::master::PersistentRedisConfigInfo>::mutable_dirty()
Line
Count
Source
118
190
  State* mutable_dirty() {
119
190
    DCHECK(lock_.HasWriteLock());
120
190
    is_dirty_ = true;
121
190
    return DCHECK_NOTNULL(dirty_state_.get());
122
190
  }
yb::CowObject<yb::master::PersistentUDTypeInfo>::mutable_dirty()
Line
Count
Source
118
49
  State* mutable_dirty() {
119
49
    DCHECK(lock_.HasWriteLock());
120
49
    is_dirty_ = true;
121
49
    return DCHECK_NOTNULL(dirty_state_.get());
122
49
  }
yb::CowObject<yb::master::PersistentRoleInfo>::mutable_dirty()
Line
Count
Source
118
17.2k
  State* mutable_dirty() {
119
17.2k
    DCHECK(lock_.HasWriteLock());
120
17.2k
    is_dirty_ = true;
121
17.2k
    return DCHECK_NOTNULL(dirty_state_.get());
122
17.2k
  }
Unexecuted instantiation: yb::CowObject<yb::master::PersistentSnapshotInfo>::mutable_dirty()
yb::CowObject<yb::master::PersistentCDCStreamInfo>::mutable_dirty()
Line
Count
Source
118
5.56k
  State* mutable_dirty() {
119
5.56k
    DCHECK(lock_.HasWriteLock());
120
5.56k
    is_dirty_ = true;
121
5.56k
    return DCHECK_NOTNULL(dirty_state_.get());
122
5.56k
  }
yb::CowObject<yb::master::PersistentUniverseReplicationInfo>::mutable_dirty()
Line
Count
Source
118
4
  State* mutable_dirty() {
119
4
    DCHECK(lock_.HasWriteLock());
120
4
    is_dirty_ = true;
121
4
    return DCHECK_NOTNULL(dirty_state_.get());
122
4
  }
123
124
7.60M
  const State& dirty() const {
125
7.60M
    return *DCHECK_NOTNULL(dirty_state_.get());
126
7.60M
  }
yb::CowObject<yb::master::PersistentTabletInfo>::dirty() const
Line
Count
Source
124
3.67M
  const State& dirty() const {
125
3.67M
    return *DCHECK_NOTNULL(dirty_state_.get());
126
3.67M
  }
yb::CowObject<yb::master::PersistentTableInfo>::dirty() const
Line
Count
Source
124
3.86M
  const State& dirty() const {
125
3.86M
    return *DCHECK_NOTNULL(dirty_state_.get());
126
3.86M
  }
yb::CowObject<yb::master::PersistentClusterConfigInfo>::dirty() const
Line
Count
Source
124
3.44k
  const State& dirty() const {
125
3.44k
    return *DCHECK_NOTNULL(dirty_state_.get());
126
3.44k
  }
yb::CowObject<yb::master::PersistentSysConfigInfo>::dirty() const
Line
Count
Source
124
20.6k
  const State& dirty() const {
125
20.6k
    return *DCHECK_NOTNULL(dirty_state_.get());
126
20.6k
  }
yb::CowObject<yb::master::PersistentNamespaceInfo>::dirty() const
Line
Count
Source
124
20.1k
  const State& dirty() const {
125
20.1k
    return *DCHECK_NOTNULL(dirty_state_.get());
126
20.1k
  }
yb::CowObject<yb::master::PersistentRedisConfigInfo>::dirty() const
Line
Count
Source
124
185
  const State& dirty() const {
125
185
    return *DCHECK_NOTNULL(dirty_state_.get());
126
185
  }
yb::CowObject<yb::master::PersistentUDTypeInfo>::dirty() const
Line
Count
Source
124
47
  const State& dirty() const {
125
47
    return *DCHECK_NOTNULL(dirty_state_.get());
126
47
  }
yb::CowObject<yb::master::PersistentRoleInfo>::dirty() const
Line
Count
Source
124
5.72k
  const State& dirty() const {
125
5.72k
    return *DCHECK_NOTNULL(dirty_state_.get());
126
5.72k
  }
yb::CowObject<yb::master::PersistentUniverseReplicationInfo>::dirty() const
Line
Count
Source
124
3
  const State& dirty() const {
125
3
    return *DCHECK_NOTNULL(dirty_state_.get());
126
3
  }
yb::CowObject<yb::master::PersistentCDCStreamInfo>::dirty() const
Line
Count
Source
124
10.7k
  const State& dirty() const {
125
10.7k
    return *DCHECK_NOTNULL(dirty_state_.get());
126
10.7k
  }
Unexecuted instantiation: yb::CowObject<yb::master::PersistentSnapshotInfo>::dirty() const
127
128
  bool is_dirty() const {
129
    DCHECK(lock_.HasReaders() || lock_.HasWriteLock());
130
    return is_dirty_;
131
  }
132
133
 private:
134
  mutable RWCLock lock_;
135
136
  State state_;
137
  std::unique_ptr<State> dirty_state_;
138
139
  // Set only when mutable_dirty() method is called. Unset whenever dirty_state_ is reset().
140
  bool is_dirty_ = false;
141
142
  DISALLOW_COPY_AND_ASSIGN(CowObject);
143
};
144
145
// A lock-guard-like scoped object to acquire the lock on a CowObject,
146
// and obtain a pointer to the correct copy to read.
147
//
148
// Example usage:
149
//
150
//   CowObject<Foo> my_obj;
151
//   {
152
//     CowReadLock<Foo> l(&my_obj);
153
//     l.data().get_foo();
154
//     ...
155
//   }
156
template<class State>
157
class CowReadLock {
158
 public:
159
  CowReadLock() : cow_(nullptr) {}
160
161
  explicit CowReadLock(const CowObject<State>* cow)
162
1.11G
    : cow_(cow) {
163
1.11G
    cow_->ReadLock();
164
1.11G
  }
yb::CowReadLock<yb::master::PersistentTableInfo>::CowReadLock(yb::CowObject<yb::master::PersistentTableInfo> const*)
Line
Count
Source
162
856M
    : cow_(cow) {
163
856M
    cow_->ReadLock();
164
856M
  }
yb::CowReadLock<yb::master::PersistentTabletInfo>::CowReadLock(yb::CowObject<yb::master::PersistentTabletInfo> const*)
Line
Count
Source
162
239M
    : cow_(cow) {
163
239M
    cow_->ReadLock();
164
239M
  }
yb::CowReadLock<yb::master::PersistentSysConfigInfo>::CowReadLock(yb::CowObject<yb::master::PersistentSysConfigInfo> const*)
Line
Count
Source
162
9.28M
    : cow_(cow) {
163
9.28M
    cow_->ReadLock();
164
9.28M
  }
yb::CowReadLock<yb::master::PersistentClusterConfigInfo>::CowReadLock(yb::CowObject<yb::master::PersistentClusterConfigInfo> const*)
Line
Count
Source
162
12.1M
    : cow_(cow) {
163
12.1M
    cow_->ReadLock();
164
12.1M
  }
yb::CowReadLock<yb::master::PersistentNamespaceInfo>::CowReadLock(yb::CowObject<yb::master::PersistentNamespaceInfo> const*)
Line
Count
Source
162
1.57M
    : cow_(cow) {
163
1.57M
    cow_->ReadLock();
164
1.57M
  }
yb::CowReadLock<yb::master::PersistentUDTypeInfo>::CowReadLock(yb::CowObject<yb::master::PersistentUDTypeInfo> const*)
Line
Count
Source
162
3.30k
    : cow_(cow) {
163
3.30k
    cow_->ReadLock();
164
3.30k
  }
yb::CowReadLock<yb::master::PersistentRedisConfigInfo>::CowReadLock(yb::CowObject<yb::master::PersistentRedisConfigInfo> const*)
Line
Count
Source
162
361
    : cow_(cow) {
163
361
    cow_->ReadLock();
164
361
  }
yb::CowReadLock<yb::master::PersistentRoleInfo>::CowReadLock(yb::CowObject<yb::master::PersistentRoleInfo> const*)
Line
Count
Source
162
63.2k
    : cow_(cow) {
163
63.2k
    cow_->ReadLock();
164
63.2k
  }
Unexecuted instantiation: yb::CowReadLock<yb::master::PersistentSnapshotInfo>::CowReadLock(yb::CowObject<yb::master::PersistentSnapshotInfo> const*)
yb::CowReadLock<yb::master::PersistentCDCStreamInfo>::CowReadLock(yb::CowObject<yb::master::PersistentCDCStreamInfo> const*)
Line
Count
Source
162
2.33k
    : cow_(cow) {
163
2.33k
    cow_->ReadLock();
164
2.33k
  }
yb::CowReadLock<yb::master::PersistentUniverseReplicationInfo>::CowReadLock(yb::CowObject<yb::master::PersistentUniverseReplicationInfo> const*)
Line
Count
Source
162
4
    : cow_(cow) {
163
4
    cow_->ReadLock();
164
4
  }
165
166
  CowReadLock(const CowReadLock&) = delete;
167
  void operator=(const CowReadLock&) = delete;
168
169
  CowReadLock(CowReadLock&& rhs) noexcept
170
151
      : cow_(rhs.cow_) {
171
151
    rhs.cow_ = nullptr;
172
151
  }
yb::CowReadLock<yb::master::PersistentNamespaceInfo>::CowReadLock(yb::CowReadLock<yb::master::PersistentNamespaceInfo>&&)
Line
Count
Source
170
41
      : cow_(rhs.cow_) {
171
41
    rhs.cow_ = nullptr;
172
41
  }
yb::CowReadLock<yb::master::PersistentTableInfo>::CowReadLock(yb::CowReadLock<yb::master::PersistentTableInfo>&&)
Line
Count
Source
170
30
      : cow_(rhs.cow_) {
171
30
    rhs.cow_ = nullptr;
172
30
  }
yb::CowReadLock<yb::master::PersistentTabletInfo>::CowReadLock(yb::CowReadLock<yb::master::PersistentTabletInfo>&&)
Line
Count
Source
170
80
      : cow_(rhs.cow_) {
171
80
    rhs.cow_ = nullptr;
172
80
  }
173
174
  void operator=(CowReadLock&& rhs) noexcept {
175
    Unlock();
176
    cow_ = rhs.cow_;
177
    rhs.cow_ = nullptr;
178
  }
179
180
1.11G
  void Unlock() {
181
1.11G
    if (
cow_1.11G
) {
182
1.11G
      cow_->ReadUnlock();
183
1.11G
      cow_ = nullptr;
184
1.11G
    }
185
1.11G
  }
yb::CowReadLock<yb::master::PersistentTableInfo>::Unlock()
Line
Count
Source
180
856M
  void Unlock() {
181
856M
    if (
cow_856M
) {
182
856M
      cow_->ReadUnlock();
183
856M
      cow_ = nullptr;
184
856M
    }
185
856M
  }
yb::CowReadLock<yb::master::PersistentTabletInfo>::Unlock()
Line
Count
Source
180
239M
  void Unlock() {
181
239M
    if (cow_) {
182
239M
      cow_->ReadUnlock();
183
239M
      cow_ = nullptr;
184
239M
    }
185
239M
  }
yb::CowReadLock<yb::master::PersistentSysConfigInfo>::Unlock()
Line
Count
Source
180
9.29M
  void Unlock() {
181
9.29M
    if (
cow_9.29M
) {
182
9.29M
      cow_->ReadUnlock();
183
9.29M
      cow_ = nullptr;
184
9.29M
    }
185
9.29M
  }
yb::CowReadLock<yb::master::PersistentClusterConfigInfo>::Unlock()
Line
Count
Source
180
12.1M
  void Unlock() {
181
12.1M
    if (
cow_12.1M
) {
182
12.1M
      cow_->ReadUnlock();
183
12.1M
      cow_ = nullptr;
184
12.1M
    }
185
12.1M
  }
yb::CowReadLock<yb::master::PersistentNamespaceInfo>::Unlock()
Line
Count
Source
180
1.57M
  void Unlock() {
181
1.57M
    if (cow_) {
182
1.57M
      cow_->ReadUnlock();
183
1.57M
      cow_ = nullptr;
184
1.57M
    }
185
1.57M
  }
yb::CowReadLock<yb::master::PersistentUDTypeInfo>::Unlock()
Line
Count
Source
180
3.30k
  void Unlock() {
181
3.30k
    if (cow_) {
182
3.30k
      cow_->ReadUnlock();
183
3.30k
      cow_ = nullptr;
184
3.30k
    }
185
3.30k
  }
yb::CowReadLock<yb::master::PersistentRedisConfigInfo>::Unlock()
Line
Count
Source
180
361
  void Unlock() {
181
361
    if (cow_) {
182
361
      cow_->ReadUnlock();
183
361
      cow_ = nullptr;
184
361
    }
185
361
  }
yb::CowReadLock<yb::master::PersistentRoleInfo>::Unlock()
Line
Count
Source
180
62.8k
  void Unlock() {
181
62.9k
    if (
cow_62.8k
) {
182
62.9k
      cow_->ReadUnlock();
183
62.9k
      cow_ = nullptr;
184
62.9k
    }
185
62.8k
  }
Unexecuted instantiation: yb::CowReadLock<yb::master::PersistentSnapshotInfo>::Unlock()
yb::CowReadLock<yb::master::PersistentCDCStreamInfo>::Unlock()
Line
Count
Source
180
2.33k
  void Unlock() {
181
2.33k
    if (cow_) {
182
2.33k
      cow_->ReadUnlock();
183
2.33k
      cow_ = nullptr;
184
2.33k
    }
185
2.33k
  }
yb::CowReadLock<yb::master::PersistentUniverseReplicationInfo>::Unlock()
Line
Count
Source
180
4
  void Unlock() {
181
4
    if (cow_) {
182
4
      cow_->ReadUnlock();
183
4
      cow_ = nullptr;
184
4
    }
185
4
  }
186
187
862M
  const State& data() const {
188
862M
    return cow_->state();
189
862M
  }
yb::CowReadLock<yb::master::PersistentTableInfo>::data() const
Line
Count
Source
187
657M
  const State& data() const {
188
657M
    return cow_->state();
189
657M
  }
yb::CowReadLock<yb::master::PersistentTabletInfo>::data() const
Line
Count
Source
187
177M
  const State& data() const {
188
177M
    return cow_->state();
189
177M
  }
yb::CowReadLock<yb::master::PersistentSysConfigInfo>::data() const
Line
Count
Source
187
13.7M
  const State& data() const {
188
13.7M
    return cow_->state();
189
13.7M
  }
yb::CowReadLock<yb::master::PersistentClusterConfigInfo>::data() const
Line
Count
Source
187
12.1M
  const State& data() const {
188
12.1M
    return cow_->state();
189
12.1M
  }
yb::CowReadLock<yb::master::PersistentNamespaceInfo>::data() const
Line
Count
Source
187
1.62M
  const State& data() const {
188
1.62M
    return cow_->state();
189
1.62M
  }
yb::CowReadLock<yb::master::PersistentUDTypeInfo>::data() const
Line
Count
Source
187
4.05k
  const State& data() const {
188
4.05k
    return cow_->state();
189
4.05k
  }
yb::CowReadLock<yb::master::PersistentRedisConfigInfo>::data() const
Line
Count
Source
187
361
  const State& data() const {
188
361
    return cow_->state();
189
361
  }
yb::CowReadLock<yb::master::PersistentRoleInfo>::data() const
Line
Count
Source
187
81.9k
  const State& data() const {
188
81.9k
    return cow_->state();
189
81.9k
  }
yb::CowReadLock<yb::master::PersistentCDCStreamInfo>::data() const
Line
Count
Source
187
3.03k
  const State& data() const {
188
3.03k
    return cow_->state();
189
3.03k
  }
yb::CowReadLock<yb::master::PersistentUniverseReplicationInfo>::data() const
Line
Count
Source
187
4
  const State& data() const {
188
4
    return cow_->state();
189
4
  }
Unexecuted instantiation: yb::CowReadLock<yb::master::PersistentSnapshotInfo>::data() const
190
191
862M
  const State* operator->() const {
192
862M
    return &data();
193
862M
  }
yb::CowReadLock<yb::master::PersistentTableInfo>::operator->() const
Line
Count
Source
191
657M
  const State* operator->() const {
192
657M
    return &data();
193
657M
  }
yb::CowReadLock<yb::master::PersistentTabletInfo>::operator->() const
Line
Count
Source
191
177M
  const State* operator->() const {
192
177M
    return &data();
193
177M
  }
yb::CowReadLock<yb::master::PersistentSysConfigInfo>::operator->() const
Line
Count
Source
191
13.7M
  const State* operator->() const {
192
13.7M
    return &data();
193
13.7M
  }
yb::CowReadLock<yb::master::PersistentClusterConfigInfo>::operator->() const
Line
Count
Source
191
12.1M
  const State* operator->() const {
192
12.1M
    return &data();
193
12.1M
  }
yb::CowReadLock<yb::master::PersistentNamespaceInfo>::operator->() const
Line
Count
Source
191
1.62M
  const State* operator->() const {
192
1.62M
    return &data();
193
1.62M
  }
yb::CowReadLock<yb::master::PersistentUDTypeInfo>::operator->() const
Line
Count
Source
191
4.05k
  const State* operator->() const {
192
4.05k
    return &data();
193
4.05k
  }
yb::CowReadLock<yb::master::PersistentRedisConfigInfo>::operator->() const
Line
Count
Source
191
361
  const State* operator->() const {
192
361
    return &data();
193
361
  }
yb::CowReadLock<yb::master::PersistentRoleInfo>::operator->() const
Line
Count
Source
191
81.9k
  const State* operator->() const {
192
81.9k
    return &data();
193
81.9k
  }
yb::CowReadLock<yb::master::PersistentCDCStreamInfo>::operator->() const
Line
Count
Source
191
3.03k
  const State* operator->() const {
192
3.03k
    return &data();
193
3.03k
  }
yb::CowReadLock<yb::master::PersistentUniverseReplicationInfo>::operator->() const
Line
Count
Source
191
4
  const State* operator->() const {
192
4
    return &data();
193
4
  }
Unexecuted instantiation: yb::CowReadLock<yb::master::PersistentSnapshotInfo>::operator->() const
194
195
  bool locked() const {
196
    return cow_ != nullptr;
197
  }
198
199
1.11G
  ~CowReadLock() {
200
1.11G
    Unlock();
201
1.11G
  }
yb::CowReadLock<yb::master::PersistentTableInfo>::~CowReadLock()
Line
Count
Source
199
856M
  ~CowReadLock() {
200
856M
    Unlock();
201
856M
  }
yb::CowReadLock<yb::master::PersistentTabletInfo>::~CowReadLock()
Line
Count
Source
199
239M
  ~CowReadLock() {
200
239M
    Unlock();
201
239M
  }
yb::CowReadLock<yb::master::PersistentSysConfigInfo>::~CowReadLock()
Line
Count
Source
199
9.29M
  ~CowReadLock() {
200
9.29M
    Unlock();
201
9.29M
  }
yb::CowReadLock<yb::master::PersistentClusterConfigInfo>::~CowReadLock()
Line
Count
Source
199
12.1M
  ~CowReadLock() {
200
12.1M
    Unlock();
201
12.1M
  }
yb::CowReadLock<yb::master::PersistentNamespaceInfo>::~CowReadLock()
Line
Count
Source
199
1.57M
  ~CowReadLock() {
200
1.57M
    Unlock();
201
1.57M
  }
yb::CowReadLock<yb::master::PersistentUDTypeInfo>::~CowReadLock()
Line
Count
Source
199
3.30k
  ~CowReadLock() {
200
3.30k
    Unlock();
201
3.30k
  }
yb::CowReadLock<yb::master::PersistentRedisConfigInfo>::~CowReadLock()
Line
Count
Source
199
361
  ~CowReadLock() {
200
361
    Unlock();
201
361
  }
yb::CowReadLock<yb::master::PersistentRoleInfo>::~CowReadLock()
Line
Count
Source
199
62.8k
  ~CowReadLock() {
200
62.8k
    Unlock();
201
62.8k
  }
Unexecuted instantiation: yb::CowReadLock<yb::master::PersistentSnapshotInfo>::~CowReadLock()
yb::CowReadLock<yb::master::PersistentCDCStreamInfo>::~CowReadLock()
Line
Count
Source
199
2.33k
  ~CowReadLock() {
200
2.33k
    Unlock();
201
2.33k
  }
yb::CowReadLock<yb::master::PersistentUniverseReplicationInfo>::~CowReadLock()
Line
Count
Source
199
4
  ~CowReadLock() {
200
4
    Unlock();
201
4
  }
202
203
 private:
204
  const CowObject<State>* cow_;
205
};
206
207
// A lock-guard-like scoped object to acquire the lock on a CowObject,
208
// and obtain a pointer to the correct copy to write.
209
//
210
// Example usage:
211
//
212
//   CowObject<Foo> my_obj;
213
//   {
214
//     CowWriteLock<Foo> l(&my_obj);
215
//     l.mutable_data()->set_foo(...);
216
//     ...
217
//     l.Commit();
218
//   }
219
template<class State>
220
class CowWriteLock {
221
 public:
222
16.8M
  CowWriteLock() : cow_(nullptr) {}
yb::CowWriteLock<yb::master::PersistentTableInfo>::CowWriteLock()
Line
Count
Source
222
16.3M
  CowWriteLock() : cow_(nullptr) {}
yb::CowWriteLock<yb::master::PersistentTabletInfo>::CowWriteLock()
Line
Count
Source
222
454k
  CowWriteLock() : cow_(nullptr) {}
223
224
  explicit CowWriteLock(CowObject<State>* cow)
225
1.94M
    : cow_(cow) {
226
1.94M
    cow_->StartMutation();
227
1.94M
  }
yb::CowWriteLock<yb::master::PersistentTableInfo>::CowWriteLock(yb::CowObject<yb::master::PersistentTableInfo>*)
Line
Count
Source
225
1.37M
    : cow_(cow) {
226
1.37M
    cow_->StartMutation();
227
1.37M
  }
yb::CowWriteLock<yb::master::PersistentTabletInfo>::CowWriteLock(yb::CowObject<yb::master::PersistentTabletInfo>*)
Line
Count
Source
225
513k
    : cow_(cow) {
226
513k
    cow_->StartMutation();
227
513k
  }
yb::CowWriteLock<yb::master::PersistentClusterConfigInfo>::CowWriteLock(yb::CowObject<yb::master::PersistentClusterConfigInfo>*)
Line
Count
Source
225
3.94k
    : cow_(cow) {
226
3.94k
    cow_->StartMutation();
227
3.94k
  }
yb::CowWriteLock<yb::master::PersistentSysConfigInfo>::CowWriteLock(yb::CowObject<yb::master::PersistentSysConfigInfo>*)
Line
Count
Source
225
22.0k
    : cow_(cow) {
226
22.0k
    cow_->StartMutation();
227
22.0k
  }
yb::CowWriteLock<yb::master::PersistentNamespaceInfo>::CowWriteLock(yb::CowObject<yb::master::PersistentNamespaceInfo>*)
Line
Count
Source
225
18.2k
    : cow_(cow) {
226
18.2k
    cow_->StartMutation();
227
18.2k
  }
yb::CowWriteLock<yb::master::PersistentRedisConfigInfo>::CowWriteLock(yb::CowObject<yb::master::PersistentRedisConfigInfo>*)
Line
Count
Source
225
189
    : cow_(cow) {
226
189
    cow_->StartMutation();
227
189
  }
yb::CowWriteLock<yb::master::PersistentUDTypeInfo>::CowWriteLock(yb::CowObject<yb::master::PersistentUDTypeInfo>*)
Line
Count
Source
225
48
    : cow_(cow) {
226
48
    cow_->StartMutation();
227
48
  }
yb::CowWriteLock<yb::master::PersistentRoleInfo>::CowWriteLock(yb::CowObject<yb::master::PersistentRoleInfo>*)
Line
Count
Source
225
4.54k
    : cow_(cow) {
226
4.54k
    cow_->StartMutation();
227
4.54k
  }
Unexecuted instantiation: yb::CowWriteLock<yb::master::PersistentSnapshotInfo>::CowWriteLock(yb::CowObject<yb::master::PersistentSnapshotInfo>*)
yb::CowWriteLock<yb::master::PersistentCDCStreamInfo>::CowWriteLock(yb::CowObject<yb::master::PersistentCDCStreamInfo>*)
Line
Count
Source
225
5.31k
    : cow_(cow) {
226
5.31k
    cow_->StartMutation();
227
5.31k
  }
yb::CowWriteLock<yb::master::PersistentUniverseReplicationInfo>::CowWriteLock(yb::CowObject<yb::master::PersistentUniverseReplicationInfo>*)
Line
Count
Source
225
2
    : cow_(cow) {
226
2
    cow_->StartMutation();
227
2
  }
228
229
  CowWriteLock(const CowWriteLock&) = delete;
230
  void operator=(const CowWriteLock&) = delete;
231
232
  CowWriteLock(CowWriteLock&& rhs) noexcept
233
87.9k
      : cow_(rhs.cow_) {
234
87.9k
    rhs.cow_ = nullptr;
235
87.9k
  }
yb::CowWriteLock<yb::master::PersistentTableInfo>::CowWriteLock(yb::CowWriteLock<yb::master::PersistentTableInfo>&&)
Line
Count
Source
233
62.8k
      : cow_(rhs.cow_) {
234
62.8k
    rhs.cow_ = nullptr;
235
62.8k
  }
yb::CowWriteLock<yb::master::PersistentTabletInfo>::CowWriteLock(yb::CowWriteLock<yb::master::PersistentTabletInfo>&&)
Line
Count
Source
233
24.9k
      : cow_(rhs.cow_) {
234
24.9k
    rhs.cow_ = nullptr;
235
24.9k
  }
yb::CowWriteLock<yb::master::PersistentCDCStreamInfo>::CowWriteLock(yb::CowWriteLock<yb::master::PersistentCDCStreamInfo>&&)
Line
Count
Source
233
127
      : cow_(rhs.cow_) {
234
127
    rhs.cow_ = nullptr;
235
127
  }
236
237
1.14M
  void operator=(CowWriteLock&& rhs) noexcept {
238
1.14M
    Unlock();
239
1.14M
    cow_ = rhs.cow_;
240
1.14M
    rhs.cow_ = nullptr;
241
1.14M
  }
yb::CowWriteLock<yb::master::PersistentTableInfo>::operator=(yb::CowWriteLock<yb::master::PersistentTableInfo>&&)
Line
Count
Source
237
695k
  void operator=(CowWriteLock&& rhs) noexcept {
238
695k
    Unlock();
239
695k
    cow_ = rhs.cow_;
240
695k
    rhs.cow_ = nullptr;
241
695k
  }
yb::CowWriteLock<yb::master::PersistentTabletInfo>::operator=(yb::CowWriteLock<yb::master::PersistentTabletInfo>&&)
Line
Count
Source
237
454k
  void operator=(CowWriteLock&& rhs) noexcept {
238
454k
    Unlock();
239
454k
    cow_ = rhs.cow_;
240
454k
    rhs.cow_ = nullptr;
241
454k
  }
242
243
  // Commit the underlying object.
244
  // Requires that the caller hold the lock.
245
1.06M
  void Commit() {
246
1.06M
    cow_->CommitMutation();
247
1.06M
    cow_ = nullptr;
248
1.06M
  }
yb::CowWriteLock<yb::master::PersistentTableInfo>::Commit()
Line
Count
Source
245
502k
  void Commit() {
246
502k
    cow_->CommitMutation();
247
502k
    cow_ = nullptr;
248
502k
  }
yb::CowWriteLock<yb::master::PersistentTabletInfo>::Commit()
Line
Count
Source
245
513k
  void Commit() {
246
513k
    cow_->CommitMutation();
247
513k
    cow_ = nullptr;
248
513k
  }
yb::CowWriteLock<yb::master::PersistentClusterConfigInfo>::Commit()
Line
Count
Source
245
3.94k
  void Commit() {
246
3.94k
    cow_->CommitMutation();
247
3.94k
    cow_ = nullptr;
248
3.94k
  }
yb::CowWriteLock<yb::master::PersistentSysConfigInfo>::Commit()
Line
Count
Source
245
22.0k
  void Commit() {
246
22.0k
    cow_->CommitMutation();
247
22.0k
    cow_ = nullptr;
248
22.0k
  }
yb::CowWriteLock<yb::master::PersistentNamespaceInfo>::Commit()
Line
Count
Source
245
18.1k
  void Commit() {
246
18.1k
    cow_->CommitMutation();
247
18.1k
    cow_ = nullptr;
248
18.1k
  }
yb::CowWriteLock<yb::master::PersistentRedisConfigInfo>::Commit()
Line
Count
Source
245
189
  void Commit() {
246
189
    cow_->CommitMutation();
247
189
    cow_ = nullptr;
248
189
  }
yb::CowWriteLock<yb::master::PersistentUDTypeInfo>::Commit()
Line
Count
Source
245
48
  void Commit() {
246
48
    cow_->CommitMutation();
247
48
    cow_ = nullptr;
248
48
  }
yb::CowWriteLock<yb::master::PersistentRoleInfo>::Commit()
Line
Count
Source
245
4.53k
  void Commit() {
246
4.53k
    cow_->CommitMutation();
247
4.53k
    cow_ = nullptr;
248
4.53k
  }
Unexecuted instantiation: yb::CowWriteLock<yb::master::PersistentSnapshotInfo>::Commit()
yb::CowWriteLock<yb::master::PersistentCDCStreamInfo>::Commit()
Line
Count
Source
245
5.31k
  void Commit() {
246
5.31k
    cow_->CommitMutation();
247
5.31k
    cow_ = nullptr;
248
5.31k
  }
yb::CowWriteLock<yb::master::PersistentUniverseReplicationInfo>::Commit()
Line
Count
Source
245
2
  void Commit() {
246
2
    cow_->CommitMutation();
247
2
    cow_ = nullptr;
248
2
  }
249
250
0
  void CommitOrWarn(const Status& status, const char* action) {
251
0
    if (!status.ok()) {
252
0
      LOG(WARNING) << "An error occurred while " << action << ": " << status;
253
0
      return;
254
0
    }
255
0
    Commit();
256
0
  }
Unexecuted instantiation: yb::CowWriteLock<yb::master::PersistentSnapshotInfo>::CommitOrWarn(yb::Status const&, char const*)
Unexecuted instantiation: yb::CowWriteLock<yb::master::PersistentUniverseReplicationInfo>::CommitOrWarn(yb::Status const&, char const*)
Unexecuted instantiation: yb::CowWriteLock<yb::master::PersistentClusterConfigInfo>::CommitOrWarn(yb::Status const&, char const*)
257
258
20.4M
  void Unlock() {
259
20.4M
    if (cow_) {
260
874k
      cow_->AbortMutation();
261
874k
      cow_ = nullptr;
262
874k
    }
263
20.4M
  }
yb::CowWriteLock<yb::master::PersistentTableInfo>::Unlock()
Line
Count
Source
258
18.9M
  void Unlock() {
259
18.9M
    if (cow_) {
260
874k
      cow_->AbortMutation();
261
874k
      cow_ = nullptr;
262
874k
    }
263
18.9M
  }
yb::CowWriteLock<yb::master::PersistentTabletInfo>::Unlock()
Line
Count
Source
258
1.44M
  void Unlock() {
259
1.44M
    if (cow_) {
260
75
      cow_->AbortMutation();
261
75
      cow_ = nullptr;
262
75
    }
263
1.44M
  }
yb::CowWriteLock<yb::master::PersistentClusterConfigInfo>::Unlock()
Line
Count
Source
258
3.94k
  void Unlock() {
259
3.94k
    if (cow_) {
260
1
      cow_->AbortMutation();
261
1
      cow_ = nullptr;
262
1
    }
263
3.94k
  }
yb::CowWriteLock<yb::master::PersistentSysConfigInfo>::Unlock()
Line
Count
Source
258
22.0k
  void Unlock() {
259
22.0k
    if (cow_) {
260
0
      cow_->AbortMutation();
261
0
      cow_ = nullptr;
262
0
    }
263
22.0k
  }
yb::CowWriteLock<yb::master::PersistentNamespaceInfo>::Unlock()
Line
Count
Source
258
18.2k
  void Unlock() {
259
18.2k
    if (cow_) {
260
14
      cow_->AbortMutation();
261
14
      cow_ = nullptr;
262
14
    }
263
18.2k
  }
yb::CowWriteLock<yb::master::PersistentRedisConfigInfo>::Unlock()
Line
Count
Source
258
189
  void Unlock() {
259
189
    if (cow_) {
260
0
      cow_->AbortMutation();
261
0
      cow_ = nullptr;
262
0
    }
263
189
  }
yb::CowWriteLock<yb::master::PersistentUDTypeInfo>::Unlock()
Line
Count
Source
258
48
  void Unlock() {
259
48
    if (cow_) {
260
0
      cow_->AbortMutation();
261
0
      cow_ = nullptr;
262
0
    }
263
48
  }
yb::CowWriteLock<yb::master::PersistentRoleInfo>::Unlock()
Line
Count
Source
258
4.54k
  void Unlock() {
259
4.54k
    if (cow_) {
260
13
      cow_->AbortMutation();
261
13
      cow_ = nullptr;
262
13
    }
263
4.54k
  }
Unexecuted instantiation: yb::CowWriteLock<yb::master::PersistentSnapshotInfo>::Unlock()
yb::CowWriteLock<yb::master::PersistentCDCStreamInfo>::Unlock()
Line
Count
Source
258
5.44k
  void Unlock() {
259
5.44k
    if (cow_) {
260
0
      cow_->AbortMutation();
261
0
      cow_ = nullptr;
262
0
    }
263
5.44k
  }
yb::CowWriteLock<yb::master::PersistentUniverseReplicationInfo>::Unlock()
Line
Count
Source
258
2
  void Unlock() {
259
2
    if (cow_) {
260
0
      cow_->AbortMutation();
261
0
      cow_ = nullptr;
262
0
    }
263
2
  }
264
265
  // Obtain the underlying data.
266
  // Returns the same data as mutable_data() (not the safe unchanging copy).
267
6.10M
  const State& data() const {
268
6.10M
    return cow_->dirty();
269
6.10M
  }
yb::CowWriteLock<yb::master::PersistentTableInfo>::data() const
Line
Count
Source
267
3.73M
  const State& data() const {
268
3.73M
    return cow_->dirty();
269
3.73M
  }
yb::CowWriteLock<yb::master::PersistentNamespaceInfo>::data() const
Line
Count
Source
267
7.23k
  const State& data() const {
268
7.23k
    return cow_->dirty();
269
7.23k
  }
yb::CowWriteLock<yb::master::PersistentTabletInfo>::data() const
Line
Count
Source
267
2.35M
  const State& data() const {
268
2.35M
    return cow_->dirty();
269
2.35M
  }
Unexecuted instantiation: yb::CowWriteLock<yb::master::PersistentUDTypeInfo>::data() const
yb::CowWriteLock<yb::master::PersistentSysConfigInfo>::data() const
Line
Count
Source
267
1.10k
  const State& data() const {
268
1.10k
    return cow_->dirty();
269
1.10k
  }
yb::CowWriteLock<yb::master::PersistentClusterConfigInfo>::data() const
Line
Count
Source
267
344
  const State& data() const {
268
344
    return cow_->dirty();
269
344
  }
yb::CowWriteLock<yb::master::PersistentRoleInfo>::data() const
Line
Count
Source
267
90
  const State& data() const {
268
90
    return cow_->dirty();
269
90
  }
Unexecuted instantiation: yb::CowWriteLock<yb::master::PersistentUniverseReplicationInfo>::data() const
yb::CowWriteLock<yb::master::PersistentCDCStreamInfo>::data() const
Line
Count
Source
267
5.18k
  const State& data() const {
268
5.18k
    return cow_->dirty();
269
5.18k
  }
Unexecuted instantiation: yb::CowWriteLock<yb::master::PersistentSnapshotInfo>::data() const
270
271
6.08M
  const State* operator->() const {
272
6.08M
    return &data();
273
6.08M
  }
yb::CowWriteLock<yb::master::PersistentTableInfo>::operator->() const
Line
Count
Source
271
3.72M
  const State* operator->() const {
272
3.72M
    return &data();
273
3.72M
  }
yb::CowWriteLock<yb::master::PersistentTabletInfo>::operator->() const
Line
Count
Source
271
2.35M
  const State* operator->() const {
272
2.35M
    return &data();
273
2.35M
  }
yb::CowWriteLock<yb::master::PersistentNamespaceInfo>::operator->() const
Line
Count
Source
271
7.23k
  const State* operator->() const {
272
7.23k
    return &data();
273
7.23k
  }
Unexecuted instantiation: yb::CowWriteLock<yb::master::PersistentUDTypeInfo>::operator->() const
yb::CowWriteLock<yb::master::PersistentSysConfigInfo>::operator->() const
Line
Count
Source
271
1.10k
  const State* operator->() const {
272
1.10k
    return &data();
273
1.10k
  }
yb::CowWriteLock<yb::master::PersistentClusterConfigInfo>::operator->() const
Line
Count
Source
271
344
  const State* operator->() const {
272
344
    return &data();
273
344
  }
yb::CowWriteLock<yb::master::PersistentRoleInfo>::operator->() const
Line
Count
Source
271
90
  const State* operator->() const {
272
90
    return &data();
273
90
  }
Unexecuted instantiation: yb::CowWriteLock<yb::master::PersistentUniverseReplicationInfo>::operator->() const
Unexecuted instantiation: yb::CowWriteLock<yb::master::PersistentSnapshotInfo>::operator->() const
yb::CowWriteLock<yb::master::PersistentCDCStreamInfo>::operator->() const
Line
Count
Source
271
5.18k
  const State* operator->() const {
272
5.18k
    return &data();
273
5.18k
  }
274
275
  // Obtain the mutable data.
276
1.22M
  State* mutable_data() const {
277
1.22M
    return cow_->mutable_dirty();
278
1.22M
  }
yb::CowWriteLock<yb::master::PersistentTableInfo>::mutable_data() const
Line
Count
Source
276
964k
  State* mutable_data() const {
277
964k
    return cow_->mutable_dirty();
278
964k
  }
yb::CowWriteLock<yb::master::PersistentTabletInfo>::mutable_data() const
Line
Count
Source
276
201k
  State* mutable_data() const {
277
201k
    return cow_->mutable_dirty();
278
201k
  }
yb::CowWriteLock<yb::master::PersistentClusterConfigInfo>::mutable_data() const
Line
Count
Source
276
4.16k
  State* mutable_data() const {
277
4.16k
    return cow_->mutable_dirty();
278
4.16k
  }
yb::CowWriteLock<yb::master::PersistentSysConfigInfo>::mutable_data() const
Line
Count
Source
276
28.0k
  State* mutable_data() const {
277
28.0k
    return cow_->mutable_dirty();
278
28.0k
  }
yb::CowWriteLock<yb::master::PersistentNamespaceInfo>::mutable_data() const
Line
Count
Source
276
20.2k
  State* mutable_data() const {
277
20.2k
    return cow_->mutable_dirty();
278
20.2k
  }
yb::CowWriteLock<yb::master::PersistentRedisConfigInfo>::mutable_data() const
Line
Count
Source
276
189
  State* mutable_data() const {
277
189
    return cow_->mutable_dirty();
278
189
  }
yb::CowWriteLock<yb::master::PersistentUDTypeInfo>::mutable_data() const
Line
Count
Source
276
3
  State* mutable_data() const {
277
3
    return cow_->mutable_dirty();
278
3
  }
yb::CowWriteLock<yb::master::PersistentRoleInfo>::mutable_data() const
Line
Count
Source
276
4.54k
  State* mutable_data() const {
277
4.54k
    return cow_->mutable_dirty();
278
4.54k
  }
Unexecuted instantiation: yb::CowWriteLock<yb::master::PersistentSnapshotInfo>::mutable_data() const
yb::CowWriteLock<yb::master::PersistentCDCStreamInfo>::mutable_data() const
Line
Count
Source
276
5.25k
  State* mutable_data() const {
277
5.25k
    return cow_->mutable_dirty();
278
5.25k
  }
yb::CowWriteLock<yb::master::PersistentUniverseReplicationInfo>::mutable_data() const
Line
Count
Source
276
2
  State* mutable_data() const {
277
2
    return cow_->mutable_dirty();
278
2
  }
279
280
  bool is_dirty() const {
281
    return cow_->is_dirty();
282
  }
283
284
16.3M
  bool locked() const {
285
16.3M
    return cow_ != nullptr;
286
16.3M
  }
287
288
18.8M
  ~CowWriteLock() {
289
18.8M
    Unlock();
290
18.8M
  }
yb::CowWriteLock<yb::master::PersistentTableInfo>::~CowWriteLock()
Line
Count
Source
288
17.8M
  ~CowWriteLock() {
289
17.8M
    Unlock();
290
17.8M
  }
yb::CowWriteLock<yb::master::PersistentTabletInfo>::~CowWriteLock()
Line
Count
Source
288
992k
  ~CowWriteLock() {
289
992k
    Unlock();
290
992k
  }
yb::CowWriteLock<yb::master::PersistentClusterConfigInfo>::~CowWriteLock()
Line
Count
Source
288
3.94k
  ~CowWriteLock() {
289
3.94k
    Unlock();
290
3.94k
  }
yb::CowWriteLock<yb::master::PersistentSysConfigInfo>::~CowWriteLock()
Line
Count
Source
288
22.0k
  ~CowWriteLock() {
289
22.0k
    Unlock();
290
22.0k
  }
yb::CowWriteLock<yb::master::PersistentNamespaceInfo>::~CowWriteLock()
Line
Count
Source
288
18.2k
  ~CowWriteLock() {
289
18.2k
    Unlock();
290
18.2k
  }
yb::CowWriteLock<yb::master::PersistentRedisConfigInfo>::~CowWriteLock()
Line
Count
Source
288
189
  ~CowWriteLock() {
289
189
    Unlock();
290
189
  }
yb::CowWriteLock<yb::master::PersistentUDTypeInfo>::~CowWriteLock()
Line
Count
Source
288
48
  ~CowWriteLock() {
289
48
    Unlock();
290
48
  }
yb::CowWriteLock<yb::master::PersistentRoleInfo>::~CowWriteLock()
Line
Count
Source
288
4.54k
  ~CowWriteLock() {
289
4.54k
    Unlock();
290
4.54k
  }
Unexecuted instantiation: yb::CowWriteLock<yb::master::PersistentSnapshotInfo>::~CowWriteLock()
yb::CowWriteLock<yb::master::PersistentCDCStreamInfo>::~CowWriteLock()
Line
Count
Source
288
5.44k
  ~CowWriteLock() {
289
5.44k
    Unlock();
290
5.44k
  }
yb::CowWriteLock<yb::master::PersistentUniverseReplicationInfo>::~CowWriteLock()
Line
Count
Source
288
2
  ~CowWriteLock() {
289
2
    Unlock();
290
2
  }
291
292
 private:
293
  CowObject<State>* cow_;
294
};
295
296
} // namespace yb
297
298
#endif /* YB_UTIL_COW_OBJECT_H */