Fix Reactor adapter async-context race in SentinelReactorSubscriber.currentContext#3624
Open
wuwen5 wants to merge 1 commit into
Open
Fix Reactor adapter async-context race in SentinelReactorSubscriber.currentContext#3624wuwen5 wants to merge 1 commit into
SentinelReactorSubscriber.currentContext#3624wuwen5 wants to merge 1 commit into
Conversation
…currentContext` (#1) * Initial plan * fix(reactor): avoid async context race in currentContext and add regression test Agent-Logs-Url: https://github.com/wuwen5/Sentinel/sessions/1d7e9bbc-a643-4695-a906-b0575add87f0 Co-authored-by: wuwen5 <5037807+wuwen5@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: wuwen5 <5037807+wuwen5@users.noreply.github.com>
|
|
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.
Describe what this PR does / why we need it
SentinelReactorSubscriber.currentContext()could throwNullPointerException: valueunder concurrent termination because it readcurrentEntry.getAsyncContext()twice. IfAsyncEntry.exit()cleared async context between those reads,Context.put(...)receivednull.Race fix in context propagation
currentContext()to use the already-captured localsentinelContextwhen putting Sentinel context into ReactorContext.currentEntry.getAsyncContext().Targeted regression coverage
SentinelReactorSubscriberTestin the reactor adapter test module.currentContext()captures a non-null async context, a concurrent cancel path exits/clears context, andcurrentContext()must still propagate the captured value (the pre-fix path would passnulltoContext.put).某Redis Reactive请求先发生异常
→ Reactor进入onError链路
→ SentinelReactorSubscriber.currentContext()
→ Context.put(null)
→ NullPointerException
→ 未捕获异常打穿Netty EventExecutor
→ lettuce-eventExecutorLoop-1-4 号线程死亡(threadStatus=2)
→ executor terminated
→ 后续Redis Reactive callback无法调度
→ Spring Session Reactive Pipeline部分卡死 (重启恢复)
Does this pull request fix one issue?
fixed #3556 #1907
This pull request was created from Copilot chat.