Skip to content

Preserve the RabbitMQ broker log in integration tests - #114434

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:rabbitmq-collect-broker-log
Aug 13, 2026
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
groeneai:rabbitmq-collect-broker-log

Conversation

@groeneai

Copy link
Copy Markdown
Collaborator

Related: #114415
Related: #113610

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

When a RabbitMQ container never becomes available, wait_rabbitmq_to_start raises and every test in
the module fails from that one event. On master @ e4d3698282346fcd7e496ef668ff517106c84ac5 that cost all 21 tests of
test_storage_rabbitmq/test_system_stop.py from one fixture failure
(report).
Four such events in 21 days, two on master.

The artifact that would say why does not survive the run. rabbitmq.conf sets
log.file = /rabbitmq_logs/rabbit.log and no log.console, so everything goes to that file and
nothing to the console, which is also why the docker logs capture is empty. /rabbitmq_logs was
declared tmpfs, so the log died with the container. cluster.py has always exported
RABBITMQ_LOGS and RABBITMQ_LOGS_FS="bind" and created the host directory, but no compose file
consumed them after 545bb5b replaced the bind mount with tmpfs.
RabbitMQ was the only broker whose *_LOGS export was dead.
rabbit.log has zero hits in the failing run's whole artifact bundle.

This restores the mount in the same ${VAR_FS:-tmpfs} / ${VAR:-} form the siblings use, so an unset
RABBITMQ_LOGS still degrades to tmpfs. /var/lib/rabbitmq stays a tmpfs: it holds Mnesia state, and
persisting it would change test semantics.

test_system_stop.py passes 21/21 and test.py 58/58 with the mount, each producing a rabbit.log
of over 100 KB under _instances*/rabbitmq/logs/, which the integration job already tars. The new
test_rabbitmq_broker_log_is_collected asserts that log exists and is non-empty; reverting the hunk
alone leaves the rest of the module passing and reddens only that test, on an empty log directory.

This neither stops the abort nor explains why the Erlang node failed to register with epmd. #114415
recreates a hung container; this makes the next occurrence diagnosable. #113610 fixed only the second
diagnostics loop of wait_rabbitmq_to_start and is not a container-start fix.

When a RabbitMQ container fails to become available, wait_rabbitmq_to_start
raises and every test in the affected module fails from that one event. The
broker's own log, the artifact that would say why the node never started, does
not survive the run.

rabbitmq.conf sets log.file = /rabbitmq_logs/rabbit.log and no log.console, so
everything the broker logs goes to that file and nothing to the console, which
is also why the docker logs capture produces an empty file. The compose file
declares /rabbitmq_logs as tmpfs, so the log dies with the container.
cluster.py has always exported RABBITMQ_LOGS and RABBITMQ_LOGS_FS="bind" and
created the host directory, but no compose file consumed them after
545bb5b replaced the bind mount with a tmpfs
entry. RabbitMQ was the only broker whose *_LOGS export was dead.

Restore the mount in the same ${VAR_FS:-tmpfs} / ${VAR:-} form the live sibling
compose files use, so an unset RABBITMQ_LOGS still degrades to tmpfs.
/var/lib/rabbitmq stays a tmpfs: it holds Mnesia state, and persisting it
across runs would change test semantics.

The log lands in _instances*/rabbitmq/logs/, which the integration job already
tars.

This neither stops the module abort nor explains why the Erlang node failed to
register with epmd. ClickHouse#114415 recreates a hung container; this makes the next
occurrence diagnosable. ClickHouse#113610 fixed only the second diagnostics loop of
wait_rabbitmq_to_start and is not a container-start fix.
The restored bind mount degrades silently: source: ${RABBITMQ_LOGS:-} falls
back to tmpfs when the variable is unset, and every RabbitMQ module passes
either way, so losing the artifact again would be invisible. That is how the
mount was lost in the first place - 545bb5b
removed it and nothing caught that for six months.

Assert both that rabbit.log exists and that it is non-empty: a bare existence
check would accept the zero-byte file the docker logs capture already produces.
The host path comes from cluster.rabbitmq_logs_dir, which is xdist-worker
scoped, so the test is safe to run in parallel with itself. On failure it
reports the log directory's contents, which distinguishes the tmpfs regression
(empty directory) from a broker that opened the file and wrote nothing.
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review

Two review rounds. Round 1 raised two majors, both fixed; round 2 raised no blocker or major. The
compose hunk is byte-identical to the revision reviewed in round 1 (blob 694f44b81d5686a at both
heads), so the only new content was the added test and a message-only reword.

Finding Verdict
❌ No committed test observed the restored rabbit.log, so a later silent degradation of the mount would be invisible AGREED, fixed. grep -rn 'rabbit.log|rabbitmq_logs_dir' over tests/integration/**/*.py (excluding helpers/cluster.py) returned zero hits against a positive control. source: ${RABBITMQ_LOGS:-} falls back to tmpfs silently, and 545bb5bae91233313868ee4d98d7e6dc6efe20db already deleted this block once without anything catching it for six months. Added test_rabbitmq_broker_log_is_collected, asserting the host file exists and is non-empty. Mutation arm: revert the compose hunk alone and only that test fails, on an empty log directory, while the rest of the module still passes.
❌ A *_LOGS export count stated in the commit message was wrong AGREED, fixed. Two counts were wrong, not one. Measured with a positive control: 11 destination exports (8 string literals plus a dynamic env_variables[f"{prefix}_LOGS"] at cluster.py:2075 firing for the three Prometheus servers, all consumed), of which 9 were consumed and 2 dead. Both counts were removed rather than corrected. The surviving qualitative claim was then verified separately: Kafka and NATS export no *_LOGS variable at all, so RabbitMQ was indeed the only broker with a dead one.
💡 Related pull requests were not visible relationship lines: both full URLs sat inside the template's instruction comment, so the rendered description showed only a shorthand Related: #114415 and #113610 appeared in prose AGREED, fixed. .claude/CLAUDE.md:171-174 requires full GitHub URLs, one relationship per line. Both are now visible and the shorthand is gone.
💡 The linked CI report used a truncated commit SHA AGREED, fixed. The report is an S3 path, not a git lookup: the 12-char form returns 403 while the identical URL with the full 40-char SHA returns 200.
⚠️ Neither commit message carries the CI report URL Not blocking. The repository instruction places that obligation on the pull request description, which carries the full canonical URL. Base rate on the project's own history: 14 of the last 400 master commit messages contain such a URL, and no CI check parses for one.
⚠️ The diagnosability claim is unverified for the failure path: if the Erlang VM dies before its logging app opens log.file, the restored artifact is empty Not blocking. The mount is a necessary precondition either way, and the status quo guarantees zero bytes, so no path is made worse. The description says this makes the next occurrence diagnosable rather than claiming a fix.
💡 test_storage_rabbitmq/test.py fails 8 of 105 under --count 5 --workers 1 Not blocking, and not caused by this change. A pristine-master control at identical shape and load failed identically: the same two tests, the same assertion, eight times, with zero Cannot wait RabbitMQ container in either arm. --count implies --random-order (integration_test_job.py:705) and the test fixes rabbitmq_queue_base, so durable-queue state carries across repeats. No CI job applies --count to this module.
💡 JDBC_DRIVER_LOGS remains a dead export Not blocking, not raised. Pre-existing, non-broker, no user-reachable or CI-observable consequence. Noted here rather than turned into a follow-up.

Verified by reading rather than accepted from the author: the new test's four control-flow states
(absent, zero-byte, late growth, already present), that both assertions are load-bearing and their
failure messages distinguishable, and that a stale log cannot satisfy the test because
os.makedirs without exist_ok raises on a surviving directory; parallel safety, which is structural
because instances_dir is xdist-worker scoped; that the host directory is created before the
container (cluster.py:4008 precedes the compose up); that down --volumes removes anonymous
volumes rather than bind mounts, so the log survives teardown; that the mount target still matches the
image-baked log.file = /rabbitmq_logs/rabbit.log; that both CI collection paths cover
_instances*/rabbitmq/logs/; that the restored block is byte-identical to the one
545bb5bae91233313868ee4d98d7e6dc6efe20db deleted; and that the container runs as root, which retires
a chmod 777 concern raised while planning. ruff passes, and black is enforced by no style check.
/var/lib/rabbitmq correctly stays a tmpfs.

Deliberately unchanged: helpers/cluster.py, rabbitmq.conf, test_cluster_waiters/, and the
RuntimeError text, so historical CI searches keying on Cannot wait RabbitMQ container keep
matching. #114415 rewrites wait_rabbitmq_to_start and deletes a test file; it touches neither file
changed here.

This change does not stop the module abort and does not explain why the Erlang node failed to register
with epmd.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, 100%. praktika run "integration" --test test_storage_rabbitmq/test_system_stop.py --workers 2, then check _instances*/rabbitmq/logs/rabbit.log: absent after every run before the change, present after every run with it. The container-start abort itself is not locally reproducible and this PR does not claim to fix it.
b Root cause explained? Yes. rabbitmq.conf sets log.file = /rabbitmq_logs/rabbit.log with no log.console, so the broker writes only to that file (which is why docker logs is empty too). /rabbitmq_logs was declared tmpfs, so the file died with the container. cluster.py:1747-1748 exports RABBITMQ_LOGS and RABBITMQ_LOGS_FS="bind" and :4008-4009 creates the host directory, but no compose file consumed them after 545bb5b replaced the bind mount with a tmpfs entry. Result: every RabbitMQ startup failure is artifact-free.
c Fix matches root cause? Yes. It re-consumes the dead export at the exact site of the regression. No timeout widened, no assertion relaxed, no retry added, no test skipped, no data reduced.
d Test intent preserved / new tests added? Yes, both. No existing test is weakened, re-marked or removed, so no intent is altered; test_storage_rabbitmq/test.py goes 57 -> 58 passed, the +1 being the new test. Added test_rabbitmq_broker_log_is_collected, which asserts the restored artifact exists and is non-empty, resolving the host path from cluster.rabbitmq_logs_dir rather than a literal, bounded by wall clock rather than an iteration count, and reporting the directory listing on failure so a regression is self-diagnosing. Three mutation arms confirm it is not vacuous: reverting the compose hunk alone reddens it on the missing-file assertion with an empty listing; a zero-byte file reddens it on the size assertion; a non-empty file passes. It is parallel-safe with itself because instances_dir is xdist-worker-scoped (cluster.py:625-628), so it reads only its own fixture's directory and adds no global state.
e Both directions demonstrated? Yes. With the change: 21 passed, rabbit.log 205,822 B. With the hunk reverted and nothing else changed: 21 passed and rabbit.log absent, the host directory created but empty. Both arms pass, so the oracle is not satisfied by "the tests pass".
f Fix is general across code paths? Yes. Every *_LOGS destination cluster.py exports was enumerated, counting the dynamic f"{prefix}_LOGS" site at :2075 that fires for the three Prometheus servers: all were already consumed by their compose file in this identical form except two, RabbitMQ was the only dead broker one, and JDBC_DRIVER_LOGS remains dead (non-broker, no observed consequence, deliberately out of scope). /var/lib/rabbitmq stays a tmpfs on purpose: it holds Mnesia state and binding it would persist broker state across runs. Fixed at the source, the dead export, not guarded at the failure site.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes for the input surface that exists here, the two environment variables. Both states are pinned: with RABBITMQ_LOGS set, docker compose config renders type: bind; with both variables unset it renders type: tmpfs via the ${VAR:-} defaults, exactly as the sibling files degrade. No type surface applies (a YAML config change), so no Nullable / LowCardinality / Array matrix.
h Backward compatible? (maintainer-approved exception only) Yes. Tests and CI harness only: no src/, no setting, no SettingsChangesHistory.cpp, no format or serialization change, no user-visible behaviour. The RuntimeError text is unchanged, so historical CI failure searches keying on Cannot wait RabbitMQ container keep matching by construction.
i Invariants and contracts preserved? Yes. The container's own mkdir -p /rabbitmq_logs && chmod 777 /rabbitmq_logs now targets a host directory that cluster.py:4009 already world-chmods by design; verified empirically, since both modules pass with the bind in place and the log is written by the container's mapped uid. Teardown and cleanup are unaffected across 5+ module runs, and the integration job's sudo chown -R precedes tarring. No lock ordering, atomicity or error-path contract is in scope.

Session id: cron:clickhouse-impl-slot-41:20260812-070002

@clickhouse-gh

clickhouse-gh Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f51d629]

Summary: ✅


AI Review

Summary

This PR restores the RabbitMQ broker log bind mount in the integration harness and adds a regression test that fails if the host-side rabbit.log disappears again. I checked the current diff, prior PR discussion, harness setup and cleanup in cluster.py, the RabbitMQ logging configuration, and the current Praktika report; I did not find any blocking or major issues in the patch as it stands.

Final Verdict

✅ No blocking issues found.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 12, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @nikitamikhaylov, could you review this? The integration harness has exported RABBITMQ_LOGS and RABBITMQ_LOGS_FS=bind and created the host directory all along, but no compose file consumed them after the bind mount was replaced with a tmpfs, so the broker's own rabbit.log is discarded on every run and a container that never starts leaves no artifact explaining why.

@PedroTadim PedroTadim self-assigned this Aug 12, 2026
@PedroTadim

Copy link
Copy Markdown
Member

cc @pamarcos

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Aug 12, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger — f51d629

CI is fully finished on this head and there are no failing checks, so there is nothing to own.

  • 176 check-runs: 31 success, 145 skipped, 0 incomplete.
  • Config Workflow = success, Finish Workflow = success; last completion 2026-08-12T17:28:35Z.
  • praktika result_pr.json: top-level OK, 174 leaves, 0 DROPPED. Every skip carries a reason (Not affected by the changed files and not required x94, no build-affecting changes x25, reused from cache x8, not labeled with 'pr-performance' x6, not a bug-fix PR x5, no tests to run x4, and 4 more), so the run is thin by design for a test-only diff rather than blind.
  • The jobs that actually exercise this change all ran green: Integration tests (arm_binary, distributed plan, 1-4/4), (amd_asan_ubsan, db disk, old analyzer, 1-6/6), (amd_asan_ubsan, flaky), (amd_tsan, 1-6/6), (amd_msan, 1-8/8), plus Style check and Code Review.
  • CIDB carries two Config Workflow / Pre Hooks FAIL rows for this SHA, both from the superseded 08:12Z and 09:09Z attempts that were dropped before the can be tested label was applied. The live attempt at 13:55Z has Pre Hooks = OK and the check concluded success, so no failure is outstanding.
Check / test Reason Owner / fixing PR
— no failing checks on this head —

Session id: cron:our-pr-ci-monitor:20260812-180000

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is good. Only the test for this minor CI improvement is doubtful.

@alexey-milovidov alexey-milovidov self-assigned this Aug 13, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 13, 2026
Merged via the queue into ClickHouse:master with commit fc46996 Aug 13, 2026
528 of 532 checks passed
@groeneai

Copy link
Copy Markdown
Collaborator Author

The test is there because this compose block was already deleted once: 545bb5bae91233313868ee4d98d7e6dc6efe20db removed it in February and nothing caught it for six months. source: ${RABBITMQ_LOGS:-} falls back to tmpfs silently, so every RabbitMQ module keeps passing with no broker log collected. The test is what turns that into a red instead of an invisible regression.

It costs no container time: rabbitmq_cluster is module-scoped and the rest of the module already starts it, so the body is a stat plus a wait that only spends time when the artifact is actually missing.

You merged it, so I am not arguing to keep it. If you would still rather it were gone, say so and I will remove it in a follow-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants