CAICAIIs opened a new pull request, #1061:
URL: https://github.com/apache/incubator-seata-go/pull/1061
## Summary
Fix XA mode implementation - implements `commitOnXA()` and `LockQuery()` as
reported in Issue #1060.
## Problem
The XA mode in seata-go had two critical unimplemented methods:
1. **`commitOnXA()`** - Empty implementation returning `nil`, causing XA
transactions to not execute properly
2. **`LockQuery()`** - Always returned `(false, nil)` without checking
global locks
This caused XA mode to be unusable in production environments.
## Solution
### 1. `pkg/datasource/sql/tx_xa.go`
Implements `commitOnXA()` to:
- Check if global transaction is open
- Execute XA END + XA PREPARE via `xaConn.Commit()`
- Report branch status to TC (Phase One)
### 2. `pkg/datasource/sql/xa_resource_manager.go`
Fixes `LockQuery()` to delegate to `rmRemoting.LockQuery()` for actual
global lock checking against TC
### 3. `pkg/datasource/sql/tx.go`
Adds `xaConn` field to `Tx` struct to support XA transaction coordination
### 4. `pkg/datasource/sql/conn_xa.go`
Sets `xaConn` reference in `BeginTx()` to enable transaction coordination
## How It Works
Seata XA uses two-phase commit:
Phase 1 (Application):
1. XAConn.BeginTx() → XA START + register branch
2. Execute business SQL
3. XATx.Commit() → commitOnXA() → XA END + XA PREPARE + report to TC
Phase 2 (TC):
4. TC decides to commit → calls BranchCommit()
5. BranchCommit() → XA COMMIT (final step)
This PR implements Phase 1. Phase 2 was already implemented in
`XAResourceManager.BranchCommit()`.
## Testing
- [x] Build passes: `go build ./...`
- [x] Vet passes: `go vet ./pkg/datasource/sql/...`
- [x] Tests pass: `go test ./pkg/datasource/sql/...`
## Related Issues
- Fixes #1060
```release-note
fix: implement XA mode commitOnXA() and LockQuery()
```
--
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]