feat(binance-trading-bot): preload pg_stat_statements in bundled Postgres - #63
Conversation
…gres The app's migration packages/db/migrations/0001_extensions.sql runs `create extension if not exists "pg_stat_statements"`, but the module only records once it is preloaded, so the view errored on every read. shared_preload_libraries replaces postgresql.conf rather than appending, and the timescaledb image writes timescaledb into that file at init, so timescaledb has to be named explicitly alongside pg_stat_statements or hypertable creation breaks. compute_query_id defaults to `auto` and activates on load, so no extra flag is needed. track_planning is left commented: the PostgreSQL docs warn it may cost noticeably at high statement rates. Verified against timescale/timescaledb:2.29.1-pg17 - server starts, `show shared_preload_libraries` returns both, the extension creates and the view reads. Chart 1.2.3 -> 1.3.0: new default runtime behaviour, and the Postgres pod restarts on upgrade. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MZo4ay6r1xtgHHQRRce6pV
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe Helm chart version changed to ChangesPostgreSQL preload configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized chart change enables PostgreSQL query statistics while preserving TimescaleDB configuration and has documented validation; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Warning Your free Security trial is over. An organization admin can activate billing to continue. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Adds
pg_stat_statementstoshared_preload_librarieson the bundled Postgres StatefulSet, and bumps the chart1.2.3→1.3.0.Why
The application's own migration,
packages/db/migrations/0001_extensions.sql, already runs:create extension if not exists "pg_stat_statements";CREATE EXTENSIONsucceeds without preloading, but the module only collects statistics when loaded at server start, so every read of the view failed. The chart shipped a query-statistics surface that could never return data.Two details the change had to get right:
timescaledbhas to be restated.shared_preload_librariespassed as-con the command line replaces the value inpostgresql.conf; it does not append. Thetimescale/timescaledbimage writestimescaledbinto that file during init, so omitting it here would silently drop TimescaleDB and break hypertable creation. Same reason theargslist itself carries a comment: Helm replaces a list wholesale, so an override must restate every entry it still wants.compute_query_idflag needed. It defaults toauto, which activates it whenpg_stat_statementsis loaded.pg_stat_statements.track_planningis added commented-out. The PostgreSQL docs note it "could have a measurable performance impact" at high statement rates, so it stays opt-in.Verification
Booted
timescale/timescaledb:2.29.1-pg17with the exact rendered args:Server starts clean — no startup FATAL.
pg_stat_statements.soand its control file are confirmed present in the image.Chart-level:
scripts/check-binance-trading-bot-render.sh→0/29 assertions failedhelm lint charts/binance-trading-bot→1 chart(s) linted, 0 chart(s) failedartifacthub.io/changesstill parses as a YAML list (5 entries)Upgrade impact
Changing
shared_preload_librariesrequires a server restart, so the Postgres pod is recycled on upgrade. This is aminorbump rather than a patch for that reason: new default runtime behaviour plus a restart, not a no-op fix.🤖 Generated with Claude Code
https://claude.ai/code/session_01MZo4ay6r1xtgHHQRRce6pV
Summary by CodeRabbit
New Features
pg_stat_statementsalongside TimescaleDB.Documentation