Skip to content

Handle type state being undefined for very old queues (backport #14211) #14214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2025

Conversation

mergify[bot]
Copy link

@mergify mergify bot commented Jul 11, 2025

Proposed Changes

Field #amqqueue.type_state can be undefined for queues declared on old RabbitMQ versions before 3.8.0. Ensure amqqueue:get_type_state/1 always returns a map according to its type spec to make life of calling code easier.

Before this change the newly introduced emit_queue_info crashed on such very old queues when calling /metrics/per-object prometheus endpoint

2025-07-11 09:42:43.972536+02:00 [error] <0.3422.0>   crasher:
2025-07-11 09:42:43.972536+02:00 [error] <0.3422.0>     initial call: cowboy_stream_h:request_process/3
2025-07-11 09:42:43.972536+02:00 [error] <0.3422.0>     pid: <0.3422.0>
2025-07-11 09:42:43.972536+02:00 [error] <0.3422.0>     registered_name: []
2025-07-11 09:42:43.972536+02:00 [error] <0.3422.0>     exception error: bad map: undefined
2025-07-11 09:42:43.972536+02:00 [error] <0.3422.0>       in function  prometheus_rabbitmq_core_metrics_collector:'-emit_queue_info/3-fun-0-'/3
2025-07-11 09:42:43.972536+02:00 [error] <0.3422.0>       in call from lists:foldl/3 (lists.erl, line 2146)
2025-07-11 09:42:43.972536+02:00 [error] <0.3422.0>       in call from prometheus_rabbitmq_core_metrics_collector:emit_queue_info/3 (prometheus_rabbitmq_core_metrics_collector.erl, line 453)
2025-07-11 09:42:43.972536+02:00 [error] <0.3422.0>       in call from prometheus_rabbitmq_core_metrics_collector:collect_mf/2 (prometheus_rabbitmq_core_metrics_collector.erl, line 322)
2025-07-11 09:42:43.972536+02:00 [error] <0.3422.0>       in call from prometheus_collector:collect_mf/3 (src/prometheus_collector.erl, line 173)
2025-07-11 09:42:43.972536+02:00 [error] <0.3422.0>       in call from prometheus_registry:'-collect/2-lc$^0/1-0-'/3 (src/prometheus_registry.erl, line 86)
2025-07-11 09:42:43.972536+02:00 [error] <0.3422.0>       in call from prometheus_registry:collect/2 (src/prometheus_registry.erl, line 87)
2025-07-11 09:42:43.972536+02:00 [error] <0.3422.0>       in call from prometheus_text_format:format/1 (src/formats/prometheus_text_format.erl, line 73)

Types of Changes

What types of changes does your code introduce to this project?
Put an x in the boxes that apply

  • Bug fix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause an observable behavior change in existing systems)
  • Documentation improvements (corrections, new content, etc)
  • Cosmetic change (whitespace, formatting, etc)
  • Build system and/or CI

Checklist

Put an x in the boxes that apply.
You can also fill these out after creating the PR.
If you're unsure about any of them, don't hesitate to ask on the mailing list.
We're here to help!
This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally with my changes
  • If relevant, I have added necessary documentation to https://github.com/rabbitmq/rabbitmq-website
  • If relevant, I have added this change to the first version(s) in release-notes that I expect to introduce it

Further Comments


This is an automatic backport of pull request #14211 done by [Mergify](https://mergify.com).

Field #amqqueue.type_state can be undefined for queues declared on old
RabbitMQ versions before 3.8.0. Ensure `amqqueue:get_type_state/1`
always returns a map according to its type spec to make life of
calling code easier.

(cherry picked from commit cc95d37)
@michaelklishin michaelklishin added this to the 4.1.3 milestone Jul 11, 2025
@michaelklishin michaelklishin merged commit 9bcbad1 into v4.1.x Jul 15, 2025
546 of 547 checks passed
@michaelklishin michaelklishin deleted the mergify/bp/v4.1.x/pr-14211 branch July 15, 2025 02:11
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