[FLINK-40326][core] Do not over-grant permits in GatedRateLimiter - #28920
[FLINK-40326][core] Do not over-grant permits in GatedRateLimiter#28920Savonitar wants to merge 1 commit into
Conversation
The decrement in acquire() was generalized from a constant 1 to numberOfEvents as part of FLIP-535, but the gate was left closing only at capacityLeft <= 0, so a cycle can admit more events than capacityPerCycle. The gate is now closed unless the capacity left covers the whole request.
|
Thanks for the fix. Two questions:
So we neither reach Fine with me if this is the accepted behaviour. |
|
@1996fanrui thanks for the questions and feedback.
2.That one is pre-existing, not introduced here: before the PR it produced [10000, 10000, ...], now it produces [0, 10000, ...]. So this is an iterative improvement rather than a complete fix, a strict cap would need a redesign. This PR fixes three separate things: the gate, an NPE when a checkpoint completes before the first acquire(), and a missing argument check. I'm happy to drop the gate change and keep the overshoot if you think that's better by design. WDYT? |
What is the purpose of the change
The decrement in acquire() was generalized from a constant 1 to numberOfEvents as part of FLIP-535, but the gate was left closing only at capacityLeft <= 0, so a cycle can admit more events than capacityPerCycle. The gate is now closed unless the capacity left covers the whole request.
Brief change log
Verifying this change
This change added the following tests:
GatedRateLimiterTest, one per defect, each fails against the unfixed codeDoes this pull request potentially affect one of the following parts:
@Public(Evolving): (yes, but Javadoc only )Documentation
Was generative AI tooling used to co-author this PR?
Generated-by: [Tool Name and Version]