Skip to content
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

Prevent node from booting if credit_flow_default_credit is not valid #13046

Merged
merged 6 commits into from
Jan 12, 2025

Conversation

JimmyWang6
Copy link
Contributor

@JimmyWang6 JimmyWang6 commented Jan 10, 2025

Proposed Changes

As mention in previous discussion thread, this PR add adds validation for
param credit_flow_default_credit, and change it to default value for the following two cases:

  1. MoreCreditAfter larger than InitialCredit
  2. Negative value

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.

Further Comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution
you did and what alternatives you considered, etc.

@JimmyWang6 JimmyWang6 marked this pull request as draft January 10, 2025 06:55
@JimmyWang6 JimmyWang6 marked this pull request as ready for review January 10, 2025 07:17
@JimmyWang6 JimmyWang6 marked this pull request as draft January 10, 2025 07:17
@JimmyWang6 JimmyWang6 marked this pull request as ready for review January 10, 2025 08:01
@JimmyWang6 JimmyWang6 changed the title WIP Fix MoreCreditAfter could larger than InitialCredit Fix MoreCreditAfter could larger than InitialCredit Jan 10, 2025
@@ -300,6 +300,8 @@
%% 100 ms
-define(BOOT_STATUS_CHECK_INTERVAL, 100).

-define(DEFAULT_CREDIT, {400, 200}).
Copy link
Member

@ansd ansd Jan 10, 2025

Choose a reason for hiding this comment

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

We already have this default defined in

{credit_flow_default_credit, {400, 200}},

Defining yet another default in another place (rabbit.erl) for the case of user misconfiguration is hard to justify. As @michaelklishin suggested in the discussion, instead of emitting a warning, let's make the node boot fail by throw()ing an error.

@JimmyWang6 JimmyWang6 requested a review from ansd January 11, 2025 07:01
@michaelklishin michaelklishin changed the title Fix MoreCreditAfter could larger than InitialCredit Prevent node from booting if credit_flow_default_credit does not match the expected format Jan 11, 2025
@michaelklishin michaelklishin changed the title Prevent node from booting if credit_flow_default_credit does not match the expected format Prevent node from booting if credit_flow_default_credit is not valid Jan 11, 2025
michaelklishin added a commit that referenced this pull request Jan 12, 2025
@michaelklishin michaelklishin merged commit 0135f62 into rabbitmq:main Jan 12, 2025
1 check passed
@michaelklishin michaelklishin added this to the 4.1.0 milestone Jan 12, 2025
@michaelklishin
Copy link
Member

Finished and merged in #13055. I will backport it manually to v4.0.x. Thank you for contributing to RabbitMQ.

michaelklishin added a commit that referenced this pull request Jan 12, 2025
(cherry picked from commit 3dd3433)
@JimmyWang6
Copy link
Contributor Author

Finished and merged in #13055. I will backport it manually to v4.0.x. Thank you for contributing to RabbitMQ.

Awesome. thanks for your help!

@ansd
Copy link
Member

ansd commented Jan 12, 2025

This PR makes booting the node fail if MoreCreditAfter == InitialCredit. While not being the most performant setting, it's a valid setting where the node should succeed to boot.

@michaelklishin
Copy link
Member

@ansd correct, I have considered this and have left the original condition in place. Let's change that to "lesser or equal".

michaelklishin added a commit that referenced this pull request Jan 12, 2025
michaelklishin added a commit that referenced this pull request Jan 12, 2025
@michaelklishin
Copy link
Member

Done.

mkuratczyk added a commit that referenced this pull request Jan 14, 2025
#13046
introduced additional checks which prevent setting
`{credit_flow_default_credit,{0,0}}`.

Setting credits to zero allows disabling the credit flow mechanism
(we use it in our benchmarks and mention for example in
https://www.rabbitmq.com/blog/2023/03/21/native-mqtt)
mkuratczyk added a commit that referenced this pull request Jan 14, 2025
#13046
introduced additional checks which prevent setting
`{credit_flow_default_credit,{0,0}}`.

Setting credits to zero allows disabling the credit flow mechanism
(we use it in our benchmarks and mention for example in
https://www.rabbitmq.com/blog/2023/03/21/native-mqtt)
mergify bot pushed a commit that referenced this pull request Jan 14, 2025
#13046
introduced additional checks which prevent setting
`{credit_flow_default_credit,{0,0}}`.

Setting credits to zero allows disabling the credit flow mechanism
(we use it in our benchmarks and mention for example in
https://www.rabbitmq.com/blog/2023/03/21/native-mqtt)

(cherry picked from commit a4634d3)
mkuratczyk added a commit that referenced this pull request Jan 14, 2025
#13046
introduced additional checks which prevent setting
`{credit_flow_default_credit,{0,0}}`.

Setting credits to zero allows disabling the credit flow mechanism
(we use it in our benchmarks and mention for example in
https://www.rabbitmq.com/blog/2023/03/21/native-mqtt)

(cherry picked from commit a4634d3)

Co-authored-by: Michal Kuratczyk <[email protected]>
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.

3 participants