Skip to content

[Bug]: Coverage UT embed restart panics in MORPC traceCodec.Encode on zero-capacity ByteBuf #30532

Closed

Description

@iamlinjunhong

Is there an existing issue for the same bug?

Source and environment

Source: PR #30286, exact head 9f3c4912333722b7775ef8ed0eece90031d09b21.
Official-main control: beffc64c486d369406a41cdb1447b120bc93cb41.
Run 39121003616, original attempt 1, Linux/amd64, Go 1.27.1, CGO enabled, short mode, matrixone_test, coverage mode set, no race flag, package parallelism 8. The coverage manifest contains 510 packages.

Actual behavior and CI impact

Complete failed-job logs were retrieved with gh run view 39121003616 --log-failed. The complete diagnostics artifact was also inspected: all 1,027,976 raw JSON events were scanned, with exactly one package failure and zero build failures.

The panic is attributed to TestDataBranchDiffAcrossCheckpointGCAndRestart/flush_only_restart in the JSON report. It happens while services are closing, after the branch DIFF executes; the package terminates before a normal subtest verdict. Stable signature:

panic: runtime error: slice bounds out of range [:46] with capacity 0

github.com/fagongzi/goetty/v2/buf.(*ByteBuf).RawSlice
  goetty/v2/buf/buf.go:230 (version v2.0.0-20260811155919-8edc32ac370a)
github.com/matrixorigin/matrixone/pkg/common/morpc.(*traceCodec).Encode
  pkg/common/morpc/codec_header.go:76
github.com/matrixorigin/matrixone/pkg/common/morpc.(*baseCodec).encodeCustomHeaders
  pkg/common/morpc/codec.go:469
github.com/matrixorigin/matrixone/pkg/common/morpc.(*baseCodec).Encode
  pkg/common/morpc/codec.go:322
github.com/matrixorigin/matrixone/pkg/common/morpc.(*messageCodec).Encode
  pkg/common/morpc/codec.go:152
github.com/fagongzi/goetty/v2.(*baseIO).Write
  session.go:448
github.com/matrixorigin/matrixone/pkg/common/morpc.(*server).startWriteLoop.func1
  pkg/common/morpc/server.go:448
FAIL github.com/matrixorigin/matrixone/pkg/embed 35.030s

traceCodec.Encode reserves the span header through setWriterIndexAfterGow and then accesses RawSlice. The observed capacity is zero at that access. Goetty's close path releases its output buffer, and the event occurs during service shutdown, but the artifact does not prove the specific close/write interleaving or identify the releasing goroutine. This is a runtime panic, not a compiler/type/static/security or coverage-threshold failure. No direct runner fault or resolved product defect is claimed.

Expected behavior

Stopping/restarting the embedded cluster must drain pending RPC writes safely. Trace-header encoding must never access a released output buffer, and the selected restart scenario must complete its branch-history assertions and cleanup.

Reproduction and bounded comparison

Original workflow command inside its timeout/diagnostic wrapper:

go test -mod=readonly -count=1 -json -short -v -tags matrixone_test \
  -timeout=20m -p 8 -covermode=set \
  -coverprofile="$coverage_profile" -coverpkg="$cover_pkgs" $test_scope

The local comparison uses the repository mo-cgo-test wrapper, CGO_ENABLED=1, the same complete 510-package coverpkg manifest from the diagnostic artifact, and the exact failed subtest. Every round is a separate process with -count=1, a unique coverage profile, and no race flag:

cover_pkgs=$(paste -sd, ut-coverage-packages.txt)
.agents/skills/mo-dev/scripts/mo-cgo-test \
  -count=1 -json -short -v -tags=matrixone_test -p=8 -timeout=240s \
  -covermode=set -coverprofile="$profile" -coverpkg="$cover_pkgs" \
  -run '^TestDataBranchDiffAcrossCheckpointGCAndRestart$/^flush_only_restart$' \
  ./pkg/embed

Manifest SHA-256: baa597eaab0add034bd734c3f9f9faa7db9f5ab12b847d699959a0c806a31b77.

Source Round 1 Round 2 Round 3
PR 9f3c49123337 PASS 9.219s PASS 9.959s PASS 9.364s
main beffc64c486d PASS 9.301s PASS 8.465s PASS 8.957s

Durations are terminal Go package elapsed times. All six processes exit 0 and emit the exact selected subtest’s terminal PASS. Three earlier PR-only package-coverage controls also passed; they are not substituted for this full-instrumentation six-round comparison.

The control is a clean complete git archive export of the exact official-main revision under TMPDIR, with all 11,441 tracked files checked against Git blob identities before and after execution. No additional Git worktree or branch switch was used. Both sources use identical, validated Darwin/arm64 native inputs; the native source trees, Go module files, Goetty version and CGo wrapper are identical. The exported wrapper changes only its repository-root lookup to the archive root, retaining all CGo, linker and runtime flags. No tracked main source was changed. Main's existing port-lease change uses Stop for restart, preserving the same service-shutdown path and retaining ports until final Close; this comparison does not claim identical whole-tree revisions.

All four bounded non-PR flaky-candidate conditions:

  1. Complete job logs and all raw events identify this runtime panic and the two dependent gates, with zero build failures.
  2. Three consecutive exact-head processes pass the exact failing subtest in the CI CGO/tag/short/coverage mode with its full instrumentation scope; each has terminal PASS and exit 0.
  3. The complete 33-file PR diff does not change pkg/embed, pkg/common/morpc, pkg/util/trace, pkg/txn/clock, Goetty/module files, native inputs, Makefile or CI harness. The changed SQL code handles fractional TIMESTAMPADD, its expression admission, and persisted DUMP/LOAD bindings. The failed scenario uses only integer columns and branch operations; it does not execute TIMESTAMPADD, DUMP/LOAD, prepared TIMESTAMPADD expressions or restored CHECK replacement. The response-write/trace-header/buffer-close path in the stack does not call those SQL changes. New SQL-integration tests run in a separate package process and do not alter the embed fixture or its transport owners.
  4. Three consecutive independent processes on clean current official-main source pass the same focused command; tracked source integrity is verified after testing.

These focused controls run on Darwin/arm64, Go 1.27.1. They preserve coverage instrumentation, CGO, tags and short mode but do not reproduce Linux scheduling or the original 510-package concurrent test workload. Passing main controls are the expected bounded flaky-candidate result, not reproduction of the original panic or proof that it is fixed.

The original exact-head Coverage artifact contains terminal PASS for every changed owning package: defines (1.839s), frontend (19.071s), pb/plan (1.686s), compile (13.080s), function (14.271s), plan (36.063s), disttae (8.248s), and sqlintegration (507.175s). Both TestTimestampDefaultDumpRoundtrip (0.390s, all four subcases) and TestTimestampAddHistoricalDumpRoundtrip (0.820s) pass. Ordinary race UT, SCA, shared build and both enabled BVT lanes also pass at this exact head. No unrelated source is changed to force CI green.

Classification: non-PR flaky candidate under the bounded three-round comparison rule. After this issue is created and verified, request one failed-jobs rerun of run 39121003616 and verify the new attempt was accepted. Recurrence requires renewed attribution and must not produce an unlimited rerun loop.

Activity

  1. self-assigned this
    on Oct 18, 2026
  2. added a commit that references this issue on Oct 18, 2026
    2508ce7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions