Skip to content

fix(backup): make read-only quiesce work on MySQL/older-MariaDB containers (+ --db-check)#2

Merged
andrewbakercloudscale merged 4 commits into
mainfrom
fix/db-readonly-error-logging
May 31, 2026
Merged

fix(backup): make read-only quiesce work on MySQL/older-MariaDB containers (+ --db-check)#2
andrewbakercloudscale merged 4 commits into
mainfrom
fix/db-readonly-error-logging

Conversation

@andrewbakercloudscale

Copy link
Copy Markdown
Owner

Summary

Follow-up to #1. The new zero-downtime read-only quiesce silently failed on a live MySQL 8 container and fell back to STOP_DOCKER, causing real site downtime. Root-caused and fixed, with a diagnostic to prevent recurrence.

Root cause

db_exec's Docker path hardcoded the mariadb client. MySQL images (and MariaDB < 10.5) ship only mysql, so docker exec … mariadb failed with "executable not found", the quiesce silently no-op'd, verification saw read_only=0, and the backup fell back to stopping all containers.

Fixes

  1. Container client fallbackdb_exec now tries mariadb then mysql for the Docker path, mirroring the native branch.
  2. Surface DB errorsdb_exec captures stderr into _DB_LAST_ERR (was /dev/null); db_lock_mysql logs the real error on fallback.
  3. --db-check mode — reports engine/location, connecting user, version, and whether read_only actually engages (toggles + restores it, no imaging, zero downtime).

Verified on the live Pi (MySQL 8.0.46 container)

  • Before: --db-checkmariadb: executable file not found → RESULT FAILED.
  • After: read_only 0 → 1 → restored → RESULT OK.
  • Full --force backup: logged READ-ONLY — SET GLOBAL read_only=ON active, no STOP_DOCKER fallback, all 11 containers stayed up, site responding throughout.

shellcheck -x clean; bash -n passes.

🤖 Generated with Claude Code

Andrew Baker and others added 4 commits May 31, 2026 14:31
db_exec captured stderr to /dev/null, so a failed `SET GLOBAL read_only=ON`
only logged "did not take effect" with no cause. Capture stderr into
_DB_LAST_ERR and log it in db_lock_mysql's fallback branch so the actual
MariaDB error (privilege, auth, etc.) is visible for diagnosis.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Reports DB detection + whether the read-only quiesce engages (current user,
version, prior/after read_only, SET errors), then exits without imaging.
Briefly toggles read_only and restores it. Zero downtime; reusable for
diagnosing why a backup falls back to STOP_DOCKER.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The container branch of db_exec hardcoded the `mariadb` client. MySQL and
older MariaDB images ship only `mysql`, so `docker exec ... mariadb` failed
with 'executable not found' and the read-only quiesce silently no-op'd —
causing a fallback to STOP_DOCKER (downtime). Now tries mariadb then mysql,
mirroring the native branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Document the container mysql-client fallback fix and the new --db-check
diagnostic mode across CHANGELOG (1.10.0 Fixed/Added), README options,
AGENTS.md troubleshooting, and pi2s3.com/llms.txt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@andrewbakercloudscale andrewbakercloudscale merged commit b164d0e into main May 31, 2026
1 check passed
@andrewbakercloudscale andrewbakercloudscale deleted the fix/db-readonly-error-logging branch May 31, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant