fix(mariadb): stop logging protocol-normal "Aborted connection" warnings

MariaDB logged an [Warning] Aborted connection ... (Got an error/timeout
reading communication packets) for every DB connection PHP closed without
the COM_QUIT handshake — i.e. whenever a long-lived worker (queue/schedule/
reverb) was recycled, a php-fpm worker retired, or a container restarted.
These are protocol-normal, not a fault: Aborted_clients was 46 over ~24
days uptime (~2/day) with a non-persistent PDO pool and no connection leak.

They surface only because the mariadb:11 image ships log_warnings=2. Add
docker/mariadb/tuning.cnf (mounted in dev + prod) setting log_warnings=1 —
genuine errors still log, the expected-disconnect noise stops — plus a
higher net_read_timeout (120s) so a momentarily-stalled worker read isn't
aborted as aggressively. Verified: forcing app+queue restarts now produces
zero new "Aborted connection" lines. The DB is internal-network only, so
dropping the level-2 access-denied notes carries no real exposure.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
feat/v1-foundation
boban 2026-07-05 23:34:04 +02:00
parent 3fae5293e2
commit fd6eba5c29
3 changed files with 20 additions and 0 deletions

View File

@ -163,6 +163,8 @@ services:
MARIADB_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:?set DB_ROOT_PASSWORD in .env}" MARIADB_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:?set DB_ROOT_PASSWORD in .env}"
volumes: volumes:
- mariadb-data:/var/lib/mysql - mariadb-data:/var/lib/mysql
# Quiet the protocol-normal "Aborted connection" WARNINGs (log_warnings=1) + worker timeouts.
- ./docker/mariadb/tuning.cnf:/etc/mysql/conf.d/tuning.cnf:ro
healthcheck: healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s interval: 10s

View File

@ -81,6 +81,8 @@ services:
MARIADB_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:?set DB_ROOT_PASSWORD in .env}" MARIADB_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:?set DB_ROOT_PASSWORD in .env}"
volumes: volumes:
- mariadb-data:/var/lib/mysql - mariadb-data:/var/lib/mysql
# Quiet the protocol-normal "Aborted connection" WARNINGs (log_warnings=1) + worker timeouts.
- ./docker/mariadb/tuning.cnf:/etc/mysql/conf.d/tuning.cnf:ro
ports: ports:
# localhost-only: reachable from the host (DB tools / SSH tunnel), not the whole network. # localhost-only: reachable from the host (DB tools / SSH tunnel), not the whole network.
- "127.0.0.1:${DB_PORT:-3306}:3306" - "127.0.0.1:${DB_PORT:-3306}:3306"

16
docker/mariadb/tuning.cnf Normal file
View File

@ -0,0 +1,16 @@
[mysqld]
# ── Connection-log noise ────────────────────────────────────────────────────────────────────
# PHP/Laravel closes DB connections WITHOUT the MySQL COM_QUIT handshake whenever a long-lived
# worker (queue:work / schedule:work / reverb:start) is recycled, a php-fpm worker is retired, or
# a container restarts. MariaDB records each such disconnect as
# [Warning] Aborted connection ... (Got an error/timeout reading communication packets)
# but ONLY at log_warnings >= 2 (the image default). These are protocol-normal — here ~2/day with
# a non-persistent PDO pool and no connection leak — not a fault. Drop to level 1 so genuine errors
# still log while the expected-disconnect noise stops. (The DB is bound to the internal network
# only, so dropping the level-2 access-denied notes carries no real exposure.)
log_warnings = 1
# Give a momentarily-stalled read on a long-lived worker connection more slack before the server
# aborts it, which further reduces the "timeout reading communication packets" variant. Job runtime
# is already bounded by `queue:work --timeout=90`, so this only affects idle/stall tolerance.
net_read_timeout = 120