Error Writing Conflict in Pessimistic Transaction Mode

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 悲观事务模式下报错写入冲突错误

| username: 努力努力再努力学习

[TiDB Usage Environment] Production
[TiDB Version] 5.3
[Encountered Problem] Pessimistic lock transaction encountered write conflict error
[Reproduction Path] Occasional update operation
[Problem Phenomenon and Impact] Update execution failure leading to transaction rollback

Error log:
[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’”]

| username: zzw6776 | Original post link

Hi, here to support. The issue I mentioned earlier hasn’t been resolved. We’re still getting Write conflict errors online (very infrequently, so we haven’t bothered with it) - -
The solution is to retry from the business side. Just bookmarking this post to see if there’s a solution.

| username: Hacker_Yv76YjBL | Original post link

This issue is caused by a bug in TiDB. You can upgrade to version 5.3.2 to resolve it;

| username: h5n1 | Original post link

Which versions are affected by this bug, and which versions have resolved this issue? Are there any other solutions besides upgrading?

| username: Hacker_Yv76YjBL | Original post link

There are no other solutions, you can only upgrade, which will affect version 5.3 and related versions.

| username: system | Original post link

This topic was automatically closed 1 minute after the last reply. No new replies are allowed.