Skip to content

[Bug]: pkg/proxy coverage UT crashes on concurrent test-server map writes #27771

Description

@gouhongshen

Branch and build

Actual behavior

The Ubuntu coverage suite crashes pkg/proxy while running
TestHandler_HandleEventKill:

fatal error: concurrent map writes
github.com/matrixorigin/matrixone/pkg/proxy.(*testHandler).handleKillConn(...)
    pkg/proxy/server_conn_test.go:385
github.com/matrixorigin/matrixone/pkg/proxy.testHandle(...)
    pkg/proxy/server_conn_test.go:358
github.com/matrixorigin/matrixone/pkg/proxy.(*testCNServer).Start.func1(...)
    pkg/proxy/server_conn_test.go:318
created by github.com/matrixorigin/matrixone/pkg/proxy.(*testCNServer).Start
    pkg/proxy/server_conn_test.go:313
FAIL github.com/matrixorigin/matrixone/pkg/proxy 3.491s

testCNServer.Start creates one handler goroutine per backend connection.
handleKillConn lets those goroutines write the shared
testCNServer.globalVars map without synchronization:

h.server.globalVars["killed"] = "yes"

The same shared map is also iterated without synchronization by
handleShowGlobalVar.

Expected behavior

The proxy test server must serialize or otherwise encapsulate all access to
its shared state so concurrent kill handling cannot crash the test process or
race with readers.

Steps to reproduce

  1. Check out the observed head or the baseline above.
  2. Run the repository's Ubuntu all-package coverage command with
    -tags matrixone_test -covermode=set.
  3. Observe TestHandler_HandleEventKill occasionally dispatch the kill to
    concurrent test-server handlers and crash on the shared map write.

The failure is timing-sensitive. The linked attempt is the exact reproduction
and contains the complete goroutine stack.

Scope and attribution

  • Searches for TestHandler_HandleEventKill, handleKillConn,
    pkg/proxy plus concurrent map, and globalVars found no matching issue.
  • pkg/proxy/server_conn_test.go has the same SHA-256
    (ac41d30b42d0d94a90b7f066cd6511936cdcbe9acaab3d4d88c9b3e3e4ac2733)
    on the baseline and failing PR head.
  • The unsafe map and write were introduced in commit 90f59ec7a3c in 2023.
  • PR fix: preserve clone auto-increment continuation #27154 changes only clone allocator construction/tests and clone BVT
    expectations. Although pkg/sql/compile is transitively linked into the
    proxy test binary through pkg/frontend, its changed
    constructTableClone path is not executed by this test.

This is therefore an unrelated latent test-fixture concurrency defect exposed
by coverage scheduling, not a clone allocator regression.

Metadata

Metadata

Assignees

Labels

ai-easyAI直接干,人扫一眼就行kind/bugSomething isn't workingseverity/s0Active / top priority for current sprint. Owner has committed to working on it now.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions