postgresql 并发访问_postgresql 并发update下导致的死锁问题

批量打印操作中,由于并发触发更新postgresql表t_sc_receipt的打印次数,导致死锁问题。报错显示多个进程因ShareLock相互等待而形成死锁。分析认为可能是由于重复行锁或事务中的update操作引起。解决方案包括单条更新或去除重复数据。调整postgresql的autovacuum参数可能有助于避免类似死锁。
摘要由CSDN通过智能技术生成

一、死锁问题背景

在收据批量打印时,由于采用异步并发触发打印,同时触发打印(九千多数据 每隔50ms触发一次),导致了并发执行引起在接口更新打印次数时postgresql发生死锁问题,

具体报错如下:

1 ### The error occurred whilesetting parameters2 ### SQL: update t_sc_receipt set print_num = coalesce(print_num,0) + 1 ,print_ts=?

3 ### Cause: org.postgresql.util.PSQLException: ERROR: deadlock detected4 详细:Process 19540 waits for ShareLockon transaction 12520113; blocked by process 19539.5 Process 19539 waits for ShareLock on transaction 12520112; blocked by process 19540.6 建议:See server log forquery details.7 在位置:while rechecking updated tuple (329,3) in relation "t_sc_receipt"

8 ; SQL []; ERROR: deadlock detected9 详细:Process 19540 waits for ShareLock on transaction 12520113; blocked by process 19539.10 Process 19539 waits for ShareLock on transaction 12520112; blocked by process 19540.11 建议:See server log forquery details.12 在位置:while rechecking updated tuple (329,3) in relation "t_sc_receipt"; nested exception is org.postgresql.util.PSQLException: ERROR: deadlock detected13 详细:Process 19540 waits for ShareLock on transaction 12520113; blocked by process 19539.14 Process 19539 waits for ShareLock on transaction 12520112; blocked by process 19540.15 建议

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值