在 Java 應用程式中,我經常看到這樣的錯誤:
org.springframework.r2dbc.UncategorizedR2dbcException: executeMany; SQL [select * from table1 where id=:id and column1 <> :a for update]; could not serialize access due to concurrent update; nested exception is io.r2dbc.postgresql.ExceptionFactory$PostgresqlTransientException: [40001] could not serialize access due to concurrent update
帶有查詢的事務select * from table1 where id=:id and column1 <> :a for update已回滾。事務隔離級別 - 可重復讀取。如何查看鎖定該行的內容?鎖定時間很短(毫秒)。
我在 Postgres 日志和應用程式日志中看不到任何有用的資訊。
uj5u.com熱心網友回復:
這里的問題不是并發鎖,而是并發資料修改。得到這個錯誤是完全正常的,如果你得到它,你應該簡單地重復失敗的事務。
除非您記錄所有 DML 陳述句,否則無法找出哪個并發事務更新了該行。
如果您遇到很多此類錯誤,您可能會考慮使用SELECT ... FOR NO KEY UPDATE.
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/526453.html
