github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/storage/testdata/mvcc_histories/write_with_sequence (about) 1 # This test verifies that writes at sequence numbers equal to 2 # or below the sequence of an active intent verify that they agree with the 3 # intent's sequence history. If so, they become no-ops because writes are meant 4 # to be idempotent. If not, they throw errors. 5 6 # Check for "missing intent" error upon using old sequence number. 7 8 run error 9 with t=t k=k 10 txn_begin ts=1 11 txn_step seq=2 12 put v=v1 13 txn_step 14 put v=v2 15 txn_step seq=1 16 put v=v1 batched 17 ---- 18 put: batch after write is empty 19 >> at end: 20 txn: "t" meta={id=00000000 key="k" pri=0.00000000 epo=0 ts=0.000000001,0 min=0,0 seq=1} lock=true stat=PENDING rts=0.000000001,0 wto=false max=0,0 21 meta: "k"/0,0 -> txn={id=00000000 key="k" pri=0.00000000 epo=0 ts=0.000000001,0 min=0,0 seq=3} ts=0.000000001,0 del=false klen=12 vlen=7 ih={{2 /BYTES/v1}} 22 data: "k"/0.000000001,0 -> /BYTES/v2 23 error: (*withstack.withStack:) transaction 00000000-0000-0000-0000-000000000001 with sequence 3 missing an intent with lower sequence 1 24 25 run ok 26 txn_remove t=t 27 clear_range k=k end=-k 28 ---- 29 >> at end: 30 <no data> 31 32 # Same sequence as overwritten intent. 33 34 run ok 35 with t=t k=k 36 txn_begin ts=1 37 txn_step seq=2 38 put v=v1 39 txn_step 40 put v=v2 41 txn_step seq=2 42 put v=v1 batched 43 ---- 44 put: batch after write is empty 45 >> at end: 46 txn: "t" meta={id=00000000 key="k" pri=0.00000000 epo=0 ts=0.000000001,0 min=0,0 seq=2} lock=true stat=PENDING rts=0.000000001,0 wto=false max=0,0 47 meta: "k"/0,0 -> txn={id=00000000 key="k" pri=0.00000000 epo=0 ts=0.000000001,0 min=0,0 seq=3} ts=0.000000001,0 del=false klen=12 vlen=7 ih={{2 /BYTES/v1}} 48 data: "k"/0.000000001,0 -> /BYTES/v2 49 50 run ok 51 txn_remove t=t 52 clear_range k=k end=-k 53 ---- 54 >> at end: 55 <no data> 56 57 # Same sequence as overwritten intent, wrong value. 58 59 run error 60 with t=t k=k 61 txn_begin ts=1 62 txn_step seq=2 63 put v=v1 64 txn_step 65 put v=v2 66 txn_step seq=2 67 put v=v2 batched 68 ---- 69 put: batch after write is empty 70 >> at end: 71 txn: "t" meta={id=00000000 key="k" pri=0.00000000 epo=0 ts=0.000000001,0 min=0,0 seq=2} lock=true stat=PENDING rts=0.000000001,0 wto=false max=0,0 72 meta: "k"/0,0 -> txn={id=00000000 key="k" pri=0.00000000 epo=0 ts=0.000000001,0 min=0,0 seq=3} ts=0.000000001,0 del=false klen=12 vlen=7 ih={{2 /BYTES/v1}} 73 data: "k"/0.000000001,0 -> /BYTES/v2 74 error: (*withstack.withStack:) transaction 00000000-0000-0000-0000-000000000003 with sequence 2 has a different value [0 0 0 0 3 118 50] after recomputing from what was written: [0 0 0 0 3 118 49] 75 76 run ok 77 txn_remove t=t 78 clear_range k=k end=-k 79 ---- 80 >> at end: 81 <no data> 82 83 # Same sequence at active intent. 84 # The batch remains empty because the put is a no-op. 85 86 run ok 87 with t=t k=k 88 txn_begin ts=1 89 txn_step seq=2 90 put v=v1 91 txn_step 92 put v=v2 93 put v=v2 batched 94 ---- 95 put: batch after write is empty 96 >> at end: 97 txn: "t" meta={id=00000000 key="k" pri=0.00000000 epo=0 ts=0.000000001,0 min=0,0 seq=3} lock=true stat=PENDING rts=0.000000001,0 wto=false max=0,0 98 meta: "k"/0,0 -> txn={id=00000000 key="k" pri=0.00000000 epo=0 ts=0.000000001,0 min=0,0 seq=3} ts=0.000000001,0 del=false klen=12 vlen=7 ih={{2 /BYTES/v1}} 99 data: "k"/0.000000001,0 -> /BYTES/v2 100 101 102 run ok 103 txn_remove t=t 104 clear_range k=k end=-k 105 ---- 106 >> at end: 107 <no data> 108 109 # Same sequence at active intent, wrong value. 110 111 run error 112 with t=t k=k 113 txn_begin ts=1 114 txn_step seq=2 115 put v=v1 116 txn_step 117 put v=v2 118 put v=v3 batched 119 ---- 120 put: batch after write is empty 121 >> at end: 122 txn: "t" meta={id=00000000 key="k" pri=0.00000000 epo=0 ts=0.000000001,0 min=0,0 seq=3} lock=true stat=PENDING rts=0.000000001,0 wto=false max=0,0 123 meta: "k"/0,0 -> txn={id=00000000 key="k" pri=0.00000000 epo=0 ts=0.000000001,0 min=0,0 seq=3} ts=0.000000001,0 del=false klen=12 vlen=7 ih={{2 /BYTES/v1}} 124 data: "k"/0.000000001,0 -> /BYTES/v2 125 error: (*withstack.withStack:) transaction 00000000-0000-0000-0000-000000000005 with sequence 3 has a different value [0 0 0 0 3 118 51] after recomputing from what was written: [0 0 0 0 3 118 50] 126 127 128 run ok 129 txn_remove t=t 130 clear_range k=k end=-k 131 ---- 132 >> at end: 133 <no data> 134 135 # New seq. Verify that the batch for the final 136 # put is non-empty after the write. 137 138 run ok 139 with t=t k=k 140 txn_begin ts=1 141 txn_step seq=2 142 put v=v1 143 txn_step 144 put v=v2 145 txn_step 146 put v=v4 batched 147 ---- 148 put: batch after write is non-empty 149 >> at end: 150 txn: "t" meta={id=00000000 key="k" pri=0.00000000 epo=0 ts=0.000000001,0 min=0,0 seq=4} lock=true stat=PENDING rts=0.000000001,0 wto=false max=0,0 151 meta: "k"/0,0 -> txn={id=00000000 key="k" pri=0.00000000 epo=0 ts=0.000000001,0 min=0,0 seq=4} ts=0.000000001,0 del=false klen=12 vlen=7 ih={{2 /BYTES/v1}{3 /BYTES/v2}} 152 data: "k"/0.000000001,0 -> /BYTES/v4 153 154 # FIXME(knz): assert batching