Skip to content

[Bug]: burst connections fail when HAKeeper connection-ID batch refill times out #27114

Closed

Description

@LeftHandCold

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

4.2-dev (the same connection-admission implementation is also present on main)

Commit ID

29eff42

Other Environment Information

Actual Behavior

Immediately after rebuilding ten 10-million-row tables with cluster by(id), Sysbench opened 1,000 connections concurrently. MatrixOne accepted 92 connections and failed the remaining 908 during the MySQL handshake.

The client reported:

FATAL: error 2013: Lost connection to MySQL server at
'handshake: reading initial communication packet', system error: 11
FATAL: `thread_init' function failed: connection creation failed
FATAL: Threads initialization failed!

The MatrixOne log contained exactly 908 corresponding failures between 08:51:43.675 UTC and 08:51:48.949 UTC:

failed to get connection ID from HAKeeper: context deadline exceeded
internal error: getConnID

During the same interval, the HAKeeper client repeatedly logged:

isHAKeeper: false, err: context deadline exceeded

It recovered at 08:51:48.955 UTC:

isHAKeeper: true, err: <nil>

The MO process did not crash or restart. The Docker container was not OOM-killed, the host oom_kill counter did not increase, all swap remained free, and a subsequent scenario test passed on the same MO instance.

This is therefore a connection-admission failure caused by a short HAKeeper/ID-allocation stall, not an OS or container OOM.

Expected Behavior

A short HAKeeper connection-ID batch-refill delay must not turn a burst of otherwise valid client connections into hundreds of MySQL handshake failures. MatrixOne should tolerate the refill delay without a global waiter convoy, or apply bounded admission/backpressure/retry behavior that does not reject nearly the entire burst.

The benchmark workflow may wait for a steady state before collecting performance results, but normal database correctness and availability must not depend on the client sleeping after a bulk load.

Steps to Reproduce

  1. Start a single-node MatrixOne service.

  2. Prepare Sysbench data with 10 tables and 10,000,000 rows per table.

  3. Rebuild each table sequentially as a cluster-by table:

    alter table sysbench_db.sbtestN rename to sysbench_db.bak_sbtestN;
    create table sysbench_db.sbtestN(
        id int not null,
        k int default 0,
        c char(120) default '',
        pad char(60) default ''
    ) cluster by(id);
    insert into sysbench_db.sbtestN select * from sysbench_db.bak_sbtestN;
    drop table sysbench_db.bak_sbtestN;
  4. While the post-load merge/resource pressure is still active, immediately run:

    sysbench \
      --mysql-host=127.0.0.1 \
      --mysql-port=6001 \
      --mysql-user=dump \
      oltp_point_select.lua \
      --mysql-db=sysbench_db \
      --tables=10 \
      --table_size=10000000 \
      --threads=1000 \
      --time=300 \
      --report-interval=10 \
      --range_selects=off \
      --point_selects=1 \
      --secondary=on \
      --create_secondary=off \
      --auto_inc=off run
  5. Observe that a connection-ID batch refill can time out and cause most worker connections to fail during handshake.

The timing is load-sensitive. The linked regression run preserves the exact failure evidence.

Additional information

The failure shape strongly matches exhaustion of the local keyed ID batch:

  • RoutineManager.getConnID gives each new connection a 2-second context.
  • The default AllocateIDBatch is 100.
  • managedHAKeeperClient.AllocateIDByKeyWithBatch holds the shared c.mu while preparing the client and sending the HAKeeper allocate-ID request.
  • The first 92 connections succeeded; the remaining 908 failed while the refill path was stalled. This is consistent with eight IDs having already been consumed from the current 100-ID batch.

Relevant code paths:

  • pkg/frontend/routine_manager.go: RoutineManager.getConnID and RoutineManager.Created
  • pkg/logservice/hakeeper_client.go: managedHAKeeperClient.AllocateIDByKeyWithBatch
  • pkg/logservice/config.go: default AllocateIDBatch = 100

The Git blobs for these three files are identical between the successful comparison commit b83878b8e9f33a80ff9de633717ec8cd2bad0c3f and the failing commit 29eff4237c6d042095522a798c04a262a326646a. The latter only adds backup/tombstone compatibility fixes, so this is not introduced by the backup fix branch; it appears to be a pre-existing robustness problem exposed by the more aggressive timing.

A focused regression should cover a burst larger than the local ID batch while forcing or simulating a delayed batch refill. A separate end-to-end case can cover immediate high-concurrency admission after bulk loading, without changing the steady-state performance benchmark semantics.

Activity

  1. added
    kind/bug
    severity/s0
    and removed on Aug 13, 2026
  2. added a commit that references this issue on Aug 13, 2026
    0d7f110
  3. added 3 commits that reference this issue on Sep 17, 2026
    9ba63db
    3e96f8d
    cc60333
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions