CAICAIIs commented on PR #1119:
URL: 
https://github.com/apache/incubator-seata-go/pull/1119#issuecomment-4408781991

   这个 PR 对应 #1116 里拆分路线的第一个 PR,目标是先让 Oracle XA 能在现在的 registry-based SQL XA 
框架里真实跑起来。也就是说,这个 PR 主要处理的是 Oracle XA 的基础接入和基础生命周期,而不是一次性把完整 Oracle XA 能力全部做完。
   
   这个 PR 包含的范围主要是:
   
   - 增加 `seata-xa-oracle` driver 接入;
   - 接入 Oracle Go driver;
   - 让 Oracle 能通过现有 XA driver / connector / resource 路径创建资源;
   - 基于 Oracle `DBMS_XA` 实现基础生命周期:`Start`、`End`、`Prepare`、`Commit`、`Rollback`;
   - 对当前不支持的能力给出明确错误,比如 `Recover`、`Forget`;
   - 修复 Oracle PR1 要能跑通所必需的通用 XA branch-status / held connection 处理;
   - 补充对应单测,以及需要真实 Oracle 环境才会跑的 integration test。
   
   实际代码部分情况:
   
   1. `pkg/datasource/sql/xa/oracle_xa_connection.go`
   
      这里是 Oracle `DBMS_XA` 生命周期的主要实现。里面比较关键的点是:
   
      - Oracle rollback 路径不能使用 `TMFAIL`,所以这里使用 `XA_END(..., TMSUCCESS)`;
      - `XA_PREPARE` 返回 `XA_RDONLY` 时,这个 branch 已经是终态成功,不应该再继续走二阶段 commit。
   
   2. `pkg/datasource/sql/driver.go`、`connector.go`、`db.go`
   
      这里主要是 Oracle driver 注册、资源创建,以及 Oracle resource id / db name 的处理。
   
   3. `pkg/datasource/sql/conn_xa.go`、`xa_resource_manager.go`
   
      这里是为了让 Oracle XA 基础生命周期能跑通所需的通用 XA 处理,包括 prepared connection 
的保留、二阶段连接清理、branch status 处理等。
   
   4. 测试文件
   
      - `pkg/datasource/sql/xa/oracle_xa_connection_test.go`
      - `pkg/datasource/sql/conn_xa_test.go`
      - `pkg/datasource/sql/xa_resource_manager_test.go`
      - `pkg/datasource/sql/oracle_xa_integration_test.go`
   
   我本地用 OrbStack 启了一个 Oracle Free 容器做真实验证:
   
   - 容器名:`seata-oracle-xa`
   - 镜像:`gvenzl/oracle-free:23-slim`
   - 连接方式:`ORACLE_XA_DSN='oracle://system:<password>@localhost:1521/FREEPDB1'`
   
   这里的 DSN 是本地测试容器的连接串,不是生产环境配置。
   
   验证命令:
   
   ```bash
   go test ./pkg/datasource/sql -count=1
   
   go test ./pkg/datasource/sql/xa ./pkg/datasource/sql/types 
./pkg/protocol/branch -count=1
   
   ORACLE_XA_DSN='oracle://system:OraclePwd123@localhost:1521/FREEPDB1' \
     go test ./pkg/datasource/sql \
     -run 
'TestOracleXAIntegration_SeataXAOracle(FirstAndSecondPhase|Rollback|ReadOnlySkipsSecondPhaseCommit)$'
 \
     -count=1 -v
   ```
   真实 Oracle 环境里验证通过的场景包括:
   - 一阶段 prepare 后二阶段 commit;
   - rollback;
   - readonly branch,也就是 XA_PREPARE 返回 XA_RDONLY 后跳过二阶段 commit。


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

Reply via email to