Repository navigation
feat: enable pg_stat_statements for Ecto Stats - #312
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The scoped migration handles the documented failure paths and rollback, with no blocking issues identified.
No open issues 🎉
What changed in this PR
Enables pg_stat_statements where supported so LiveDashboard’s Ecto Stats can report query costs, following the dashboard rollout in #305.
Changes:
- Adds a reversible migration that creates and probes the extension, skipping expected preload and permission failures with a notice.
- Documents the requirements for the “outliers” and “calls” tabs.
| File | Description |
|---|---|
| priv/repo/migrations/20261020164842_enable_pg_stat_statements.exs | Creates and checks the extension; drops it on rollback. |
| AGENTS.md | Documents preload requirements and local/CI skip behavior. |
Review effort: Balanced
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.
Closes #308
This enables
pg_stat_statementsonflick_prod, so LiveDashboard's Ecto Stats "outliers" and "calls" tabs can show which queries cost the most time. It follows the Ecto Stats rollout in #305.The risk is a skipped extension, not a failed deploy
The migration runs at boot, so an error there would stop the deploy. To prevent that, the migration catches any error, rolls back, and logs
pg_stat_statements skipped: <reason>. A revert followed by a rollback drops the extension. Nothing in Flick reads the extension, and the suite is unchanged at 193 passing.Production preloads the library
A rolled-back dry run in a remote shell on
flick_prodcreated the extension and read its view, returning{:error, :dry_run}. Render preloads the library, and the app role may create the extension.The migration creates the extension, then reads its view once
The issue's plain
CREATE EXTENSIONbroke Ecto Stats on any server that does not preload the library, which includes local and CI Postgres. A first version readshared_preload_librariesto decide, but only superusers can read that setting. The migration instead creates the extension and reads its view once. If either step raises, the block rolls back. I checked each path by hand onpostgres:18:Worth a reviewer's attention
-c shared_preload_libraries, so I verified it by hand.