Skip to content

[Bug]: JSON_OVERLAPS allocation test flakes under coverage instrumentation #26543

Closed

Description

@XuPeng-SH

Is there an existing issue for the same bug?

  • I have checked the existing issues.

#26214 and #26243 cover the same allocation-count test failing under race instrumentation. They were closed after the allocation-only test was moved behind //go:build !race. No open issue records the failure under non-race coverage instrumentation.

Branch Name

main (observed on PR #26532 after merging main)

Commit ID

5e5748f96620f28ead0b1084042e440288a2c5dc

Other Environment Information

Actual Behavior

The non-race coverage UT failed in pkg/sql/plan/function:

=== RUN   TestJSONOverlapsAccessorAllocationsDoNotScaleWithRows
func_builtin_json_overlap_alloc_test.go:65:
    Error: "22" is not less than or equal to "10"
    Messages: accessor allocations must be batch-scoped: one=0.000000 many=22.000000
--- FAIL: TestJSONOverlapsAccessorAllocationsDoNotScaleWithRows (0.01s)

The coverage job runs the suite with repository-wide coverage instrumentation:

go test -mod=readonly -json -short -v -tags matrixone_test -p 6 \
  -covermode=set -coverprofile=<profile> -coverpkg=<all packages> ./...

The failed UT coverage producer then caused Matrixone Utils CI / Coverage to fail with:

coverage merge skipped because at least one required producer was skipped or failed

This dequeued PR #26532 from the merge queue.

Analysis

The failure is outside the PR change scope

PR #26532 changes only:

  • pkg/fileservice/object_storage_semaphore.go
  • pkg/fileservice/object_storage_semaphore_test.go

It does not change pkg/sql/plan/function, jsonOverlaps, or the failing allocation test.

The same workflow head passed:

  • Ubuntu/x86 ordinary UT
  • Linux/arm64 SCA
  • standalone pessimistic BVT
  • compose proxy BVT

The ordinary race UT does not execute this allocation-only test because the file has //go:build !race; the relevant evidence is the coverage history below.

The failure is intermittent

An earlier UT coverage run on PR head f7038e9f03d1c9733b90000e2926205f9cf000be passed:

Between that head and the failing head 5e5748f96620f28ead0b1084042e440288a2c5dc, no file in pkg/sql/plan/function changed. The intervening main merges removed the stream feature and changed TAE transfer-page synchronization; neither changes JSON_OVERLAPS or this test.

The same test therefore passed and failed across heads with unchanged target code. This strongly indicates an instrumentation/runtime-sensitive test rather than a regression introduced by PR #26532.

Why the existing race-only fix is insufficient

The test uses:

testing.AllocsPerRun(3, func() {
    result.PreExtendAndReset(rows)
    jsonOverlaps(...)
})

It compares the complete execution for one row with 8192 rows and requires:

manyRows <= oneRow + 10

#26214 and #26243 already established that this exact style of allocation assertion is unstable under race instrumentation. Moving it to a !race file prevents race UT failures, but the test still runs under repository-wide -coverpkg instrumentation.

In the failing run, the one-row measurement was 0 while the longer 8192-row measurement observed 22 allocations. testing.AllocsPerRun derives its result from runtime allocation counters around the measured callback. A longer, fully instrumented execution can pick up initialization, cache, instrumentation, or background-runtime allocations outside the narrow accessor-lifetime invariant. This is the likely mechanism; the log proves the unstable count but does not identify which individual allocations contributed to the 22.

Impact

  • Unrelated PRs can fail a required coverage producer.
  • The downstream coverage merge fails even though it has no independent coverage error.
  • Mergify removes otherwise-green PRs from the merge queue.
  • Rerunning may pass without any code change, wasting CI capacity and reviewer time.

Expected Behavior

An allocation-statistics-only regression test should not intermittently fail unrelated PRs because of coverage/runtime instrumentation.

JSON_OVERLAPS functional behavior should remain tested in ordinary, race, and coverage builds. The accessor-allocation invariant should be measured in an isolated/stable environment or asserted without relying on a small exact process-wide allocation delta during an 8192-row instrumented execution.

Steps to Reproduce

  1. Check out commit 5e5748f96620f28ead0b1084042e440288a2c5dc.
  2. Use the MatrixOne CGo test environment.
  3. Run the non-race UT coverage workflow with -covermode=set and repository-wide -coverpkg.
  4. Observe TestJSONOverlapsAccessorAllocationsDoNotScaleWithRows.
  5. Repeat the coverage run. The test may pass or report batch allocations above the oneRow + 10 threshold without any JSON_OVERLAPS source change.

Suggested Fix Direction

Keep the functional JSON_OVERLAPS tests in every build, but make the allocation regression deterministic. Possible directions:

  1. Run the allocation-only assertion in a dedicated non-race, non-coverage test job/process with a narrowly controlled package scope.
  2. Redesign the test to measure the specific accessor construction/ownership invariant instead of the complete 8192-row function execution.
  3. If exact allocation counting remains necessary, isolate warm-up and measured state so lazy initialization and unrelated runtime work cannot be charged only to the large-row measurement.
  4. Add repeated validation under the actual coverage command before considering the issue fixed.

Simply increasing the threshold would reduce sensitivity but would weaken the intended batch-scoped allocation regression guarantee.

Additional information

Activity

  1. added
    kind/bug
    on Aug 1, 2026
  2. added a commit that references this issue on Aug 2, 2026
    ac4a306
  3. added 3 commits that reference this issue on Sep 17, 2026
    2ff0bf5
    ec0dba1
    4a028a2
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