You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "MinatoWu (via GitHub)" <gi...@apache.org> on 2025/08/16 09:28:29 UTC

[PR] Fix active xa rollback failure and added error message judgment [incubator-seata-go]

MinatoWu opened a new pull request, #875:
URL: https://github.com/apache/incubator-seata-go/pull/875

   <!--  Thanks for sending a pull request! 
   -->
   
   **What this PR does**:
   with :https://github.com/apache/incubator-seata-go/pull/672   Fix active xa rollback failure and added error message judgment
   **Which issue(s) this PR fixes**:
   <!--
   *Automatically closes linked issue when PR is merged.
   Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
   _If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
   -->
   Fixes #
   #708 
   **Special notes for your reviewer**:
   
   **Does this PR introduce a user-facing change?**:
   <!--
   If no, just write "NONE" in the release-note block below.
   If yes, a release note is required:
   Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
   -->
   ```release-note
   
   ```


-- 
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


Re: [PR] Fix active xa rollback failure and added error message judgment [incubator-seata-go]

Posted by "MinatoWu (via GitHub)" <gi...@apache.org>.
MinatoWu commented on PR #875:
URL: https://github.com/apache/incubator-seata-go/pull/875#issuecomment-3263937625

   > If we can improve the unit test coverage, that would be even better.
   
   done


-- 
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


Re: [PR] Fix active xa rollback failure and added error message judgment [incubator-seata-go]

Posted by "AlexStocks (via GitHub)" <gi...@apache.org>.
AlexStocks merged PR #875:
URL: https://github.com/apache/incubator-seata-go/pull/875


-- 
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


Re: [PR] Fix active xa rollback failure and added error message judgment [incubator-seata-go]

Posted by "MinatoWu (via GitHub)" <gi...@apache.org>.
MinatoWu commented on code in PR #875:
URL: https://github.com/apache/incubator-seata-go/pull/875#discussion_r2329148793


##########
pkg/datasource/sql/conn_xa.go:
##########
@@ -313,6 +325,7 @@ func (c *XAConn) Rollback(ctx context.Context) error {
 			c.cleanXABranchContext()
 			return fmt.Errorf("failed to report XA branch commit-failure on xid:%s err:%w", c.txCtx.XID, err)
 		}
+		c.rollBacked = true

Review Comment:
   Only two rollbacks are successfully set to true, and no modification is required here
   



-- 
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


Re: [PR] Fix active xa rollback failure and added error message judgment [incubator-seata-go]

Posted by "MinatoWu (via GitHub)" <gi...@apache.org>.
MinatoWu commented on code in PR #875:
URL: https://github.com/apache/incubator-seata-go/pull/875#discussion_r2303456626


##########
pkg/datasource/sql/conn_xa.go:
##########
@@ -404,3 +415,17 @@ func (c *XAConn) XaRollback(ctx context.Context, xaXid XAXid) error {
 	c.releaseIfNecessary()
 	return err
 }
+
+// isXAER_RMFAILAlreadyEnded checks if the XAER_RMFAIL error indicates the XA branch is already ended
+func isXAER_RMFAILAlreadyEnded(err error) bool {
+	if err == nil {
+		return false
+	}
+
+	errMsg := err.Error()
+	// Check for XAER_RMFAIL error with "already ended" message
+	if strings.Contains(errMsg, "XAER_RMFAIL") && strings.Contains(errMsg, "already ended") {

Review Comment:
   Okay, I'm trying to reproduce him and add constant Err code  judgment. 



-- 
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


Re: [PR] Fix active xa rollback failure and added error message judgment [incubator-seata-go]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #875:
URL: https://github.com/apache/incubator-seata-go/pull/875#issuecomment-3193536260

   ## [Codecov](https://app.codecov.io/gh/apache/incubator-seata-go/pull/875?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `53.84615%` with `6 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 38.05%. Comparing base ([`c4c82f7`](https://app.codecov.io/gh/apache/incubator-seata-go/commit/c4c82f79bdc54951a0ea15bf2554492078ede7e5?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`89f043f`](https://app.codecov.io/gh/apache/incubator-seata-go/commit/89f043fd98196a97af314231f472bd38e4beebc0?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/incubator-seata-go/pull/875?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [pkg/datasource/sql/conn\_xa.go](https://app.codecov.io/gh/apache/incubator-seata-go/pull/875?src=pr&el=tree&filepath=pkg%2Fdatasource%2Fsql%2Fconn_xa.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGtnL2RhdGFzb3VyY2Uvc3FsL2Nvbm5feGEuZ28=) | 53.84% | [6 Missing :warning: ](https://app.codecov.io/gh/apache/incubator-seata-go/pull/875?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master     #875      +/-   ##
   ==========================================
   + Coverage   38.02%   38.05%   +0.02%     
   ==========================================
     Files         186      186              
     Lines       11232    11243      +11     
   ==========================================
   + Hits         4271     4278       +7     
   - Misses       6537     6541       +4     
     Partials      424      424              
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/incubator-seata-go/pull/875?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
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


Re: [PR] Fix active xa rollback failure and added error message judgment [incubator-seata-go]

Posted by "Code-Fight (via GitHub)" <gi...@apache.org>.
Code-Fight commented on PR #875:
URL: https://github.com/apache/incubator-seata-go/pull/875#issuecomment-3238976014

   If we can improve the unit test coverage, that would be even better.


-- 
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


Re: [PR] Fix active xa rollback failure and added error message judgment [incubator-seata-go]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #875:
URL: https://github.com/apache/incubator-seata-go/pull/875#discussion_r2328966364


##########
pkg/datasource/sql/conn_xa.go:
##########
@@ -313,6 +325,7 @@ func (c *XAConn) Rollback(ctx context.Context) error {
 			c.cleanXABranchContext()
 			return fmt.Errorf("failed to report XA branch commit-failure on xid:%s err:%w", c.txCtx.XID, err)
 		}
+		c.rollBacked = true

Review Comment:
   The `c.rollBacked = true` line is placed inside the `if !c.rollBacked` block but after the XA rollback operation. If the XA rollback fails and returns an error, this line will not be executed, but the method will still return an error. This could leave the connection in an inconsistent state where subsequent rollback attempts might behave unexpectedly.



##########
pkg/datasource/sql/conn_xa.go:
##########
@@ -404,3 +417,19 @@ func (c *XAConn) XaRollback(ctx context.Context, xaXid XAXid) error {
 	c.releaseIfNecessary()
 	return err
 }
+
+// isXAER_RMFAILAlreadyEnded checks if the XAER_RMFAIL error indicates the XA branch is already ended
+// expected error: Error 1399 (XAE07): XAER_RMFAIL: The command cannot be executed when global transaction is in the  IDLE state
+func isXAER_RMFAILAlreadyEnded(err error) bool {
+	if err == nil {
+		return false
+	}
+	if mysqlErr, ok := err.(*mysql.MySQLError); ok {
+		if mysqlErr.Number == types.ErrCodeXAER_RMFAIL_IDLE {
+			return strings.Contains(mysqlErr.Message, "IDLE state") || strings.Contains(mysqlErr.Message, "already ended")
+		}
+	}
+	//todo other DB error

Review Comment:
   The comment should be properly formatted with a space after '//' and proper capitalization: '// TODO: handle other DB errors'.
   ```suggestion
   	// TODO: handle other DB errors
   ```



##########
pkg/datasource/sql/conn_xa.go:
##########
@@ -404,3 +417,19 @@ func (c *XAConn) XaRollback(ctx context.Context, xaXid XAXid) error {
 	c.releaseIfNecessary()
 	return err
 }
+
+// isXAER_RMFAILAlreadyEnded checks if the XAER_RMFAIL error indicates the XA branch is already ended
+// expected error: Error 1399 (XAE07): XAER_RMFAIL: The command cannot be executed when global transaction is in the  IDLE state

Review Comment:
   There's an extra space in 'the  IDLE state' - should be 'the IDLE state' with only one space.
   ```suggestion
   // expected error: Error 1399 (XAE07): XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
   ```



-- 
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


Re: [PR] Fix active xa rollback failure and added error message judgment [incubator-seata-go]

Posted by "Code-Fight (via GitHub)" <gi...@apache.org>.
Code-Fight commented on code in PR #875:
URL: https://github.com/apache/incubator-seata-go/pull/875#discussion_r2282770388


##########
pkg/datasource/sql/conn_xa.go:
##########
@@ -404,3 +415,17 @@ func (c *XAConn) XaRollback(ctx context.Context, xaXid XAXid) error {
 	c.releaseIfNecessary()
 	return err
 }
+
+// isXAER_RMFAILAlreadyEnded checks if the XAER_RMFAIL error indicates the XA branch is already ended
+func isXAER_RMFAILAlreadyEnded(err error) bool {
+	if err == nil {
+		return false
+	}
+
+	errMsg := err.Error()
+	// Check for XAER_RMFAIL error with "already ended" message
+	if strings.Contains(errMsg, "XAER_RMFAIL") && strings.Contains(errMsg, "already ended") {

Review Comment:
   The string matching approach in isXAER_RMFAILAlreadyEnded() is fragile
   Consider using error codes or types instead of string matching
   Different database vendors might format error messages differently
   



-- 
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