From fd6eba5c29b8be33a4ffca6fafafaceedc110705 Mon Sep 17 00:00:00 2001 From: boban Date: Sun, 5 Jul 2026 23:34:04 +0200 Subject: [PATCH] fix(mariadb): stop logging protocol-normal "Aborted connection" warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- docker-compose.prod.yml | 2 ++ docker-compose.yml | 2 ++ docker/mariadb/tuning.cnf | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 docker/mariadb/tuning.cnf diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index e20b522..67bd436 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -163,6 +163,8 @@ services: MARIADB_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:?set DB_ROOT_PASSWORD in .env}" volumes: - 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: test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] interval: 10s diff --git a/docker-compose.yml b/docker-compose.yml index e918e23..97dd90e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -81,6 +81,8 @@ services: MARIADB_ROOT_PASSWORD: "${DB_ROOT_PASSWORD:?set DB_ROOT_PASSWORD in .env}" volumes: - 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: # localhost-only: reachable from the host (DB tools / SSH tunnel), not the whole network. - "127.0.0.1:${DB_PORT:-3306}:3306" diff --git a/docker/mariadb/tuning.cnf b/docker/mariadb/tuning.cnf new file mode 100644 index 0000000..f953272 --- /dev/null +++ b/docker/mariadb/tuning.cnf @@ -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