go runtime_error ai_generated true

sql: transaction has already been committed or rolled back

ID: go/sql-tx-committed-twice

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-08-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.10 active

Root Cause

对已提交或回滚的事务再次调用Commit或Rollback

generic

中文

对已提交或回滚的事务再次调用Commit或Rollback

Workarounds

  1. 90% success
    使用defer tx.Rollback()并检查Commit错误
  2. 85% success
    在Commit后设置标志位

Dead Ends

Common approaches that don't work:

  1. 70% fail

    状态管理混乱,后续操作不可预测

  2. 80% fail

    如果Commit成功,Rollback会返回此错误