Repository navigation
fix(txn): preserve logger ownership during runtime retirement - #29921
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review 完成:当前七文件交付增量未发现已确认的正确性、设计或工程质量阻塞项,代码审查建议通过。 CI 仍在运行,未计入通过证据。
审查 head 98a23e78369fbb21d1abca39ad24544ee31c6217,base/merge-base a5b7d1e75fde337400d4f0c71932a0ebbaff0b30。全程单人,没有 subagent。最新 head 合入 main 后,本 PR 的七个交付文件与 223e91ebe75 完全一致;新增 main 依赖变化也已检查。
设计与职责归属
txnClient 已拥有 logger,普通 New 将这个依赖交给现有 operator 构造函数,与 NewWithSnapshot 的做法一致;RestartTxn 保留 operator 的依赖,CloneSnapshotOp 继承父 operator 的 logger。metadata 所需 runtime 读取仍在既有 shutdown gate 内,operator 构造不再重查可能已删除或替换的 registry。没有新状态机、fallback、存储、校验或执行路径,也没有把 admission 等待扩大到 lifecycle gate 中。被替代的构造阶段 lookup 已删除,全部私有调用方已迁移。
| Unhappy-path 审查 | 结论 |
|---|---|
| Q1:清理归属 | 未准入失败走现有 closeUnadmitted;准入后的创建失败由 abortCreatedTxn 清理。回归检查 Aborted/closed、SQL/terminal sealed、active/users/queue 为零及无 RPC。 |
| Q2:等待与关闭 | 真实 New 的 option 持有 op.mu 时,Close 仍可完成。测试失败清理会释放 barrier 并 join New;没有新增生产等待边。 |
| Q3:资源和性能 | 新增的生产行为是传递已有指针,并移除一次 registry lookup;没有新增容器、goroutine、同步或分配。没有量化吞吐/延迟提升的主张。 |
实现、测试、文档分别核对
生产代码为 2 文件 +3/-1;Go 测试为 3 文件 +136/-5;SQL/result 为 2 文件 +66/-0;没有文档或 CI 配置改动。事务测试的 retained、retired、replaced 和 public-New 分别约束对照、原 nil panic、错误 generation 和 Close 活性,使用确定性边界,未增加生产测试 hook。两个可编译旧行为负对照分别在 retired 分支触发原 panic、replaced 分支失败于 logger identity;公共 option-barrier 用例只证明构造内至准入前的关闭行为,不冒充原构造前 lookup 的独立复现。
SQL 回归复用已有 fixture:精确 CREATE UNIQUE expression 返回 nil plan/ErrNotSupported;inline、默认 ALTER、COPY ALTER 检查各自既有拒绝;普通 UNIQUE 成功。BVT 检查失败前后 schema、数据、索引、generated column 和 relation count 不变,以及普通 UNIQUE 对重复值的拒绝。旧的弱 inline 重复测试已被更强断言替代,原非 UNIQUE 功能索引覆盖保留。inline/ALTER 的 ErrInternal 属于既有错误分类,未伪称已统一为 ErrNotSupported。
评论与 issue 闭环
- #29875 的 P1:代码与回归闭环已完成。metadata 返回后删除或替换 runtime,operator 仍使用旧 client 持有的 logger,随后正常返回 ErrClientClosed。旧 PR 的 GitHub thread 当前仍是 unresolved;这是线程元数据状态。
- #29898:当前 main 的 deliberate unsupported guard 来自 #29472;本 PR 增加精确回归。符合 issue 允许的“不支持但明确报错”结果,不代表 v4.2.5 已 backport,也不代表支持 UNIQUE expression index。
- #29921 当前没有人工 review 或 inline finding;Qodo 留言只是服务暂停通知。此前 #29875 的 TP 性能证据边界仍保留,本 PR 没有相应性能承诺。
验证与证据适用范围
本轮在隔离的精确 head、Darwin arm64/Go 1.27.1、经过 provenance 校验的 native 产物上实际执行:
- 精确新增/直接影响的事务及 functional-index 用例,normal
-count=1:两包终态 PASS,23 个含子测试通过事件。 TestNewUsesClientLoggerAfterRuntimeRetirement,GOMAXPROCS=4 -race -count=100:PASS,四个场景各 100 次,500 个含父测试通过事件;测试包耗时 1.614s。次数按单次已测约 0.01s、30s 预算及上限 100 确定,没有重复整个包。- 原 owning-package normal/race、真实 New consumer、静态检查、两个旧行为负对照,以及 BVT 59/59 加同实例第二次 59/59 的证据,按本次不变的事务和 LOWER/VARCHAR 契约复用。合入 main 的 ENUM serial_extract、SET/LOAD 和 IVF/ISCP 变化不改变这里的输入/拒绝路径;本轮针对性测试补充了最新 head 的编译和执行证据。历史整包记录不冒充最新 head 的全量 CI。
- 最新 diff whitespace 检查通过,review worktree 无源码改动。远端 build、UT、SCA、coverage 仍在运行。
本评论记录审查结论,不改变旧 PR thread 状态,也不提交 PR 作者对自己的 APPROVE。
|
mo-bot work · Commit: Final review accepts the independent flaky diagnosis and unchanged candidate. Both cause issues, all four failure dispositions and the single bounded rerun are confirmed; CI recovery remains pending coordinator action. Cause issue: #29985 |
|
mo-bot review · Commit: Assessment: approve Reviewed the complete seven-file delta and affected owners/callers. The logger fix preserves client dependency ownership across runtime retirement without adding lifecycle state, synchronization or execution paths. The SQL regressions verify deliberate rejection and absence of side effects. No actionable defects remain. Model: Session: Validation:
Limitations:
|
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 98a23e78369fbb21d1abca39ad24544ee31c6217
Assessment: approve
Reviewed the complete seven-file delta and affected owners/callers. The logger fix preserves client dependency ownership across runtime retirement without adding lifecycle state, synchronization or execution paths. The SQL regressions verify deliberate rejection and absence of side effects. No actionable defects remain.
Model: gpt-6-astra / xhigh
Session: 01a12d8f-8e48-7622-ad17-b605f08450ce · slot 1 · generation 0
Validation:
-
Verified HEAD, merge-base, clean checkout and correspondence between change.patch and the complete Git delta. Whitespace check passed; recorded scope-validation.json.
-
Traced New, snapshot construction, restart, clone, admission failure, Close and runtime retirement. All constructor callers supply the existing logger; unadmitted cleanup remains local and avoids RPC.
-
Reviewed deterministic retained/retired/replaced-runtime and public-New tests, synchronization, failure cleanup, logger identity, closed/sealed state and admission accounting.
-
Traced CREATE, inline and ALTER UNIQUE-expression rejection. Reviewed typed planner assertions and SQL/result checks for unchanged schema, rows and metadata, session recovery, ordinary UNIQUE enforcement and teardown.
-
Reused frozen author evidence: exact-head focused normal tests and logger regression under GOMAXPROCS=4 -race -count=100; reported owning-package normal/race results, real New consumer, old-lookup negative controls and SQL BVT 59/59 twice.
-
Frozen head-associated CI reports successful shared build, Ubuntu UT, Linux arm64 SCA, coverage, proxy/compose BVT and CI Required. Reviewed every supplied comment; skipped checks and prior approval conclusions were not treated as validation.
Limitations:
-
No local native tests were rerun; execution evidence was reused from the frozen CI snapshot and author reports.
-
Reported targeted SQL BVT used a main-base binary with the unchanged SQL rejection guard; transaction validation used owning tests and the real consumer.
-
Linked-issue requirements were available through the frozen PR description and review, not standalone issue bodies. Approval covers current main behavior, not UNIQUE-expression support or a v4.2.5 backport.
-
No throughput or latency improvement was measured; source analysis establishes removal of one registry lookup without added synchronization or allocation.
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed 98a23e7 against merge-base a5b7d1e. No blocking finding.
The logger now follows the transaction client's dependency lifetime rather than the mutable service-runtime registry. All private-constructor callers pass the appropriate owned logger. Metadata capture remains under the lifecycle gate, construction stays outside it, and closed-client admission still rejects and seals an unadmitted operator without touching a replacement runtime generation or sending RPCs. This removes a lookup; it adds no new lock, cache, retry owner or per-operation allocation.
Unhappy-path closure for the changed construction boundary:
| Audit | Result |
|---|---|
| Q1 ownership | Before admission, closeUnadmitted owns rejection; after openTxn, the existing deferred abortCreatedTxn owner handles unsuccessful creation. Logger retention is GC-managed through the client/operator lifetime. |
| Q2 liveness | Close does not acquire the unadmitted operator's initialization mutex. Existing limiter/readiness/snapshot waits retain caller/client-close cancellation; no new wait is introduced. |
| Q3 boundedness/generation | No new accumulating state; retained, removed and replacement-runtime cases preserve the original logger and leave zero admission ownership on rejection. |
The deterministic tests cover the exact post-metadata retirement/replacement boundary and a public New interrupted by Close before admission. The UNIQUE-expression changes are regression coverage for an existing main guard, not implementation of expression UNIQUE indexes or a release backport. Their nil-plan/error-class assertions and before/after SQL metadata/data checks preserve the existing positive functional/ordinary UNIQUE controls.
Validation: reviewed all changed hunks and reused the reported complete owning normal/race tests, old-lookup negative controls, real consumer and twice-repeated normal-comparison SQL BVT. Current-head CI passes. I did not rerun native packages or a SQL service locally. The lifecycle audit shaped the ownership and generation checks above; no separate broader shutdown guarantee is claimed.
…29978) ## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes #29960 Fixes #29968 Related CI failure: #29921. ## What this PR does / why we need it: The TERM/PID fixture could acknowledge a signal before its trap returned. The sender then issued the next TERM too early and stalled waiting for an acknowledgment. A timeout's extra TERM could release the stall and misleadingly print `TERMS 200`. Acknowledgments now come from ordinary main-loop execution after the trap returns, with sequence/readiness assertions. A sender failure publishes its completion marker so the main process can join it and report the protocol error promptly. Logservice test listener candidates previously overlapped automatic client-port allocation. Probes closed their sockets before service startup; outbound traffic could occupy a candidate in that gap. On Linux, the existing allocator now excludes the configured inclusive `ip_local_port_range`, choosing the larger remaining interval while preserving its probes, process-local uniqueness and bounded attempts. The existing gossip topology and restart/convergence assertions remain exercised. TopN's unsupported-type regression used `T_any`, whose domainless NULL values now have a comparator. It now rejects `T_tuple` and positively exercises flat/constant all-NULL ANY keys across reset generations with source-row and mpool cleanup assertions. This adopts Lundomn's original #29975 commit `fbc1abc9f7bfdda6d907904d03ef34cb4793eac8`, preserving authorship, and closes partial batch-construction cleanup in a follow-up. The CI corrections are consolidated here as requested. ## Validation Linux/amd64, Go 1.27.1, CGo enabled, `matrixone_test`, bounded build/test concurrency. Matching native source/platform/profile provenance was verified before using the repository CGo test wrapper. - Full `optools`, `pkg/logservice`, and `pkg/sql/colexec/partition` packages pass in normal and race modes. - The three TERM/TopN regression tests pass with set coverage instrumentation; this is focused mode validation, not a full CI coverage-threshold verdict. - TERM regression passes 100 focused race repetitions; the gossip consumer including restart passes five focused race repetitions. - Modern PID and legacy fallback script controls complete all 200 signals. Mutating the same script to publish ACK inside the trap is rejected immediately with exit 98 in both controls. - Configured port-range, exhausted/invalid range, probe-error, occupied TCP/UDP, and socket cleanup controls pass. - Incremental repository lint reports zero issues; vet, gofmt and diff whitespace checks pass for the complete affected closure. - `gpt-6.1-sol` / `xhigh` produced the design and reviewed the complete final change. No unresolved material findings. The fix adds no sleeps, retry loops, reduced topology, or skipped coverage. Port probing still has an interval before the actual bind, so independent explicit binders can race it. Non-Linux uses a conservative candidate ceiling suitable for default macOS ranges; customized non-Linux ephemeral ranges are not inspected. BVT is not applicable to these CI/test-fixture contracts. Remote CI is pending after publication. --------- Co-authored-by: Lundomn <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #29898
Follow-up to merged #29875 and its remaining P1 review.
What this PR does / why we need it:
Preserve transaction-client dependency ownership during shutdown
Newsnapshots transaction metadata under the lifecycle gate, then constructs an operator outside the gate.Closecan complete and retire the service runtime between those steps. The operator previously looked up its logger through that runtime registry, causing a nil-pointer panic before closed-client admission could reject the transaction. Re-registering the same service ID could instead bind the old client to the replacement runtime's logger.Pass the logger already owned by the transaction client into the existing private operator constructor, matching snapshot construction. No additional lifecycle state, runtime fallback, synchronization or admission path is introduced. Close can still progress during construction and admission waits; unadmitted cleanup remains with the existing creation path. This removes a registry lookup rather than adding work.
Deterministic tests cover retained, retired and replaced runtimes after metadata capture, plus real public
Newinterrupted by Close before admission. They assert the original logger,ErrClientClosed, aborted/closed and sealed operator state, empty admission ownership and no RPC. Restoring only the old logger lookup in a compilable source overlay fails with the original nil panic and wrong-generation logger, respectively.Lock down the existing unsupported UNIQUE-expression contract (#29898)
The report concerns v4.2.5. Current main already rejects the exact
CREATE UNIQUE INDEX ... ((LOWER(email)))statement withErrNotSupported, through the guard introduced by #29472. This PR adds precise planner and SQL regressions; it does not implement UNIQUE expression indexes or establish a v4.2.5 backport.Planner coverage asserts a nil plan and the error class, checks inline and both ALTER variants' existing rejection, and preserves successful ordinary UNIQUE creation. The SQL fixture verifies unchanged schema, rows, index metadata, generated columns and relation count after rejection; same-session recovery; and ordinary UNIQUE enforcement with unchanged rows after a duplicate insert. Existing positive functional-index coverage is retained. A weaker duplicate inline test is replaced by the typed assertion.
Validation
On Darwin arm64, Go 1.27.1, with verified CPU-release native dependencies:
pkg/txn/clientandpkg/sql/planUT: PASS, normal and race,-count=1.Newconsumer:TestLockTableLocksAllPrePipelineTargetsPASS.gpt-6.1-sol / xhighdesign gates and final overall review: PASS.SQL verification used a fresh one-CN main-base binary; the SQL production guard is unchanged by this delivery. Transaction changes were validated directly through normal/race owning tests and the real consumer. Remote CI remains pending after publication.