github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/concurrency/testdata/lock_table/update (about) 1 new-lock-table maxlocks=10000 2 ---- 3 4 new-txn txn=txn1 ts=10,1 epoch=0 5 ---- 6 7 new-txn txn=txn2 ts=12,1 epoch=0 8 ---- 9 10 new-txn txn=txn3 ts=14,1 epoch=0 11 ---- 12 13 # ------------------------------------------------------------- 14 # Acquire a lock on key a at timestamp 10,1 15 # ------------------------------------------------------------- 16 17 new-request r=req1 txn=txn1 ts=10,1 spans=w@a 18 ---- 19 20 scan r=req1 21 ---- 22 start-waiting: false 23 24 guard-state r=req1 25 ---- 26 new: state=doneWaiting 27 28 acquire r=req1 k=a durability=u 29 ---- 30 global: num=1 31 lock: "a" 32 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 33 local: num=0 34 35 dequeue r=req1 36 ---- 37 global: num=1 38 lock: "a" 39 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 40 local: num=0 41 42 # ------------------------------------------------------------- 43 # Wait on this lock as: 44 # 1. transactional read-only request 45 # 2. transactional read-write request 46 # 3. non-transactional read-only request 47 # 4. non-transactional read-write request 48 # ------------------------------------------------------------- 49 50 new-request r=req2 txn=txn2 ts=12,1 spans=r@a 51 ---- 52 53 new-request r=req3 txn=txn3 ts=14,1 spans=w@a 54 ---- 55 56 new-request r=req4 txn=none ts=16,1 spans=r@a 57 ---- 58 59 new-request r=req5 txn=none ts=18,1 spans=w@a 60 ---- 61 62 scan r=req2 63 ---- 64 start-waiting: true 65 66 guard-state r=req2 67 ---- 68 new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=read 69 70 scan r=req3 71 ---- 72 start-waiting: true 73 74 guard-state r=req3 75 ---- 76 new: state=waitFor txn=txn1 key="a" held=true guard-access=write 77 78 scan r=req4 79 ---- 80 start-waiting: true 81 82 guard-state r=req4 83 ---- 84 new: state=waitFor txn=txn1 key="a" held=true guard-access=read 85 86 scan r=req5 87 ---- 88 start-waiting: true 89 90 guard-state r=req5 91 ---- 92 new: state=waitFor txn=txn1 key="a" held=true guard-access=write 93 94 print 95 ---- 96 global: num=1 97 lock: "a" 98 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,1, info: unrepl epoch: 0, seqs: [0] 99 waiting readers: 100 req: 4, txn: none 101 req: 2, txn: 00000000-0000-0000-0000-000000000002 102 queued writers: 103 active: true req: 3, txn: 00000000-0000-0000-0000-000000000003 104 active: true req: 5, txn: none 105 distinguished req: 2 106 local: num=0 107 108 # ------------------------------------------------------------- 109 # Update lock timestamp to 11,1 - nothing moves 110 # ------------------------------------------------------------- 111 112 update txn=txn1 ts=11,1 epoch=0 span=a 113 ---- 114 global: num=1 115 lock: "a" 116 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000011,1, info: unrepl epoch: 0, seqs: [0] 117 waiting readers: 118 req: 4, txn: none 119 req: 2, txn: 00000000-0000-0000-0000-000000000002 120 queued writers: 121 active: true req: 3, txn: 00000000-0000-0000-0000-000000000003 122 active: true req: 5, txn: none 123 distinguished req: 2 124 local: num=0 125 126 # ------------------------------------------------------------- 127 # Update lock timestamp to 13,1 - the transactional read at 128 # at timestamp 12,1 is allowed to proceed without acquire a 129 # reservation 130 # ------------------------------------------------------------- 131 132 update txn=txn1 ts=13,1 epoch=0 span=a 133 ---- 134 global: num=1 135 lock: "a" 136 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000013,1, info: unrepl epoch: 0, seqs: [0] 137 waiting readers: 138 req: 4, txn: none 139 queued writers: 140 active: true req: 3, txn: 00000000-0000-0000-0000-000000000003 141 active: true req: 5, txn: none 142 distinguished req: 4 143 local: num=0 144 145 guard-state r=req2 146 ---- 147 new: state=doneWaiting 148 149 scan r=req2 150 ---- 151 start-waiting: false 152 153 dequeue r=req2 154 ---- 155 global: num=1 156 lock: "a" 157 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000013,1, info: unrepl epoch: 0, seqs: [0] 158 waiting readers: 159 req: 4, txn: none 160 queued writers: 161 active: true req: 3, txn: 00000000-0000-0000-0000-000000000003 162 active: true req: 5, txn: none 163 distinguished req: 4 164 local: num=0 165 166 # ------------------------------------------------------------- 167 # Update lock timestamp to 10,1 - noop since lock is already at 168 # 13,1 169 # ------------------------------------------------------------- 170 171 update txn=txn1 ts=10,1 epoch=0 span=a 172 ---- 173 global: num=1 174 lock: "a" 175 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000013,1, info: unrepl epoch: 0, seqs: [0] 176 waiting readers: 177 req: 4, txn: none 178 queued writers: 179 active: true req: 3, txn: 00000000-0000-0000-0000-000000000003 180 active: true req: 5, txn: none 181 distinguished req: 4 182 local: num=0 183 184 # ------------------------------------------------------------- 185 # Update lock timestamp to 15,1 - nothing moves 186 # ------------------------------------------------------------- 187 188 update txn=txn1 ts=15,1 epoch=0 span=a 189 ---- 190 global: num=1 191 lock: "a" 192 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000015,1, info: unrepl epoch: 0, seqs: [0] 193 waiting readers: 194 req: 4, txn: none 195 queued writers: 196 active: true req: 3, txn: 00000000-0000-0000-0000-000000000003 197 active: true req: 5, txn: none 198 distinguished req: 4 199 local: num=0 200 201 # ------------------------------------------------------------- 202 # Update lock timestamp to 17,1 - the transactional read at 203 # at timestamp 16,1 is allowed to proceed without acquire a 204 # reservation 205 # ------------------------------------------------------------- 206 207 update txn=txn1 ts=17,1 epoch=0 span=a 208 ---- 209 global: num=1 210 lock: "a" 211 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000017,1, info: unrepl epoch: 0, seqs: [0] 212 queued writers: 213 active: true req: 3, txn: 00000000-0000-0000-0000-000000000003 214 active: true req: 5, txn: none 215 distinguished req: 3 216 local: num=0 217 218 guard-state r=req4 219 ---- 220 new: state=doneWaiting 221 222 scan r=req4 223 ---- 224 start-waiting: false 225 226 dequeue r=req4 227 ---- 228 global: num=1 229 lock: "a" 230 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000017,1, info: unrepl epoch: 0, seqs: [0] 231 queued writers: 232 active: true req: 3, txn: 00000000-0000-0000-0000-000000000003 233 active: true req: 5, txn: none 234 distinguished req: 3 235 local: num=0 236 237 # ------------------------------------------------------------- 238 # Update lock timestamp to 19,1 - nothing moves 239 # ------------------------------------------------------------- 240 241 update txn=txn1 ts=19,1 epoch=0 span=a 242 ---- 243 global: num=1 244 lock: "a" 245 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000019,1, info: unrepl epoch: 0, seqs: [0] 246 queued writers: 247 active: true req: 3, txn: 00000000-0000-0000-0000-000000000003 248 active: true req: 5, txn: none 249 distinguished req: 3 250 local: num=0 251 252 # ------------------------------------------------------------- 253 # Update lock epoch to 1 - the lock is dropped and the transactional 254 # write at timestamp 14,1 is allowed to acquire a reservation. Once 255 # it finishes, the non-transactional write is allowed to proceed 256 # without grabbing a reservation 257 # ------------------------------------------------------------- 258 259 update txn=txn1 ts=19,1 epoch=1 span=a 260 ---- 261 global: num=1 262 lock: "a" 263 res: req: 3, txn: 00000000-0000-0000-0000-000000000003, ts: 0.000000014,1, seq: 0 264 queued writers: 265 active: true req: 5, txn: none 266 distinguished req: 5 267 local: num=0 268 269 guard-state r=req3 270 ---- 271 new: state=doneWaiting 272 273 scan r=req3 274 ---- 275 start-waiting: false 276 277 guard-state r=req5 278 ---- 279 new: state=waitForDistinguished txn=txn3 key="a" held=false guard-access=write 280 281 dequeue r=req3 282 ---- 283 global: num=0 284 local: num=0 285 286 guard-state r=req5 287 ---- 288 new: state=doneWaiting 289 290 scan r=req5 291 ---- 292 start-waiting: false 293 294 dequeue r=req5 295 ---- 296 global: num=0 297 local: num=0 298 299 # ------------------------------------------------------------- 300 # Lock is held at multiple seqnums and then updated to ignore 301 # either a seqnum that is not in the held list or one that is 302 # in the list. When all the seqnums are ignored, the lock is 303 # released. Additionally, tests the effect of updates with older 304 # epochs -- they don't affect seqnums, but can advance ts. 305 # ------------------------------------------------------------- 306 307 new-lock-table maxlocks=10000 308 ---- 309 310 new-txn txn=txn1 ts=10 epoch=1 seq=1 311 ---- 312 313 new-request r=req1 txn=txn1 ts=10 spans=w@a 314 ---- 315 316 acquire r=req1 k=a durability=u 317 ---- 318 global: num=1 319 lock: "a" 320 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [1] 321 local: num=0 322 323 new-txn txn=txn1 ts=10 epoch=1 seq=5 324 ---- 325 326 new-request r=req2 txn=txn1 ts=10 spans=w@a 327 ---- 328 329 acquire r=req2 k=a durability=u 330 ---- 331 global: num=1 332 lock: "a" 333 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [1, 5] 334 local: num=0 335 336 new-txn txn=txn1 ts=10 epoch=1 seq=7 337 ---- 338 339 new-request r=req3 txn=txn1 ts=10 spans=w@a 340 ---- 341 342 acquire r=req3 k=a durability=u 343 ---- 344 global: num=1 345 lock: "a" 346 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [1, 5, 7] 347 local: num=0 348 349 new-txn txn=txn1 ts=10 epoch=1 seq=10 350 ---- 351 352 new-request r=req4 txn=txn1 ts=10 spans=w@a 353 ---- 354 355 acquire r=req4 k=a durability=u 356 ---- 357 global: num=1 358 lock: "a" 359 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [1, 5, 7, 10] 360 local: num=0 361 362 # No seqnum change since lock is not held at seqnum 3, 8, 9. 363 364 update txn=txn1 ts=10 epoch=1 span=a ignored-seqs=3,8-9 365 ---- 366 global: num=1 367 lock: "a" 368 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [1, 5, 7, 10] 369 local: num=0 370 371 # No change since update is using older epoch. 372 373 update txn=txn1 ts=10 epoch=0 span=a ignored-seqs=3,5-7 374 ---- 375 global: num=1 376 lock: "a" 377 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [1, 5, 7, 10] 378 local: num=0 379 380 update txn=txn1 ts=10 epoch=1 span=a ignored-seqs=3,5-7 381 ---- 382 global: num=1 383 lock: "a" 384 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [1, 10] 385 local: num=0 386 387 update txn=txn1 ts=10 epoch=1 span=a ignored-seqs=9-11 388 ---- 389 global: num=1 390 lock: "a" 391 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 1, seqs: [1] 392 local: num=0 393 394 # No seqnum change since update is using older epoch. But since the update is using 395 # a higher timestamp, the ts is advanced. 396 397 update txn=txn1 ts=15 epoch=0 span=a ignored-seqs=1 398 ---- 399 global: num=1 400 lock: "a" 401 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000015,0, info: unrepl epoch: 1, seqs: [1] 402 local: num=0 403 404 # No change, since seqnum 3 is not held. Note that the ts is not updated. 405 406 update txn=txn1 ts=10 epoch=1 span=a ignored-seqs=3 407 ---- 408 global: num=1 409 lock: "a" 410 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000015,0, info: unrepl epoch: 1, seqs: [1] 411 local: num=0 412 413 # Timestamp is updated again. 414 update txn=txn1 ts=16 epoch=1 span=a 415 ---- 416 global: num=1 417 lock: "a" 418 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000016,0, info: unrepl epoch: 1, seqs: [1] 419 local: num=0 420 421 # Seqnum 1 is also ignored, so the lock is released. Note that it does not 422 # matter that the update is using an older timestamp. 423 424 update txn=txn1 ts=10 epoch=1 span=a ignored-seqs=1 425 ---- 426 global: num=0 427 local: num=0