fix: ensure subsequent slots execute after PriorityWaitException in FlowSlot#3607
Open
daguimu wants to merge 1 commit intoalibaba:masterfrom
Open
fix: ensure subsequent slots execute after PriorityWaitException in FlowSlot#3607daguimu wants to merge 1 commit intoalibaba:masterfrom
daguimu wants to merge 1 commit intoalibaba:masterfrom
Conversation
…lowSlot When FlowSlot.checkFlow() throws PriorityWaitException (for prioritized requests that pass by waiting), fireEntry() was never called, causing all subsequent slots in the chain (DefaultCircuitBreakerSlot, DegradeSlot) to be skipped. This means circuit breaker checks were bypassed for priority-waited requests. Catch PriorityWaitException in FlowSlot.entry(), execute downstream slots via fireEntry(), then re-throw the exception for StatisticSlot to handle. If a downstream slot throws BlockException (e.g. circuit breaker is open), the BlockException propagates instead. Fixes alibaba#3604
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
FlowSlot.checkFlow()throwsPriorityWaitException(for prioritized requests that pass flow control by waiting for a future token),fireEntry()is never called. This causes all subsequent slots in the chain to be skipped.The default slot chain order is:
When
PriorityWaitExceptionis thrown,DefaultCircuitBreakerSlotandDegradeSlotare never executed. This means circuit breaker checks are bypassed for priority-waited requests — even if a circuit breaker is in the OPEN state, the request passes through unchecked.Root Cause
In
FlowSlot.entry(),checkFlow()is called beforefireEntry(). WhencheckFlow()throwsPriorityWaitException, the exception propagates immediately andfireEntry()(which chains to downstream slots) is never reached:Fix
Catch
PriorityWaitExceptioninFlowSlot.entry(), execute downstream slots viafireEntry(), then re-throw the exception forStatisticSlotto handle:If a downstream slot throws
BlockException(e.g., circuit breaker is OPEN), theBlockExceptionpropagates instead ofPriorityWaitException, andStatisticSlothandles it as a block.Tests Added
testPriorityWaitExceptionStillFiresSubsequentSlots: Verifies that downstream slots are executed whenPriorityWaitExceptionis thrown, and the exception is still re-thrown.testPriorityWaitWithDownstreamBlockPropagatesBlockException: Verifies that if a downstream slot throwsBlockExceptionafter a priority wait, theBlockExceptiontakes precedence.All 225 tests in sentinel-core pass.
Impact
Only affects
FlowSlot.entry()behavior whenPriorityWaitExceptionis thrown (prioritized QPS-based flow control with token waiting). Normal flow control (pass/block) is unchanged.Fixes #3604