This issue requires an assignee. Since you haven't specified one, we've assigned TestManager as the default assignee for this issue.


Welcome To openGauss Community
Hey @Rourou2285 , thanks for your contribution to the community.
Bot Usage Manual
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
Contact Guide
If you have any questions, please contact the SIG: Plugin ,
and any of the maintainers: @CarrotGo, @chendong76, @chenxiaobin19, @congzhou2603, @dodders, @hwworkholic, @jemappellehc, @libiao2024, @muyulinzhong, @quemingjian, @shenzheng4, @shirley_zhengx, @superlchf, @totaj, @wlff234, @wofanzheng, @ywzq1161327784 ,
and any of the committers: @dreamalloc, @huyinghao, @libiao2024, @wangfeihuo, @wmy_ld, @wuyuechuan, @xiong_xjun, @zhangxubo, @zhaojunv3z810 .


This issue requires an assignee. Since you haven't specified one, we've assigned TestManager as the default assignee for this issue.


验证结果:通过(PASS)
测例:SeaORM transactions 模块(examples 测例链接 https://atomgit.com/opengauss/examples/merge_requests/115)
| 用例 | 覆盖 | 结果 |
|---|---|---|
| TX1 | db.transaction() 提交 |
PASS |
| TX2 | 事务回滚 | PASS |
| TX3 | 连续 3 个事务 | PASS |
| TX4 | 原始 SQLx BEGIN/COMMIT |
PASS |
| TX5 | 原始 SQLx 回滚 | PASS |
| TX6 | 事务内结果集(EOF 路径)后提交 | PASS |
| TX7 | SAVEPOINT + ROLLBACK TO SAVEPOINT 后提交 |
PASS |
| TX8 | 事务内语句失败后,新事务可正常开启 | PASS |
| TX9 | SET autocommit=0 + COMMIT |
PASS |
| TX10 | 事务隔离:未提交不可见 / 提交后可见 | PASS |



问题描述
使用 SeaORM(底层为 SQLx 0.8 MySQL 驱动)连接 openGauss B 兼容库(dolphin,
DBCOMPATIBILITY 'B')执行db.transaction()时,返回BeginFailed,事务无法开始。复现方式
use sea_orm::{ConnectionTrait, DatabaseConnection, DbBackend, Statement, TransactionTrait}; db.transaction(|txn| { Box::pin(async move { // 任意 DML Ok::<_, sea_orm::DbErr>(()) }) }) .await.expect("transaction failed"); // BEGINFAILEDSTAR TRANSACTION之后 SQLx 事务管理器读取响应包的status_flags确认事务已开始,缺失SERVER_STATUS_IN_TRANS位则判定失败。根因
dolphin 在构造 MySQL OK/EOF 包的
status_flags字段时只设置了SERVER_STATUS_AUTOCOMMIT(及多语句时的SERVER_MORE_RESULTS_EXISTS),没有根据当前是否处于事务块设置SERVER_STATUS_IN_TRANS。因此客户端在START TRANSACTION后无法确认事务已真正开始。修复
在
contrib/dolphin/plugin_protocol/dqformat.cpp:send_network_ok_packet():当IsTransactionBlock()时给server_status或上SERVER_STATUS_IN_TRANS;sendServerStatus()(EOF 包路径复用):同样处理;#include "access/xact.h"。验证
db.transaction()返回BeginFailed。count=2,[PASS] transaction。结论
为符合 MySQL 协议语义,OK/EOF 包的状态位应反映事务状态。这是协议状态位补全,不影响其它路径。
关联 MR:基于
seaorm-fix-intrans分支提交。