Repository navigation
Description
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
Other Environment Information
- Hardware parameters: single-node MatrixOne running in Docker with an 84 GiB memory limit; the host still had about 117–124 GiB available during the failure
- OS type: Linux
- Workload: Sysbench, 10 tables × 10,000,000 rows, 1,000 threads
- Regression run: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/31673657725/job/94364065796
- Successful legacy-workflow comparison: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/31509289615/job/93990723358
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
-
Start a single-node MatrixOne service.
-
Prepare Sysbench data with 10 tables and 10,000,000 rows per table.
-
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;
-
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
-
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.getConnIDgives each new connection a 2-second context.- The default
AllocateIDBatchis 100. managedHAKeeperClient.AllocateIDByKeyWithBatchholds the sharedc.muwhile 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.getConnIDandRoutineManager.Createdpkg/logservice/hakeeper_client.go:managedHAKeeperClient.AllocateIDByKeyWithBatchpkg/logservice/config.go: defaultAllocateIDBatch = 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
fix(logservice): prevent connection ID refill convoys (#27119)
fix(logservice): prevent connection ID refill convoys (matrixorigin#2…
fix(logservice): prevent connection ID refill convoys (matrixorigin#2…
fix(logservice): prevent connection ID refill convoys (matrixorigin#2…