Conversation
…cking Adds a complete second infrastructure adapter (internal/infrastructure/mysql) implementing every application-layer port the Postgres adapter does, so pgscope can now monitor either engine via PGSCOPE_DB_ENGINE. Backend: - 20 MySQL collectors covering database size, connection saturation, duplicate/unused indexes, idle-in-transaction, top queries, long-running queries, sequence (AUTO_INCREMENT) overflow, pagination warnings, index candidates, prepared transactions, and unlogged (MEMORY) tables - Full live session/lock graph support (ISessionCollectorPort): active session listing, blocking-pid relationships, and per-lock detail with a MySQL-specific RECORD vs TABLE lock severity mapping - New MySQL-only insight: lock wait detection via sys.innodb_lock_waits, with query text always sourced from normalized DIGEST_TEXT rather than raw PROCESSLIST_INFO to avoid leaking literal query values - New GET /api/v1/connection endpoint reporting which engine is active, shaped to extend cleanly to a future multi-connection list - main.go now wires MySQL through the same Poller/SSE/history/insights flow Postgres uses, no more feature gap between the two engines Frontend: - Insights responses are normalized so MySQL's unpopulated fields (which serialize as null) never reach a component expecting an array, fixing a real crash on the Health tab - New EngineProvider/useEngine context so the UI knows which engine it's talking to - Postgres-only cards, tabs, and notices (vacuum health, checkpoints, replication lag/slots, physical I/O, function/trigger cost tracking, pg_stat_statements.track hints) are now hidden when connected to MySQL instead of showing incorrect or misleading instructions - New LockWaitCard for the MySQL-only lock wait insight - Long health-card warning lists now scroll within a max height instead of distorting the grid - Every health-card now shows a short, always-visible plain-language subtitle explaining what it checks, not just when it has a warning Every collector and adapter was verified against a live MySQL 8 container, not just reviewed for correctness.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: add MySQL/MariaDB engine support with full session and lock tracking
Adds a complete second infrastructure adapter (internal/infrastructure/mysql) implementing every application-layer port the Postgres adapter does, so pgscope can now monitor either engine via PGSCOPE_DB_ENGINE.
Backend:
Frontend:
Every collector and adapter was verified against a live MySQL 8 container, not just reviewed for correctness.
What does this PR do
Adds MySQL/MariaDB as a second, fully-supported database engine alongside Postgres. Every insight category, the live session/lock graph, SSE streaming, and history recording now work identically on both engines, selected at startup via
PGSCOPE_DB_ENGINE. The frontend also now knows which engine it is talking to and hides Postgres-only advisories instead of showing incorrect instructions against a MySQL database.Why
Postgres was pgscope's only supported engine so far, and the architecture was already built with hexagonal boundaries specifically to make a second engine possible without touching
domainorapplication. This PR is that proof: MySQL support was written entirely inside a newinfrastructure/mysqlpackage, with zero changes to the domain layer's types or logic. It also closes a real gap for anyone running MySQL/MariaDB in production who wanted the same live blocking-graph and advisory insights Postgres users already have.How was this tested
go build ./... && go vet ./... && go test ./...passesnpx tsc -bpasses (if frontend changed)mysql:8.0container to confirmlockWaitWarnings,blockedBy, and per-session lock detail render correctly on the live SSE session/lock graph, and confirmed Postgres-only cards and notices (vacuum health, checkpoints, replication lag/slots, physical I/O, function/trigger cost tracking) are hidden rather than shown incorrectly.golangci-lint runalso passes with 0 issues.Checklist
CONTRIBUTING.md(no SQL outsideinfrastructure/postgres; the newinfrastructure/mysqlpackage is the only place with MySQL-specific SQL, anddomain/applicationhave zero engine-specific vocabulary in actual types or logic, only in explanatory comments, matching the existing Postgres adapter's own comment style)SELECTagainst statistics views (the MySQL monitoring role needsSELECTandEXECUTEonperformance_schema/sysplus globalPROCESS, documented in the updated root README; no write capability anywhere)