【 TiDB 使用环境】线上 【 TiDB 版本】5.3 【遇到的问题】悲观锁事务遇到写冲突报错 【复现路径】偶发的update操作 【问题现象及影响】update执行失败导致事务回滚
报错日志: [2022/07/17 18:34:23.377 +08:00] [WARN] [session.go:721] [“can not retry txn”] [conn=5567757] [label=general] [error="[kv:9007]Write conflict, txnStartTS=434648924385705994, conflictStartTS=434648924385705995, conflictCommitTS=434648924385706003, key={tableID=89, indexID=5, indexValues={1717698306, 1850243498146817280,1850243106666971136, 637967337, }} primary={tableID=89, indexID=1, indexValues={110121367726914335, }} [try again later]"] [IsBatchInsert=false] [IsPessimistic=true] [InRestrictedSQL=false] [tidb_retry_limit=10] [tidb_disable_txn_auto_retry=true]
[2022/07/17 18:34:23.377 +08:00] [WARN] [session.go:737] [“commit failed”] [conn=5567757] [“finished txn”=“Txn{state=invalid}”] [error="[kv:9007]Write conflict,txnStartTS=434648924385705994, conflictStartTS=434648924385705995, conflictCommitTS=434648924385706003, key={tableID=89, indexID=5, indexValues={1717698306, 1850243498146817280, 1850243106666971136, 637967337, }} primary={tableID=89, indexID=1, indexValues={110121367726914335, }} [try again later]"]
[2022/07/17 18:34:23.377 +08:00] [WARN] [session.go:1583] [“run statement failed”] [conn=5567757] [schemaVersion=96] [error=“previous statement: /*DW: primary=true :/update trade_order_seller SET seller_feature = ‘{“incomeStatus”:0}’, delivery_no = ‘DN101005’ where seller_id = 44 and sub_order_no = ‘11’: [kv:9007]Write conflict, txnStartTS=434648924385705994, conflictStartTS=434648924385705995, conflictCommitTS=434648924385706003, key={tableID=89, indexID=5, indexValues={1717698306, 1850243498146817280, 1850243106666971136, 637967337, }} primary={tableID=89, indexID=1, indexValues={110121367726914335, }} [try again later]”] [session="{\ “currDBName”: “db”,\ “id”: ,\ “status”:0,\ “strictMode”: true,\ “user”: {\ “Username”: “db”,\ “Hostname”: “10.240.”,\ “CurrentUser”: false,\ "AuthUsername": “db”,\ “AuthHostname”: “%”\ }\ }"]
[2022/07/17 18:34:23.377 +08:00] [INFO] [conn.go:1069] [“command dispatched failed”] [conn=5567757] [connInfo=“id:5567757, addr:10.240.61.77:24602 status:0, collation:utf8_general_ci, user:dw_trade_order_seller_db”] [command=Query] [status=“inTxn:0, autocommit:0”] [sql=commit] [txn_mode=PESSIMISTIC] [err="[kv:9007]Write conflict, txnStartTS=434648924385705994, conflictStartTS=434648924385705995, conflictCommitTS=434648924385706003, key={tableID=89, indexID=5, indexValues={1717698306, 1850243498146817280, 1850243106666971136, 637967337, }} primary={tableID=89, indexID=1, indexValues={110121367726914335, }} [try again later]\ previousstatement: /DW: primary=true :DW/update trade_order_seller SET seller_feature = ‘{"incomeS}’, delivery_no = ‘DN10100’ where seller_id = 17 and sub_order_no = ‘11’"]