github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/concurrency/lock/locking.pb.go (about) 1 // Code generated by protoc-gen-gogo. DO NOT EDIT. 2 // source: kv/kvserver/concurrency/lock/locking.proto 3 4 package lock 5 6 import proto "github.com/gogo/protobuf/proto" 7 import fmt "fmt" 8 import math "math" 9 10 // Reference imports to suppress errors if they are not otherwise used. 11 var _ = proto.Marshal 12 var _ = fmt.Errorf 13 var _ = math.Inf 14 15 // This is a compile-time assertion to ensure that this generated file 16 // is compatible with the proto package it is being compiled against. 17 // A compilation error at this line likely means your copy of the 18 // proto package needs to be updated. 19 const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package 20 21 // Strength represents the different locking modes that determine how key-values 22 // can be accessed by concurrent transactions. 23 // 24 // Locking modes apply to locks that are held with a per-key granularity. It is 25 // up to users of the key-value layer to decide on which keys to acquire locks 26 // for when imposing structure that can span multiple keys, such as SQL rows 27 // (see column families and secondary indexes). 28 // 29 // Locking modes have differing levels of strength, growing from "weakest" to 30 // "strongest" in the order that the variants are presented in the enumeration. 31 // The "stronger" a locking mode, the more protection it provides for the lock 32 // holder but the more restrictive it is to concurrent transactions attempting 33 // to access the same keys. 34 // 35 // Compatibility Matrix 36 // 37 // The following matrix presents the compatibility of locking strengths with one 38 // another. A cell with an X means that the two strengths are incompatible with 39 // each other and that they can not both be held on a given key by different 40 // transactions, concurrently. A cell without an X means that the two strengths 41 // are compatible with each other and that they can be held on a given key by 42 // different transactions, concurrently. 43 // 44 // +-----------+-----------+-----------+-----------+-----------+ 45 // | | None | Shared | Upgrade | Exclusive | 46 // +-----------+-----------+-----------+-----------+-----------+ 47 // | None | | | | X^† | 48 // +-----------+-----------+-----------+-----------+-----------+ 49 // | Shared | | | X | X | 50 // +-----------+-----------+-----------+-----------+-----------+ 51 // | Upgrade | | X | X | X | 52 // +-----------+-----------+-----------+-----------+-----------+ 53 // | Exclusive | X^† | X | X | X | 54 // +-----------+-----------+-----------+-----------+-----------+ 55 // 56 // [†] reads under optimistic concurrency control in CockroachDB only conflict 57 // with Exclusive locks if the read's timestamp is equal to or greater than the 58 // lock's timestamp. If the read's timestamp is below the Exclusive lock's 59 // timestamp then the two are compatible. 60 type Strength int32 61 62 const ( 63 // None represents the absence of a lock or the intention to acquire locks. 64 // It corresponds to the behavior of transactions performing key-value reads 65 // under optimistic concurrency control. No locks are acquired on the keys 66 // read by these requests when they evaluate. However, the reads do respect 67 // Exclusive locks already held by other transactions at timestamps equal to 68 // or less than their read timestamp. 69 // 70 // Optimistic concurrency control (OCC) can improve performance under some 71 // workloads because it avoids the need to perform any locking during reads. 72 // This can increase the amount of concurrency that the system can permit 73 // between ongoing transactions. However, OCC does mandate a read validation 74 // phase if/when transactions need to commit at a different timestamp than 75 // they performed all reads at. CockroachDB calls this a "read refresh", 76 // which is implemented by the txnSpanRefresher. If a read refresh fails due 77 // to new key-value writes that invalidate what was previously read, 78 // transactions are forced to restart. See the comment on txnSpanRefresher 79 // for more. 80 None Strength = 0 81 // Shared (S) locks are used by read-only operations and allow concurrent 82 // transactions to read under pessimistic concurrency control. Shared locks 83 // are compatible with each other but are not compatible with Upgrade or 84 // Exclusive locks. This means that multiple transactions can hold a Shared 85 // lock on the same key at the same time, but no other transaction can 86 // modify the key at the same time. A holder of a Shared lock on a key is 87 // only permitted to read the key's value while the lock is held. 88 // 89 // Share locks are currently unused, as all KV reads are currently performed 90 // optimistically (see None). 91 Shared Strength = 1 92 // Upgrade (U) locks are a hybrid of Shared and Exclusive locks which are 93 // used to prevent a common form of deadlock. When a transaction intends to 94 // modify existing KVs, it is often the case that it reads the KVs first and 95 // then attempts to modify them. Under pessimistic concurrency control, this 96 // would correspond to first acquiring a Shared lock on the keys and then 97 // converting the lock to an Exclusive lock when modifying the keys. If two 98 // transactions were to acquire the Shared lock initially and then attempt 99 // to update the keys concurrently, both transactions would get stuck 100 // waiting for the other to release its Shared lock and a deadlock would 101 // occur. To resolve the deadlock, one of the two transactions would need to 102 // be aborted. 103 // 104 // To avoid this potential deadlock problem, an Upgrade lock can be used in 105 // place of a Shared lock. Upgrade locks are not compatible with any other 106 // form of locking. As with Shared locks, the lock holder of a Shared lock 107 // on a key is only allowed to read from the key while the lock is held. 108 // This resolves the deadlock scenario presented above because only one of 109 // the transactions would have been able to acquire an Upgrade lock at a 110 // time while reading the initial state of the KVs. This means that the 111 // Shared-to-Exclusive lock upgrade would never need to wait on another 112 // transaction to release its locks. 113 // 114 // Under pure pessimistic concurrency control, an Upgrade lock is equivalent 115 // to an Exclusive lock. However, unlike with Exclusive locks, reads under 116 // optimistic concurrency control do not conflict with Upgrade locks. This 117 // is because a transaction can only hold an Upgrade lock on keys that it 118 // has not yet modified. This improves concurrency between read and write 119 // transactions compared to if the writing transaction had immediately 120 // acquired an Exclusive lock. 121 // 122 // The trade-off here is twofold. First, if the Upgrade lock holder does 123 // convert its lock on a key to an Exclusive lock after an optimistic read 124 // has observed the state of the key, the transaction that performed the 125 // optimistic read may be unable to perform a successful read refresh if it 126 // attempts to refresh to a timestamp at or past the timestamp of the lock 127 // conversion. Second, the optimistic reads permitted while the Upgrade lock 128 // is held will bump the timestamp cache. This may result in the Upgrade 129 // lock holder being forced to increase its write timestamp when converting 130 // to an Exclusive lock, which in turn may force it to restart if its read 131 // refresh fails. 132 Upgrade Strength = 2 133 // Exclusive (X) locks are used by read-write and read-only operations and 134 // provide a transaction with exclusive access to a key. When an Exclusive 135 // lock is held by a transaction on a given key, no other transaction can 136 // read from or write to that key. The lock holder is free to read from and 137 // write to the key as frequently as it would like. 138 Exclusive Strength = 3 139 ) 140 141 var Strength_name = map[int32]string{ 142 0: "None", 143 1: "Shared", 144 2: "Upgrade", 145 3: "Exclusive", 146 } 147 var Strength_value = map[string]int32{ 148 "None": 0, 149 "Shared": 1, 150 "Upgrade": 2, 151 "Exclusive": 3, 152 } 153 154 func (x Strength) String() string { 155 return proto.EnumName(Strength_name, int32(x)) 156 } 157 func (Strength) EnumDescriptor() ([]byte, []int) { 158 return fileDescriptor_locking_44b6aeb3856df467, []int{0} 159 } 160 161 // Durability represents the different durability properties of a lock acquired 162 // by a transaction. Durability levels provide varying degrees of survivability, 163 // often in exchange for the cost of lock acquisition. 164 type Durability int32 165 166 const ( 167 // Replicated locks are held on at least a quorum of Replicas in a Range. 168 // They are slower to acquire and release than Unreplicated locks because 169 // updating them requires both cross-node coordination and interaction with 170 // durable storage. In exchange, Replicated locks provide a guarantee of 171 // survivability across lease transfers, leaseholder crashes, and other 172 // forms of failure events. They will remain available as long as their 173 // Range remains available and they will never be lost. 174 Replicated Durability = 0 175 // Unreplicated locks are held only on a single Replica in a Range, which is 176 // typically the leaseholder. Unreplicated locks are very fast to acquire 177 // and release because they are held in memory or on fast local storage and 178 // require no cross-node coordination to update. In exchange, Unreplicated 179 // locks provide no guarantee of survivability across lease transfers or 180 // leaseholder crashes. They should therefore be thought of as best-effort 181 // and should not be relied upon for correctness. 182 Unreplicated Durability = 1 183 ) 184 185 var Durability_name = map[int32]string{ 186 0: "Replicated", 187 1: "Unreplicated", 188 } 189 var Durability_value = map[string]int32{ 190 "Replicated": 0, 191 "Unreplicated": 1, 192 } 193 194 func (x Durability) String() string { 195 return proto.EnumName(Durability_name, int32(x)) 196 } 197 func (Durability) EnumDescriptor() ([]byte, []int) { 198 return fileDescriptor_locking_44b6aeb3856df467, []int{1} 199 } 200 201 func init() { 202 proto.RegisterEnum("cockroach.kv.kvserver.concurrency.lock.Strength", Strength_name, Strength_value) 203 proto.RegisterEnum("cockroach.kv.kvserver.concurrency.lock.Durability", Durability_name, Durability_value) 204 } 205 206 func init() { 207 proto.RegisterFile("kv/kvserver/concurrency/lock/locking.proto", fileDescriptor_locking_44b6aeb3856df467) 208 } 209 210 var fileDescriptor_locking_44b6aeb3856df467 = []byte{ 211 // 251 bytes of a gzipped FileDescriptorProto 212 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0xce, 0x3f, 0x4e, 0xc3, 0x30, 213 0x14, 0xc7, 0x71, 0x1b, 0xaa, 0x52, 0x1e, 0x7f, 0x64, 0x59, 0x4c, 0x1d, 0x3c, 0x76, 0xc8, 0x90, 214 0x0c, 0x70, 0x82, 0x0a, 0x56, 0x06, 0xaa, 0x2e, 0x6c, 0xa9, 0xf3, 0x94, 0x58, 0x8e, 0xec, 0xe8, 215 0xd5, 0xb1, 0xe8, 0x0d, 0x18, 0xb9, 0x03, 0x97, 0xe9, 0xd8, 0xb1, 0x23, 0x24, 0x17, 0x41, 0x49, 216 0x85, 0x60, 0x79, 0x7a, 0xfa, 0x49, 0x1f, 0xe9, 0x0b, 0x89, 0x8d, 0x99, 0x8d, 0x5b, 0xa4, 0x88, 217 0x94, 0x69, 0xef, 0x74, 0x4b, 0x84, 0x4e, 0xef, 0xb2, 0xda, 0x6b, 0x3b, 0x1e, 0xe3, 0xca, 0xb4, 218 0x21, 0x1f, 0xbc, 0x5c, 0x68, 0xaf, 0x2d, 0xf9, 0x5c, 0x57, 0xa9, 0x8d, 0xe9, 0xaf, 0x4a, 0xff, 219 0xa9, 0x74, 0x00, 0xf3, 0xbb, 0xd2, 0x97, 0x7e, 0x24, 0xd9, 0xf0, 0x9d, 0x74, 0xb2, 0x84, 0xd9, 220 0x2a, 0x10, 0xba, 0x32, 0x54, 0x72, 0x06, 0x93, 0x67, 0xef, 0x50, 0x30, 0x09, 0x30, 0x5d, 0x55, 221 0x39, 0x61, 0x21, 0xb8, 0xbc, 0x82, 0x8b, 0x75, 0x53, 0x52, 0x5e, 0xa0, 0x38, 0x93, 0x37, 0x70, 222 0xf9, 0xf4, 0xa6, 0xeb, 0x76, 0x6b, 0x22, 0x8a, 0xf3, 0xf9, 0xe4, 0xfd, 0x53, 0xb1, 0xe4, 0x01, 223 0xe0, 0xb1, 0xa5, 0x7c, 0x63, 0x6a, 0x13, 0x76, 0xf2, 0x16, 0xe0, 0x05, 0x9b, 0xda, 0xe8, 0x3c, 224 0x60, 0x21, 0x98, 0x14, 0x70, 0xbd, 0x76, 0xf4, 0xb7, 0xf0, 0x93, 0x5a, 0x2e, 0xf6, 0xdf, 0x8a, 225 0xed, 0x3b, 0xc5, 0x0f, 0x9d, 0xe2, 0xc7, 0x4e, 0xf1, 0xaf, 0x4e, 0xf1, 0x8f, 0x5e, 0xb1, 0x43, 226 0xaf, 0xd8, 0xb1, 0x57, 0xec, 0x75, 0x32, 0x74, 0x6f, 0xa6, 0x63, 0xe8, 0xfd, 0x4f, 0x00, 0x00, 227 0x00, 0xff, 0xff, 0xc9, 0x20, 0xf8, 0x3c, 0x14, 0x01, 0x00, 0x00, 228 }