Limit batch_max to queue_capacity - #124
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
There was a problem hiding this comment.
Pull request overview
This PR tightens the bgworker export batching logic by clamping pg_stat_ch.batch_max to the shared-memory queue’s capacity, and reduces unnecessary memory reservation when building the dequeue vector. It also updates defaults and documentation to match the new behavior.
Changes:
- Add
PschEffectiveBatchMax()(batch_max clamped to queue capacity) and use it in the bgworker drain loop and exporter. - Add
PschQueueDepth()and use it as a sizing hint to avoid reserving an oversizedstd::vectorwhen the queue is mostly empty. - Update GUC defaults and documentation (README + reference docs) for new defaults and clamping behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/worker/bgworker.c | Uses effective (clamped) batch max in the drain-loop “partial batch” termination check. |
| src/queue/shmem.h | Exposes new queue sizing/clamping helpers. |
| src/queue/shmem.c | Implements PschQueueDepth() and PschEffectiveBatchMax(). |
| src/export/stats_exporter.cc | Reserves dequeue vector based on current queue depth; uses clamped batch max for export. |
| src/config/guc.c | Updates pg_stat_ch.batch_max default and documents clamping in the GUC description. |
| README.md | Updates documented defaults for queue capacity, flush interval, and batch max. |
| docs/reference/troubleshooting.mdx | Updates tuning guidance to reflect batch_max clamping. |
| docs/reference/configuration.mdx | Updates queue sizing/memory guidance and documents batch_max clamping behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 896228d. Configure here.
896228d to
9267079
Compare
This avoids wasting memory when reserving vector Also update docs with new defaults
9267079 to
fa6400f
Compare


This avoids wasting memory when reserving vector
Also update docs with new defaults