Repository navigation
fix(logservice): preserve Dragonboat constructor unwind and cleanup - #29649
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 of 79267885385d449cd96119c2e71a20ca44ff9c26 against base / merge-base ffe8362614b8bde8fe0fa249ee472edc87bf256a: PASS — no blocking findings; approval-quality conclusion. No subagents were used. This is submitted as a COMMENT review because the authenticated GitHub account is also the PR author and cannot self-approve.
Design and responsibility. This is a focused lifecycle bug repair, exempt from the feature/major-refactor design-document gate. Reviewed every MatrixOne hunk and all six files in the actual dependency delta from 37eeca713c36 to abc3d2fce5a6, then traced LOG construction/retry/close and the dependency owners. The repair belongs in Dragonboat, not a MatrixOne recovery wrapper: callers cannot recover a panic already swallowed by NewNodeHost or release its hidden directory locks. Success-based local constructor guards hand ownership off only after successful initialization; partial hosts and published hosts use one destruction path. The old recovery/type-filtering and duplicated error-branch cleanup are removed. Public Close keeps its existing fatal policy for returned cleanup errors; constructor rollback logs secondary errors without replacing the primary failure. Transport similarly retains returned-child ownership until handoff, then stops/joins the receiver before cleaning its chunk sink. No parallel lifecycle framework, compatibility fallback or new steady-state state is introduced.
Delivery and comment closure. Actual replace: github.com/matrixorigin/dragonboat/v4 v4.0.0-20261006150417-abc3d2fce5a6. Downloaded Origin.Hash and both go.sum entries match that pin. Upstream dragonboat #18 is merged: its squash commit 18a1f46a2ea6 and the pinned commit have the identical tree 8c5753f76775569acab4d9e1002917c0e036406f. Repinning is optional provenance housekeeping, not a correctness prerequisite. There are no prior human reviews/inline findings to leave unresolved; the sole bot pause notice is not a code finding. #29641's ordinary-error, panic-identity and Goexit ownership contracts are covered. Its Fixes link can close the issue when this integration merges; upstream merge alone does not update MatrixOne main.
Independent black-/white-box challenge. The delivered MatrixOne regression was copied into a disposable public-API consumer module (only its package name changed; dependency graph follows this PR). Under race, the head pin passes all four named cells. With the verified base pin, the same test passes the ordinary-error control and fails string panic, error-panic identity and Goexit lock cleanup. Thus the oracle discriminates the original defects, rather than merely restating the new implementation.
Reviewer-only challenges additionally inject failure after LogDB return in BinaryFormat (panic and Goexit), during Transport.Start (panic), and during the final transport Name diagnostic after startup workers are created. Every cell preserves abrupt termination/panic identity, closes acquired LogDB/transport/locks exactly once, and immediately reopens and closes the same real StrictMem-backed directory. These probes are outside tracked source. Existing dependency tests independently cover successful handoff, secondary Close errors, valid snapshot chunk delivery during receiver drain, terminal .receiving cleanup, and impossible worker-count rejection before acquisition. Snapshot/close limits match the actual reflect.Select arrays (+6/+2 control cases), including exact accepted boundaries and overflow, without allocating tens of thousands of workers in tests.
| Audit | Closure verified |
|---|---|
| Q1 ownership | Env locks, acquired LogDB, returned transport child, engine and listener workers reach the existing destructor; nested rollback does not double-close the unpublished transport. |
| Q2 waits | NodeHost/engine stoppers join their workers; default TCP listener stop closes admitted connections and joins receivers before the chunk sink is destroyed. Same-directory reopen confirms the prior generation releases its lock before return/unwind. |
| Q3 boundedness | No new queue/cache/background accumulation; pool validation rejects lengths impossible for reflect.Select. This hard limit is not an affordability guarantee for extreme configurations. |
Evidence and limits. Local Go 1.26.4 / Darwin arm64 uses the downloaded dependency's unchanged production and committed test sources with validation-only manifests selecting this PR's dependency graph. Full owning packages config/root/transport pass normal (1.030s / 95.479s / 17.021s) and race (1.199s / 145.242s / 17.847s), terminal exit 0. Each of five exact lifecycle tests (early host unwind, late host/transport unwind, transport unwind, receiver drain, reviewer post-acquisition/reopen) separately passes -race -count=100; named test events confirm all 100 executions per test. Focused selection also includes nil-partial-close and config boundaries. go vet of the three owning packages and MatrixOne git diff --check pass.
Reused and verified exact-head CI 37486960204, not merely the PR-body claim: checkout SHA is this head, Linux/amd64 Go 1.26.4, the race-test report records full pkg/logservice PASS (117.16s), all four constructor subtests PASS (parent 0.01s), and actual LOG creation/close and retry tests PASS. SCA and both executed BVT topologies are green; skipped jobs are not counted as passes. The attempted local MO wrapper rejected unavailable matching native prerequisites before test execution and is not counted as validation. An initial dependency invocation inherited stale ambient MO linker flags; that loader failure was corrected by neutral dependency build flags, and all reported local passes are the completed corrected runs.
Performance/test quality/change cost. Production work added is limited to config validation, constructor guards and shutdown ordering; no Raft message/proposal hot path changes. There is no measured throughput-regression claim or new workload-dependent benchmark requirement here. Tests use existing factories, NOOP transport and StrictMem fixtures, explicit goroutine completion, minimum snapshot data and exact error/destruction oracles. They bind no ports in the new regressions and use no sleeps or production test hooks; the owning-suite and existing real LOG consumer coverage complement them. Keeping a small MatrixOne-side public-constructor regression is a dependency-pin acceptance fence, while richer internal transport/worker cases stay with their owner upstream.
MatrixOne production Go: 0; manifests +3/-3; tests +118/-1 (net +117); docs 0. Included dependency production +49/-27 (net +22), tests +630/-0, docs 0. Those test lines cover distinct acquisition phases, handoff, cleanup-error precedence, receiver-drain ordering and exact configuration boundaries; they are not exempt from review merely because they are tests. API/wire/persisted formats and normal runtime defaults are unchanged; no new SQL-result, authorization or migration contract requires a separate SQL BVT. Arbitrary factory-internal resources never returned, fatal/nonterminating destructors, and nonterminating custom callbacks retain their existing responsibility contracts; this review does not claim a new generic guarantee for them.
Tracked MatrixOne source remains unchanged. Ready for another maintainer's formal approval; no additional functional changes or mandatory repin requested.
…29667) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Part of issue #29661: direct integer bindings compared with a native DECIMAL column. This PR does not close the direct TEXT or explicit DOUBLE/INT64 pruning gaps recorded there. ## What this PR does / why we need it: A prepared INT64 comparison against DECIMAL(18,2) widens the stored column to DECIMAL(21,2), losing native ZoneMap pruning even when the actual binding fits exactly. Clean current Main reads four blocks for the existing 32,768-row probe where the equivalent literal reads one block; results are correct. Before generic comparison binding, admit only direct SELECT integer-parameter/native-DECIMAL-column comparisons whose current value fits the unchanged column domain. Reuse the existing exact-domain algorithm and existing per-EXECUTE diagnostic/cache guards. Keep executable parameter references and wider-domain fallback; no new cache, worker, state owner, storage or protocol change. Guard the exact transport spelling before cached reuse: integer-to-DECIMAL conversion alone does not enforce declared precision. This prevents a later out-of-range value from reusing the narrowed plan. Safe plans remain cacheable; wide fallbacks cannot replace them. Literal, TEXT, explicit DOUBLE, DML and column-to-column paths are unchanged. Reuse the existing DECIMAL BVT fixture rather than adding a new fixture, load, sleep or retry. Add typed admission/guard checks for DECIMAL64/128/256 and public execution checks for changed values, out-of-range bindings, NULL and recovery. Retain a DOUBLE collision control above 2^53. Tested with: - Fresh native build, Go 1.27.0, Shanghai50 isolated containers with verified clean/patched binary entrypoints, base `281ca809d688f7ff727e813a48436aff1cfbea36`. - `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=120s -run 'TestPreparedDecimalComparison(Pruning|AdmissionOwnership)' ./pkg/sql/plan`. - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/sql/plan`. - Standard mo-tester on `test/distributed/cases/prepare/issue_29514_decimal_expression_filter.sql`: clean baseline 238/239 (new pruning assertion fails), patched 239/239 twice, about 2.8 seconds per run. - Actual binary-protocol prepared SELECT and EXPLAIN ANALYZE: direct integer 4 blocks before / 1 after; changed values, INT64_MAX, NULL and re-execution return correct rows. TEXT and explicit DOUBLE/INT64 remain unchanged. - Scoped latency/cache control: the four-block direct integer query improves from approximately 0.63 ms to 0.30 ms; the submitted guarded plan retains prepared cache reuse. A broader non-cacheable prototype was rejected, not included. - Final reversed-order 5,000-query two-row controls measured approximately 0.217 ms before / 0.228 ms after (about 11 microseconds / 5% additional precision-guard cost; an earlier repeat showed about 13 microseconds / 6%). The unchanged explicit-DOUBLE control stayed approximately 0.214-0.220 ms. This patch does not claim zero overhead for tiny queries. A separate transport-shortcut prototype did not remove this cost and was also rejected. No claim is made that this fixes the full MOTR pruning matrix, the Daily HNSW QPS decline, or any 4.2 incident. The comparative baseline is 281ca80. Main subsequently advanced to 15cc623 (#29649, Dragonboat constructor cleanup), which Mergify merged into this branch as **46df957b**. All four patch files match c3cbefb byte-for-byte. The final published head was independently built on Shanghai50 with its updated dependency pin: full `pkg/sql/plan` PASS (9.683s), actual binary-protocol query controls PASS, and standard BVT 239/239 PASS (2.790s). Executable build metadata records `vcs.revision=46df957b58da1922526507e6101f7fe6a89dbf11`, `vcs.modified=false`. The latency A/B above is on the original 281ca80 comparative base; it was not relabelled as a new latency experiment after the unrelated dependency merge. Hosted CI remains separate and is not claimed green. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #29641
What this PR does / why we need it:
Dragonboat NewNodeHost swallowed non-error panics, changed error-valued panic identity and leaked its directory lock on Goexit. NewTransport could also lose a returned child before constructor handoff. Pin Dragonboat to
abc3d2fce5a6b82b3a8a922c342fd1ec4afb8df3(matrixorigin/dragonboat#18): each existing constructor owner keeps rollback until successful return and reuses its shared destruction path, preserving the primary failure.Transport Close now stops and joins the receiver before cleaning snapshot chunks. Otherwise a final valid receive can recreate
.receivingstorage after cleanup. The shared path covers ordinary shutdown and partial-start rollback, including returned child Close errors. Existing EngineConfig validation also rejects snapshot/close worker counts beyond Go's reflect.Select hard limit before acquisition. No new state machine, engine rollback framework or steady-state work is added.Remove the unused testutil import that blocked this branch's function-package compilation. This matches the existing correction on main (#29648), without pulling in its other changes.
The MatrixOne regression exercises the actual public constructor with StrictMem LogDB injection and no bound ports, checking ordinary errors, panic identity, Goexit and exactly-once lock cleanup. Dependency regressions reuse existing fixtures and validate ownership handoff, receiver draining with both Close outcomes, terminal snapshot-directory cleanup, and unsafe configuration rejection before acquisition.
Validation (Go 1.26.4, Linux/amd64):
Merge Dragonboat #18 first. Custom child Close retains its requirement to terminate and join callbacks; resources a factory never returns and arbitrary fatal/nonterminating destructors retain their existing contracts. Hard worker-count limits do not guarantee affordability of extremely large configurations. Local validation is distinct from hosted CI; new-head CI is not claimed green.