Skip to content

Md fable diagnostics locktree#2

Merged
brainexe merged 6 commits into
masterfrom
md_fable_diagnostics_locktree
Jul 5, 2026
Merged

Md fable diagnostics locktree#2
brainexe merged 6 commits into
masterfrom
md_fable_diagnostics_locktree

Conversation

@brainexe

@brainexe brainexe commented Jul 4, 2026

Copy link
Copy Markdown
Member

No description provided.

brainexe and others added 6 commits July 3, 2026 11:04
Quality pass over the whole codebase (no behaviour change).

Simplification / reuse:
- Unify the info-overlay scaffolding into shared row.go helpers: padInfo
  (was 2 private copies + 14 inline loops), infoHeader (1 helper + 15
  copies), and swatch for the "▇" legend glyph.
- Collapse the three per-function bar-cell closures in row.go into one
  bytesToCells helper; add screen.resetCursor() for the paired
  cursor/offset resets.
- Move the generic fmt* formatters from view_queries.go to format.go
  where their other consumers live.
- Quote SQL identifiers via the existing qualifiedIdent() in
  bloat/reindex/vacuum instead of Go %q.
- Build sqlBufferStats / sqlBufferStatByOID from one template (was ~50
  duplicated lines); generated SQL is byte-identical to the old consts.

Tests: shmemCatOf ordering, appliedWindowPaths/snapTime snapshot anchors,
the statements column registry (uniqueness, track_planning gating, toggles,
cells∥columns parallelism), containsFold vs a strings.Contains oracle,
lessBy*Extractor unknown-below-known, viewportRange boundaries, barWidth
clamps, a barReserve smoke test, and QueryStat derived-metric edges.
Audit-driven improvements across every tool/view plus new diagnostics and a
new blocking-chain view.

Usability/consistency:
- Diagnostic.Kinds lets registry diagnostics declare graded column kinds the
  name heuristic can't infer (hit ratios green→red, dead/stale/consumed % red→
  green); annotate the existing entries.
- C column picker + Σ footer on levelDiagnosticResult (matches the other three
  generic tables), remembered per-diagnostic in prefs.
- Activity: d describes the selected backend's table; mem/read/s/write/s grade.
- Top-queries: opt-in min_ms/max_ms/stddev_ms + derived cv (erratic runtime).
- Diagnostics list: colored category badges + f category filter.

Highlighting & cross-links:
- Parts panel grades dead-tuple % and vacuum/analyze age; buffer detail grades
  dirty share + wires d; shmem shows buffer-pool share; WAL relations grade FPI
  write-amplification; activity gains opt-in blocked_by; diag d resolves index
  names too.
- Maintenance dashboard: a/w/r jump into Activity, WAL, replication slots.

New diagnostics: fk_missing_index, index_redundant_prefix, idle_in_xact_holders,
lock_summary, progress_all, slru_stats, index_io, subscription_stats,
stale_statistics.

New view: levelLockTree under Activity (b) — pg_blocking_pids forest as an
indented tree, auto-refresh, k/x cancel/terminate.

Docs: docs/future/ design notes for a progress monitor, health-triage report,
and wait-event profiler.

Integration tests (PGDU_TEST_DSN) cover all diagnostics plus FK/redundant-index
detection and the lock-tree blocking chain.
Add a live pg_stat_progress_* monitor (levelProgress) under the
maintenance dashboard, opened with 'p', auto-refreshing on the activity
tick with a per-operation progress bar, done/total counters, phase, age
and user. The existing progress_all diagnostic keeps its point-in-time
output; both now share sqlProgressBase.

Reuse the same progress data for the disk-usage tool's inline REINDEX:
while REINDEX INDEX CONCURRENTLY runs, poll pg_stat_progress_create_index
and render a phase label + percentage bar in the banner instead of a bare
spinner. The query picks the blocks counter during the scan phase and the
tuples counter during validation so the bar stays meaningful across phases.

Also fill in the missing levelLabel cases for levelProgress and
levelLockTree (both previously rendered 'level: ?').
Add a one-key health-triage battery (internal/pg/triage.go): fans out the
existing diagnostic checks (wraparound, blocked backends, idle-in-xact,
replication slots, cache hit ratio, SLRU pressure, sequence exhaustion,
bloat, invalid indexes, temp files/deadlocks) concurrently under one
budget and renders a severity-sorted red/yellow/green report
(levelTriage, view_triage.go); Enter drills into the diagnostic or tool
backing the line that fired.

Add a wait-event profiler (levelWaitProfile, 'W' on the activity table):
samples pg_stat_activity's wait_event_type/wait_event into a ring buffer
while the activity tick runs, and renders a sparkline-backed breakdown
by wait class.

Surface health triage as its own entry on the root tool picker
("Health triage") instead of a bare '!' keybinding on levelTools, so
it's discoverable the same way every other tool is and gets a normal
toolEntryScreen/levelTriage load path.
health-triage, progress-monitor, and wait-event-profiler all landed in
aee27be; the future/ planning docs describing them are now stale.
Deadlocks and temp-file spill were graded as one line even though they're
unrelated signals sharing only the database_stats view — a clean deadlock
count could hide critical temp-file spill under a single yellow/green
verdict. Split into independent "deadlocks" and "temp files" checks.

Added WAL archiver failure, connection saturation, checkpoint pressure,
prepared-transaction (2PC) leak, rollback ratio, stale planner statistics,
and FK-missing-index checks. All reuse data pgdu already fetches (mostly
MaintenanceInfo, already pulled for the wraparound check) rather than new
SQL. Triage now fetches MaintenanceInfo and database_stats once up front
and runs the dependent checks as pure graders over the shared snapshot,
instead of hitting the server once per check.
@brainexe brainexe merged commit 27e666d into master Jul 5, 2026
2 checks passed
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