Skip to content

feat(binance-trading-bot): preload pg_stat_statements in bundled Postgres - #63

Merged
chrisleekr merged 1 commit into
mainfrom
feat/btb-postgres-pg-stat-statements
Aug 23, 2026
Merged

feat(binance-trading-bot): preload pg_stat_statements in bundled Postgres#63
chrisleekr merged 1 commit into
mainfrom
feat/btb-postgres-pg-stat-statements

Conversation

@chrisleekr

@chrisleekr chrisleekr commented Aug 23, 2026

Copy link
Copy Markdown
Owner

What

Adds pg_stat_statements to shared_preload_libraries on the bundled Postgres StatefulSet, and bumps the chart 1.2.31.3.0.

postgres:
  args:
    - -c
    - max_connections=50
    - -c
    - shared_preload_libraries=timescaledb,pg_stat_statements

Why

The application's own migration, packages/db/migrations/0001_extensions.sql, already runs:

create extension if not exists "pg_stat_statements";

CREATE EXTENSION succeeds 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:

  • timescaledb has to be restated. shared_preload_libraries passed as -c on the command line replaces the value in postgresql.conf; it does not append. The timescale/timescaledb image writes timescaledb into that file during init, so omitting it here would silently drop TimescaleDB and break hypertable creation. Same reason the args list itself carries a comment: Helm replaces a list wholesale, so an override must restate every entry it still wants.
  • No compute_query_id flag needed. It defaults to auto, which activates it when pg_stat_statements is loaded.

pg_stat_statements.track_planning is 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-pg17 with the exact rendered args:

$ psql -Atc "show shared_preload_libraries; show compute_query_id;"
timescaledb,pg_stat_statements
auto

$ psql -Atc "create extension pg_stat_statements; select count(*) from pg_stat_statements;"
CREATE EXTENSION
8

Server starts clean — no startup FATAL. pg_stat_statements.so and its control file are confirmed present in the image.

Chart-level:

  • scripts/check-binance-trading-bot-render.sh0/29 assertions failed
  • helm lint charts/binance-trading-bot1 chart(s) linted, 0 chart(s) failed
  • artifacthub.io/changes still parses as a YAML list (5 entries)

Upgrade impact

Changing shared_preload_libraries requires a server restart, so the Postgres pod is recycled on upgrade. This is a minor bump 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

    • PostgreSQL now preloads pg_stat_statements alongside TimescaleDB.
    • Added documented support for optional planning statistics configuration.
  • Documentation

    • Added a changelog entry describing the PostgreSQL configuration updates.
    • Updated the Helm chart version to 1.3.0.

…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
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b2edbf02-7c62-430b-8298-a0b84b4a3a1b

📥 Commits

Reviewing files that changed from the base of the PR and between 45f1e64 and 1da1a36.

📒 Files selected for processing (2)
  • charts/binance-trading-bot/Chart.yaml
  • charts/binance-trading-bot/values.yaml

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The Helm chart version changed to 1.3.0. PostgreSQL now preloads timescaledb and pg_stat_statements, with documented optional planning statistics.

Changes

PostgreSQL preload configuration

Layer / File(s) Summary
Configure PostgreSQL preload libraries
charts/binance-trading-bot/values.yaml, charts/binance-trading-bot/Chart.yaml
PostgreSQL arguments now preload timescaledb and pg_stat_statements. The values include an optional pg_stat_statements.track_planning setting. The chart version changed to 1.3.0, and the Artifact Hub changelog documents the update.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 1da1a

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)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preloading pg_stat_statements in the bundled PostgreSQL instance.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (2 skipped: 2 unsupported.)
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chrisleekr
chrisleekr merged commit 3cff153 into main Aug 23, 2026
8 checks passed
@chrisleekr
chrisleekr deleted the feat/btb-postgres-pg-stat-statements branch August 23, 2026 07:46
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