fix(sync): stop MariaDB connection leak and cut per-cycle sync waste
- ConnectionManager reuses a stale-but-healthy pool instead of dialing a new one every 30s, and closes every pool it replaces (one client held ~30 connections). Pool capped at 2 connections, idle released after 1 min. - Background sync every 1 min with ±30% jitter, scheduled from cycle start; users-status online threshold = interval × 1.3. One heartbeat per cycle. - Partnumber books: read headers only, fetch partnumbers_json per book when new/incomplete; empty book counts as complete; an incomplete book is re-pulled once per process (server book lists BOT_AGIBOT_G2_PERF missing from qt_partnumber_book_items). - NeedSync in one UNION ALL query; SyncQtSettings skips unchanged rewrite. - Migration 035: server-maintained server_updated_at on qt_configurations and qt_projects. Clients pull only changed rows after one full pull per process; servers without 035 and old clients keep full pulls. - Migrator: fresh GORM statement per verify query and history insert; files with two verify checks failed to record. ADL: bible-local/decisions/2026-10-26-mariadb-single-pool.md, bible-local/decisions/2026-10-26-incremental-config-project-pull.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8a08270b79
commit
44a09d4420
20 files changed
+901
-75
No files matched your search
@@ -0,0 +1,20 @@
|
||||
-- Tables affected: qt_configurations, qt_projects
|
||||
-- recovery.not-started: safe to re-run; ADD COLUMN IF NOT EXISTS / ADD INDEX IF NOT EXISTS
|
||||
-- recovery.partial: ALTER TABLE qt_configurations DROP COLUMN server_updated_at; ALTER TABLE qt_projects DROP COLUMN server_updated_at;
|
||||
-- recovery.completed: no action needed
|
||||
-- verify: qt_configurations.server_updated_at column missing | SELECT 1 FROM information_schema.COLUMNS WHERE table_schema=DATABASE() AND table_name='qt_configurations' AND column_name='server_updated_at' HAVING COUNT(*)=0
|
||||
-- verify: qt_projects.server_updated_at column missing | SELECT 1 FROM information_schema.COLUMNS WHERE table_schema=DATABASE() AND table_name='qt_projects' AND column_name='server_updated_at' HAVING COUNT(*)=0
|
||||
|
||||
-- Server-maintained change marker for incremental client pulls. Never written by
|
||||
-- clients: DEFAULT on INSERT and ON UPDATE on any row change, so clients that do not
|
||||
-- know the column keep working unchanged. See
|
||||
-- bible-local/decisions/2026-10-26-incremental-config-project-pull.md.
|
||||
ALTER TABLE qt_configurations
|
||||
ADD COLUMN IF NOT EXISTS server_updated_at TIMESTAMP(6) NOT NULL
|
||||
DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||
ADD INDEX IF NOT EXISTS idx_qt_configurations_server_updated_at (server_updated_at, id);
|
||||
|
||||
ALTER TABLE qt_projects
|
||||
ADD COLUMN IF NOT EXISTS server_updated_at TIMESTAMP(6) NOT NULL
|
||||
DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
||||
ADD INDEX IF NOT EXISTS idx_qt_projects_server_updated_at (server_updated_at, id);
|
||||
Reference in new issue
Block a user