Skip to content

feat(rabbitmq): enable core plugins, production config, and Erlang VM tuning - #58

Merged
paudley merged 2 commits into
mainfrom
rabbit-plugins
Mar 2, 2026
Merged

feat(rabbitmq): enable core plugins, production config, and Erlang VM tuning#58
paudley merged 2 commits into
mainfrom
rabbit-plugins

Conversation

@paudley

@paudley paudley commented Mar 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Enable 8 tier-1 RabbitMQ plugins required by the cognitive architecture and production operations: consistent_hash_exchange, stream, stream_management, shovel, shovel_management, event_exchange, tracing, top
  • Add rabbitmq/rabbitmq.conf with production-tuned defaults (absolute memory watermark, TCP keepalives, Nagle disabled, 15s stats interval, stream listener on 5552, guest loopback restriction)
  • Configure Erlang VM scheduler optimizations: disable speculative busy-waiting, bind scheduler threads to CPU topology
  • Wire stream protocol port 5552, container mem_limit/cpus knobs, and rabbitmq-plugins manage.sh command

Test plan

  • docker compose build rabbitmq succeeds with plugins enabled
  • docker compose --profile rabbitmq up -d starts cleanly
  • ./scripts/manage.sh rabbitmq-plugins lists all 8 new plugins as enabled
  • ./scripts/manage.sh rabbitmq-overview shows stream listener on 5552
  • Management UI accessible on :15672, confirms rabbitmq.conf values loaded
  • python -m pytest -k full_workflow passes with rabbitmq profile active

… tuning

Enable eight tier-1 RabbitMQ plugins required by the cognitive
architecture and production operations: consistent_hash_exchange,
stream, stream_management, shovel, shovel_management, event_exchange,
tracing, and top.

Add rabbitmq.conf with production-tuned defaults: absolute memory
watermark (512 MiB) with allocated calculation strategy for accurate
container reporting, disk free limit, TCP keepalives with Nagle
disabled, 128 channel max, 15 s stats emission interval, classic
queue default, stream listener on port 5552, and guest loopback
restriction.

Configure Erlang VM scheduler optimizations via
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: disable speculative busy-waiting
(+sbwt/+sbwtdcpu/+sbwtdio none) and bind scheduler threads to CPU
topology (+stbt ts) to reduce context switching.

Wire stream protocol port 5552 through docker-compose and .env.example,
add container mem_limit/cpus knobs, mount rabbitmq.conf read-only, and
register rabbitmq-plugins manage.sh command.
Copilot AI review requested due to automatic review settings March 2, 2026 22:15
@paudley
paudley enabled auto-merge (squash) March 2, 2026 22:15
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the RabbitMQ setup by integrating essential plugins, applying production-grade configuration, and optimizing the underlying Erlang VM. These changes aim to improve the broker's performance, observability, and operational capabilities, laying the groundwork for more robust and efficient message processing within the system.

Highlights

  • RabbitMQ Plugin Activation: Enabled 8 tier-1 RabbitMQ plugins, including consistent_hash_exchange, stream, stream_management, shovel, shovel_management, event_exchange, tracing, and top, to support cognitive architecture requirements and production operations.
  • Production Configuration: Introduced a new rabbitmq.conf file with production-tuned defaults for memory watermarks, TCP keepalives, Nagle's algorithm, statistics interval, stream listener, and guest loopback restriction.
  • Erlang VM Tuning: Configured Erlang VM scheduler optimizations to disable speculative busy-waiting and bind scheduler threads to CPU topology, improving resource utilization.
  • Resource and Port Exposure: Wired the RabbitMQ stream protocol port (5552), container memory/CPU limits, and added a rabbitmq-plugins management command for easier interaction.
Changelog
  • .env.example
    • Added RABBITMQ_STREAM_PORT and RABBITMQ_STREAM_HOST_PORT variables.
    • Introduced RABBITMQ_MEMORY_LIMIT and RABBITMQ_CPU_LIMIT for container resource control.
    • Added RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS to configure Erlang VM scheduler optimizations.
  • docker-compose.yml
    • Configured mem_limit and cpus for the RabbitMQ service using environment variables.
    • Mounted the new rabbitmq/rabbitmq.conf file into the container.
    • Exposed the RABBITMQ_STREAM_PORT for the RabbitMQ service.
  • docker/rabbitmq/Dockerfile
    • Updated the image description to reflect the inclusion of core plugins.
    • Added a RUN command to enable 8 specific RabbitMQ plugins offline.
  • rabbitmq/rabbitmq.conf
    • Added a new configuration file for RabbitMQ with production-tuned settings.
    • Configured absolute memory watermark, paging ratio, and memory calculation strategy.
    • Set disk free limit, heartbeat, channel max, TCP listen options (backlog, keepalive, nodelay).
    • Defined default queue type, consumer timeout, statistics emission interval, and guest user loopback restriction.
    • Specified the stream protocol listener port.
  • scripts/lib/maintenance.sh
    • Modified array expansion from ${cmd[@]} to ${cmd[*]} in the pgbadger command execution.
  • scripts/lib/rabbitmq.sh
    • Added RABBITMQ_STREAM_PORT variable with a default value.
    • Introduced cmd_rabbitmq_plugins function to execute rabbitmq-plugins list.
  • scripts/manage.sh
    • Added rabbitmq-plugins command to the help output.
    • Integrated rabbitmq-plugins into the command dispatch logic to call cmd_rabbitmq_plugins.
Activity
  • No specific review comments or activity have been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the RabbitMQ service by enabling several useful plugins, adding a production-ready configuration, and providing options for Erlang VM tuning and container resource limits. The changes are well-structured and include corresponding updates to management scripts.

I have one specific suggestion in scripts/lib/rabbitmq.sh to improve the new rabbitmq-plugins command to fully support management capabilities as described in the help text.

Additionally, a critical point to consider is the base image rabbitmq:4.2-management-alpine used in docker/rabbitmq/Dockerfile. This image tag does not appear to be valid on the official Docker Hub repository for RabbitMQ, which could cause the build to fail. Please double-check that the base image and tag are correct.

Comment thread scripts/lib/rabbitmq.sh
cmd_rabbitmq_plugins() {
ensure_env
ensure_rabbitmq_service
rabbitmq_exec rabbitmq-plugins list "$@"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation hardcodes the list subcommand, which prevents using other rabbitmq-plugins commands like enable or disable. This contradicts the help text in manage.sh which states "List or manage RabbitMQ plugins." For example, running manage.sh rabbitmq-plugins enable my_plugin would incorrectly execute rabbitmq-plugins list enable my_plugin.

To align with the documented behavior and the test plan (which requires manage.sh rabbitmq-plugins to default to list), I suggest checking if arguments are provided. If not, default to list; otherwise, pass all arguments through to rabbitmq-plugins.

Suggested change
rabbitmq_exec rabbitmq-plugins list "$@"
if [[ $# -eq 0 ]]; then
rabbitmq_exec rabbitmq-plugins list
else
rabbitmq_exec rabbitmq-plugins "$@"
fi

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds production-oriented RabbitMQ defaults to the stack: enabling core operational/plugins in the RabbitMQ image, mounting a tuned rabbitmq.conf, exposing the stream protocol port, and extending manage.sh with a RabbitMQ plugins helper command.

Changes:

  • Enable a set of RabbitMQ plugins in the RabbitMQ Docker image build.
  • Add and mount rabbitmq/rabbitmq.conf, plus expose/configure the stream listener on port 5552.
  • Add manage.sh rabbitmq-plugins command and introduce RabbitMQ container resource/VM tuning knobs in compose + .env.example.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/manage.sh Adds a new rabbitmq-plugins command to the CLI dispatcher and help text.
scripts/lib/rabbitmq.sh Implements cmd_rabbitmq_plugins helper and adds a stream port env default.
scripts/lib/maintenance.sh Adjusts how the pgBadger command is passed to bash -lc.
rabbitmq/rabbitmq.conf Introduces a production-tuned RabbitMQ configuration (memory/disk/network/monitoring/streams).
docker/rabbitmq/Dockerfile Enables required RabbitMQ plugins at build time (offline).
docker-compose.yml Mounts rabbitmq.conf, exposes stream port 5552, adds resource limit knobs.
.env.example Documents new RabbitMQ stream ports, resource limits, and Erlang VM args.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .env.example Outdated
# +sbwtdcpu none — disable dirty-CPU scheduler busy-waiting
# +sbwtdio none — disable dirty-IO scheduler busy-waiting
# +stbt ts — bind scheduler threads to topology (reduces context switches)
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=+sbwt none +sbwtdcpu none +sbwtdio none +stbt ts

Copilot AI Mar 2, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS is set to an unquoted value containing spaces. Since scripts/lib/common.sh sources .env with set -a; source, this line will break shell parsing (and can cause manage.sh to fail) unless the value is quoted or spaces are escaped.

Suggested change
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=+sbwt none +sbwtdcpu none +sbwtdio none +stbt ts
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS="+sbwt none +sbwtdcpu none +sbwtdio none +stbt ts"

Copilot uses AI. Check for mistakes.
Comment thread scripts/lib/rabbitmq.sh
cmd_rabbitmq_plugins() {
ensure_env
ensure_rabbitmq_service
rabbitmq_exec rabbitmq-plugins list "$@"

Copilot AI Mar 2, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd_rabbitmq_plugins always runs rabbitmq-plugins list and then appends user-supplied args. This prevents using other subcommands (enable/disable/etc.) and also breaks common usage like manage.sh rabbitmq-plugins list (it becomes rabbitmq-plugins list list). Consider passing through to rabbitmq-plugins directly, or defaulting to list only when no args are provided.

Suggested change
rabbitmq_exec rabbitmq-plugins list "$@"
if [[ $# -eq 0 ]]; then
rabbitmq_exec rabbitmq-plugins list
else
rabbitmq_exec rabbitmq-plugins "$@"
fi

Copilot uses AI. Check for mistakes.
Comment on lines 56 to 60
local cmd=(pgbadger --quiet --format csv --jobs "$jobs" --outfile "$output")
[[ -n $since ]] && cmd+=(--begin "$since")
cmd+=(/var/lib/postgresql/data/log/postgresql-*.csv)
compose_exec bash -lc "${cmd[@]}"
compose_exec bash -lc "${cmd[*]}"
echo "pgBadger report written to ${output}" >&2

Copilot AI Mar 2, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compose_exec bash -lc "${cmd[*]}" builds a shell command string from user-controlled values (--since, --output) without robust escaping. This can break when values contain spaces/shell metacharacters and can lead to shell injection inside the container. Prefer executing pgbadger without bash -lc (if possible), or escape each argument (e.g., via printf %q) / pass args via bash -lc '... "$@"' to avoid interpolation.

Copilot uses AI. Check for mistakes.
Comment thread scripts/manage.sh
Comment on lines +1511 to +1513
rabbitmq-plugins)
cmd_rabbitmq_plugins "$@"
;;

Copilot AI Mar 2, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new rabbitmq-plugins manage.sh command is introduced here but isn’t covered by the existing tests/test_manage.py workflow suite that exercises other manage.sh commands. Adding a test that runs manage.sh rabbitmq-plugins under the rabbitmq profile (and asserts expected plugin names show up) would prevent regressions (and would have caught issues like list list).

Copilot uses AI. Check for mistakes.
CI sources .env directly, so unquoted values with spaces like
"+sbwt none" cause the shell to interpret "none" as a command.
Wrap the RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS value in double
quotes so both `source .env` and Docker Compose handle it
correctly.
@paudley
paudley merged commit 8096c06 into main Mar 2, 2026
7 of 8 checks passed
@paudley
paudley deleted the rabbit-plugins branch March 2, 2026 22:32
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.

2 participants