go
runtime_error
ai_generated
true
sql: transaction has already been committed or rolled back
ID: go/sql-tx-committed-twice
80%Fix Rate
90%Confidence
0Evidence
2024-08-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.10 | active | — | — | — |
Root Cause
对已提交或回滚的事务再次调用Commit或Rollback
generic中文
对已提交或回滚的事务再次调用Commit或Rollback
Workarounds
-
90% success
使用defer tx.Rollback()并检查Commit错误
-
85% success
在Commit后设置标志位
Dead Ends
Common approaches that don't work:
-
70% fail
状态管理混乱,后续操作不可预测
-
80% fail
如果Commit成功,Rollback会返回此错误