github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/concurrency/testdata/lock_table/lock_changes (about) 1 # Misc tests where there is a change in state made or attempted for a lock. 2 3 new-lock-table maxlocks=10000 4 ---- 5 6 # --------------------------------------------------------------------------------- 7 # Lock being released is held by a different transaction. 8 # --------------------------------------------------------------------------------- 9 10 new-txn txn=txn1 ts=10 epoch=0 seq=2 11 ---- 12 13 new-txn txn=txn2 ts=10 epoch=0 14 ---- 15 16 new-request r=req1 txn=txn1 ts=10 spans=w@a 17 ---- 18 19 acquire r=req1 k=a durability=u 20 ---- 21 global: num=1 22 lock: "a" 23 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [2] 24 local: num=0 25 26 release txn=txn2 span=a,c 27 ---- 28 global: num=1 29 lock: "a" 30 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [2] 31 local: num=0 32 33 # --------------------------------------------------------------------------------- 34 # Lock is reacquired at same epoch with lower timestamp. This is allowed, 35 # see TestMVCCHistories/put_out_of_order. The new sequence number is added 36 # but the timestamp is not regressed. 37 # --------------------------------------------------------------------------------- 38 39 new-txn txn=txn1 ts=8 epoch=0 seq=3 40 ---- 41 42 new-request r=req2 txn=txn1 ts=8 spans=w@a 43 ---- 44 45 acquire r=req2 k=a durability=u 46 ---- 47 global: num=1 48 lock: "a" 49 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: unrepl epoch: 0, seqs: [2, 3] 50 local: num=0 51 52 # --------------------------------------------------------------------------------- 53 # Lock is reacquired at same epoch with lower timestamp and different durability. 54 # The lock's timestamp is allowed to regress in this case, because it must never 55 # diverge from the replicated state machine. 56 # --------------------------------------------------------------------------------- 57 58 acquire r=req2 k=a durability=r 59 ---- 60 global: num=1 61 lock: "a" 62 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000008,0, info: repl epoch: 0, seqs: [3], unrepl epoch: 0, seqs: [2, 3] 63 local: num=0 64 65 # --------------------------------------------------------------------------------- 66 # Lock is reacquired at a different epoch. The old sequence numbers are discarded. 67 # --------------------------------------------------------------------------------- 68 69 new-txn txn=txn1 ts=10 epoch=1 seq=0 70 ---- 71 72 new-request r=req3 txn=txn1 ts=10 spans=w@a 73 ---- 74 75 acquire r=req3 k=a durability=u 76 ---- 77 global: num=1 78 lock: "a" 79 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000008,0, info: repl epoch: 0, seqs: [3], unrepl epoch: 1, seqs: [0] 80 local: num=0 81 82 # --------------------------------------------------------------------------------- 83 # Lock is reacquired at a different epoch with lower timestamp. This is allowed, 84 # see TestMVCCHistories/put_new_epoch_lower_timestamp. The old sequence numbers are 85 # discarded but the timestamp is not regressed. 86 # --------------------------------------------------------------------------------- 87 88 new-txn txn=txn1 ts=6 epoch=2 seq=0 89 ---- 90 91 new-request r=req4 txn=txn1 ts=6 spans=w@a 92 ---- 93 94 acquire r=req4 k=a durability=u 95 ---- 96 global: num=1 97 lock: "a" 98 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000008,0, info: repl epoch: 0, seqs: [3], unrepl epoch: 2, seqs: [0] 99 local: num=0 100 101 # --------------------------------------------------------------------------------- 102 # Reader waits until the timestamp of the lock is updated. 103 # --------------------------------------------------------------------------------- 104 105 new-request r=req5 txn=txn2 ts=12 spans=r@a 106 ---- 107 108 scan r=req5 109 ---- 110 start-waiting: true 111 112 guard-state r=req5 113 ---- 114 new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=read 115 116 print 117 ---- 118 global: num=1 119 lock: "a" 120 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000008,0, info: repl epoch: 0, seqs: [3], unrepl epoch: 2, seqs: [0] 121 waiting readers: 122 req: 1, txn: 00000000-0000-0000-0000-000000000002 123 distinguished req: 1 124 local: num=0 125 126 new-txn txn=txn1 ts=14 epoch=1 seq=1 127 ---- 128 129 new-request r=req6 txn=txn1 ts=14 spans=w@a 130 ---- 131 132 acquire r=req6 k=a durability=r 133 ---- 134 global: num=1 135 lock: "a" 136 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000010,0, info: repl epoch: 1, seqs: [1], unrepl epoch: 2, seqs: [0] 137 waiting readers: 138 req: 1, txn: 00000000-0000-0000-0000-000000000002 139 distinguished req: 1 140 local: num=0 141 142 guard-state r=req5 143 ---- 144 old: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=read 145 146 acquire r=req6 k=a durability=u 147 ---- 148 global: num=1 149 lock: "a" 150 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000014,0, info: repl epoch: 1, seqs: [1], unrepl epoch: 1, seqs: [0, 1] 151 local: num=0 152 153 guard-state r=req5 154 ---- 155 new: state=doneWaiting 156 157 158 # --------------------------------------------------------------------------------- 159 # Discovery of replicated lock that was already held as unreplicated. The waiters 160 # should be informed. It is unclear whether this can actually happen in the context 161 # that the lock table is used. 162 # --------------------------------------------------------------------------------- 163 164 new-request r=req7 txn=txn2 ts=17 spans=r@a 165 ---- 166 167 scan r=req7 168 ---- 169 start-waiting: true 170 171 guard-state r=req7 172 ---- 173 new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=read 174 175 add-discovered r=req7 k=a txn=txn1 176 ---- 177 global: num=1 178 lock: "a" 179 holder: txn: 00000000-0000-0000-0000-000000000001, ts: 0.000000014,0, info: repl epoch: 1, seqs: [1], unrepl epoch: 1, seqs: [0, 1] 180 waiting readers: 181 req: 2, txn: 00000000-0000-0000-0000-000000000002 182 distinguished req: 2 183 local: num=0 184 185 guard-state r=req7 186 ---- 187 new: state=waitForDistinguished txn=txn1 key="a" held=true guard-access=read