xiaobaicai66695 opened a new issue, #1149:
URL: https://github.com/apache/incubator-seata-go/issues/1149
## Verification
- [x] I searched existing issues and pull requests.
- [x] I am willing to submit a focused fix.
## Problem
`XAConn.ShouldBeHeld` currently contains:
```go
func (c *XAConn) ShouldBeHeld() bool {
return c.res.IsShouldBeHeld() ||
(c.res.GetDbType().String() != "" && c.res.GetDbType() !=
types.DBTypeUnknown)
}
```
`DBType.String()` does not return an empty string for normal enum values (or
even for out-of-range values). Therefore the second term is effectively true
for every known database type. A resource that has already determined that its
database supports detached/cross-connection phase two is still treated as
hold-required.
The current behavior is approximately:
```go
return c.res.IsShouldBeHeld() || c.res.GetDbType() != types.DBTypeUnknown
```
This also differs from Seata Java. `ConnectionProxyXA.shouldBeHeld()` uses:
```java
return shouldBeHeld || StringUtils.isBlank(resource.getDbType());
```
That is conservative for an unknown/blank database type, while allowing a
known database whose resource capability says no hold is required to release
the phase-one connection. Java PR apache/seata#4765 introduced that behavior
for MySQL 8.0.29 cross-connection phase two.
## Expected behavior
- If the resource capability requires the original connection, return `true`.
- If the database type is unknown, retain the connection conservatively.
- If the database is known and its resource capability says detached phase
two is supported, return `false`.
- Cover all three combinations with table-driven tests.
## Compatibility note
For MySQL 8.0.29+, version alone is not a complete capability check: the
effective `@@session.xa_detach_on_prepare` value also matters. This issue is
about the reversed fallback predicate; capability probing can be improved
independently or in the same review if maintainers prefer.
## Related work
#1147 and #1148 cover a much broader set of XA retry-state,
connection-ownership, error-classification, and MySQL session-capability
changes. This issue intentionally tracks only the small `ShouldBeHeld`
predicate mismatch and its regression tests so it can be reviewed independently.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]