You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "XiaoFeiASK (via GitHub)" <gi...@apache.org> on 2026/10/16 05:03:09 UTC
Re: [PR] fix(sql): prevent XA rollback nil pointer panic after cleanup [incubator-seata-go]
XiaoFeiASK commented on code in PR #1197:
URL: https://github.com/apache/incubator-seata-go/pull/1197#discussion_r4291090519
##########
pkg/datasource/sql/conn_xa.go:
##########
@@ -512,24 +517,33 @@ func (c *XAConn) Rollback(ctx context.Context) error {
log.Infof("XA branch already ended, continuing with rollback for xid: %s", c.txCtx.XID)
// Already ended, continue with rollback
} else {
- return c.rollbackErrorHandle()
+ rollbackErr = err
}
}
// Then perform XA rollback
- if c.XaRollback(ctx, c.xaBranchXid) != nil {
- c.cleanXABranchContext()
- return c.rollbackErrorHandle()
+ if err := c.XaRollback(ctx, c.xaBranchXid); err != nil {
+ // The branch may still be open; do not return this connection to the pool.
+ c.invalidate()
+ if rollbackErr != nil {
+ rollbackErr = errors.Join(rollbackErr, err)
+ } else {
+ rollbackErr = err
+ }
}
c.rollBacked = true
Review Comment:
`c.rollBacked = true` is set even when `XA ROLLBACK` fails, which causes subsequent `Rollback()` calls to skip the rollback logic and incorrectly return `nil`. The `rollBacked` flag should only be set when the rollback succeeds. Consider moving it into an `else` block.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org