github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/storage/testdata/mvcc_histories/idempotent_transactions (about) 1 run ok 2 with t=a k=a 3 txn_begin ts=11 4 # Lay down an intent. 5 put v=first 6 # Lay down an intent again with no problem because we're idempotent. 7 put v=first 8 ---- 9 >> at end: 10 txn: "a" meta={id=00000000 key="a" pri=0.00000000 epo=0 ts=0.000000011,0 min=0,0 seq=0} lock=true stat=PENDING rts=0.000000011,0 wto=false max=0,0 11 meta: "a"/0,0 -> txn={id=00000000 key="a" pri=0.00000000 epo=0 ts=0.000000011,0 min=0,0 seq=0} ts=0.000000011,0 del=false klen=12 vlen=10 12 data: "a"/0.000000011,0 -> /BYTES/first 13 14 # Lay down an intent without increasing the sequence but with a different value. 15 # Expect an error. 16 run error 17 with t=a k=a 18 put v=second 19 ---- 20 >> at end: 21 meta: "a"/0,0 -> txn={id=00000000 key="a" pri=0.00000000 epo=0 ts=0.000000011,0 min=0,0 seq=0} ts=0.000000011,0 del=false klen=12 vlen=10 22 data: "a"/0.000000011,0 -> /BYTES/first 23 error: (*withstack.withStack:) transaction 00000000-0000-0000-0000-000000000001 with sequence 0 has a different value [0 0 0 0 3 115 101 99 111 110 100] after recomputing from what was written: [0 0 0 0 3 102 105 114 115 116] 24 25 run ok 26 with t=a k=a 27 # Lay down a second intent. 28 txn_step 29 put v=second 30 # Replay first intent without writing anything down. 31 txn_step n=-1 32 put v=first 33 # Check the intent meta is still there and its value. 34 txn_step 35 check_intent 36 ---- 37 meta: "a" -> txn={id=00000000 key="a" pri=0.00000000 epo=0 ts=0.000000011,0 min=0,0 seq=1} ts=0.000000011,0 del=false klen=12 vlen=11 ih={{0 /BYTES/first}} 38 >> at end: 39 txn: "a" meta={id=00000000 key="a" pri=0.00000000 epo=0 ts=0.000000011,0 min=0,0 seq=1} lock=true stat=PENDING rts=0.000000011,0 wto=false max=0,0 40 meta: "a"/0,0 -> txn={id=00000000 key="a" pri=0.00000000 epo=0 ts=0.000000011,0 min=0,0 seq=1} ts=0.000000011,0 del=false klen=12 vlen=11 ih={{0 /BYTES/first}} 41 data: "a"/0.000000011,0 -> /BYTES/second 42 43 run error 44 with t=a k=a 45 # Lay down an intent with a lower sequence number to see if it detects missing intents. 46 txn_step n=-2 47 put v=second 48 ---- 49 >> at end: 50 txn: "a" meta={id=00000000 key="a" pri=0.00000000 epo=0 ts=0.000000011,0 min=0,0 seq=-1} lock=true stat=PENDING rts=0.000000011,0 wto=false max=0,0 51 meta: "a"/0,0 -> txn={id=00000000 key="a" pri=0.00000000 epo=0 ts=0.000000011,0 min=0,0 seq=1} ts=0.000000011,0 del=false klen=12 vlen=11 ih={{0 /BYTES/first}} 52 data: "a"/0.000000011,0 -> /BYTES/second 53 error: (*withstack.withStack:) transaction 00000000-0000-0000-0000-000000000001 with sequence 1 missing an intent with lower sequence -1 54 55 run ok 56 with t=a k=i 57 # On a separate key, start an increment. 58 txn_step n=3 59 increment 60 # As long as the sequence is unchanged, replaying the increment doesn't increase the value. 61 increment 62 increment 63 increment 64 ---- 65 inc: current value = 1 66 inc: current value = 1 67 inc: current value = 1 68 inc: current value = 1 69 >> at end: 70 txn: "a" meta={id=00000000 key="a" pri=0.00000000 epo=0 ts=0.000000011,0 min=0,0 seq=2} lock=true stat=PENDING rts=0.000000011,0 wto=false max=0,0 71 meta: "a"/0,0 -> txn={id=00000000 key="a" pri=0.00000000 epo=0 ts=0.000000011,0 min=0,0 seq=1} ts=0.000000011,0 del=false klen=12 vlen=11 ih={{0 /BYTES/first}} 72 data: "a"/0.000000011,0 -> /BYTES/second 73 meta: "i"/0,0 -> txn={id=00000000 key="a" pri=0.00000000 epo=0 ts=0.000000011,0 min=0,0 seq=2} ts=0.000000011,0 del=false klen=12 vlen=6 74 data: "i"/0.000000011,0 -> /INT/1 75 76 run ok 77 with t=a k=i 78 # Increment again. 79 txn_step 80 increment 81 txn_step n=-1 82 # Replaying an older increment doesn't increase the value. 83 increment 84 increment 85 increment 86 ---- 87 inc: current value = 2 88 inc: current value = 1 89 inc: current value = 1 90 inc: current value = 1 91 >> at end: 92 txn: "a" meta={id=00000000 key="a" pri=0.00000000 epo=0 ts=0.000000011,0 min=0,0 seq=2} lock=true stat=PENDING rts=0.000000011,0 wto=false max=0,0 93 meta: "a"/0,0 -> txn={id=00000000 key="a" pri=0.00000000 epo=0 ts=0.000000011,0 min=0,0 seq=1} ts=0.000000011,0 del=false klen=12 vlen=11 ih={{0 /BYTES/first}} 94 data: "a"/0.000000011,0 -> /BYTES/second 95 meta: "i"/0,0 -> txn={id=00000000 key="a" pri=0.00000000 epo=0 ts=0.000000011,0 min=0,0 seq=3} ts=0.000000011,0 del=false klen=12 vlen=6 ih={{2 /INT/1}} 96 data: "i"/0.000000011,0 -> /INT/2