Setting MoreCreditAfter larger than InitialCredit may cause unrecoverable flow control #13041
-
RabbitMQ series4.0.x Operating system (distribution) usedunbuntu 22.0.4 How is RabbitMQ deployed?Generic binary package What would you like to suggest for a future version of RabbitMQ?Describe the bugIn our production environment, we set credit_flow_default_credit to {200, 400}. At the beginning, everything seemed well and nothing unusual happened. However, after the client was restarted, new connections entered a flow status and couldn't recover because the credit_flow_default_credit configuration had started to take effect.Reproduction steps
Expected behaviorFlow control as usualAdditional contextCould we incorporate additional parameter validation to guarantee that `InitialCredit` is not set to a value less than `MoreCreditAfter` ? I will submit a PR to enhance validation later. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
@JimmyWang6
You are not backing this claim with any evidence. How did you observe that the client "has entered an unrecoverable flow"? I will wager a guess: you look at the management UI and see the connection reported as Transient flow control can go in and out of effect many times, in fact, a hundred times a second. Which is why after trying to add logging for it twice, we have concluded that there is no practical way of doing that because both the logger will be overwhelmed, and the throughput will inevitably be affected. The way I am quite certain that there is no issue at all, you simply haven't loaded the connection/node enough before to see this "permanent" transient flow control in the UI, which is not permanent in the sense that the publisher is making constant progress at its peak capacity. Which, by the way, you don't be able to significantly boost with the credit flow settings. It is If you need to boost per-connection throughput significantly, the answer is not to mess with credit flow. The answer is using streams or superstreams with their native protocol clients, some of which can sustain throughput of up to 1M messages per second per connection for as long as your disks and network links can keep up. |
Beta Was this translation helpful? Give feedback.
-
We can but I don't see why we would. Tweaking and bumping credit flow is usually the wrong thing to do. Such validation will not serve any purpose. In a small number of cases where bumping credit flow makes a reasonable difference, it always was
Again, people have been trying to bump credit flow as early as 2009 or so, and it very rarely makes a big difference without causing memory footprint swings that. |
Beta Was this translation helpful? Give feedback.
-
The default setting is To provide an example: The reader proc sends messages to the channel proc. The reader proc has initially 400 credits. After the channel proc received the first 200 messages from the reader proc, the channel proc grants another 200 credits to the reader proc. If you now flip Hence, setting InitialCredit to be smaller than MoreCreditAfter is simply a misconfiguration. Now of course we can discuss whether RabbitMQ should refuse to boot if it notices this misconfiguration, and in my opinion we can add a check to prevent users from this misconfiguration. |
Beta Was this translation helpful? Give feedback.
The default setting is
{credit_flow_default_credit, {400, 200}}
and has the form{InitialCredit, MoreCreditAfter}
.To provide an example: The reader proc sends messages to the channel proc. The reader proc has initially 400 credits. After the channel proc received the first 200 messages from the reader proc, the channel proc grants another 200 credits to the reader proc.
If you now flip
{InitialCredit, MoreCreditAfter}
as you did in this issue, it means that the reader proc has only 200 credits initially and that the channel will grant new credits only after the channel receives 400 messages from the reader. However, this will never happen because the reader blocks after having sent 200 m…