Too many connections / connection pool exhausted
Too many things asked the database at once and it stopped accepting more. This usually hits at your busiest moment.
Do this first
A script is asking the database far too often. This one needs someone to find which.
What it means
MySQL refused a new connection because it is already at max_connections, or oxmysql's pool has no free slot and the wait timed out. On a live server this shows up as everything database-backed freezing at once, usually at peak population.
What causes it
Ordered by how often it is the answer.
- 1
A query in a tick loop
A thread with
Wait(0)or a short interval that queries every iteration. One such loop per player is enough to exhaust any pool. - 2
Queries in a player-connecting handler
playerConnectingruns per join; a slow query there holds a connection for the whole handshake, and a join wave holds all of them. - 3
The pool is smaller than the server needs
oxmysql defaults are modest. A 200-slot server doing per-player persistence needs more.
- 4
Long-running queries holding connections
A missing index turns a 2ms query into a 2s query, and the connection is held for the whole 2s.
- 5
Another application shares the MySQL instance
A web panel, a Discord bot, phpMyAdmin.
How to tell which one is yours
SHOW PROCESSLIST;
during the problem. Repeated identical queries mean a loop. Long Time values mean missing indexes. Then check what MySQL allows:
SHOW VARIABLES LIKE 'max_connections';
Where to look
Any CreateThread that queries, and every playerConnecting handler.
How to fix it
Cache instead of querying in a loop, raise the ceilings, and index what you filter on:
# server.cfg set mysql_connection_string "mysql://user:pass@host/db?connectionLimit=20" -- MySQL SET GLOBAL max_connections = 300; CREATE INDEX idx_users_identifier ON users (identifier);
Still stuck on your own code?
This page is what this error usually means. Paste your console into Server Fixer and it will rank everything in it and tell you what to do first, and if you would rather not touch it, ORBIE can repair the script and hand the resource back ready to drop in.
bug_reportOpen Server Fixer