[ISSUE #9983] Prohibit CallerRunsPolicy in NettyRemotingServer to prevent blocking IO threads#10205
Open
daguimu wants to merge 1 commit intoapache:developfrom
Open
[ISSUE #9983] Prohibit CallerRunsPolicy in NettyRemotingServer to prevent blocking IO threads#10205daguimu wants to merge 1 commit intoapache:developfrom
daguimu wants to merge 1 commit intoapache:developfrom
Conversation
…to prevent blocking IO threads Add defensive validation in registerProcessor and registerDefaultProcessor to reject executors configured with CallerRunsPolicy, which would block Netty IO threads when the thread pool is exhausted. Fixes apache#9983
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 a custom
ExecutorServicewithCallerRunsPolicyis registered viaregisterProcessororregisterDefaultProcessor, and the thread pool becomes exhausted, the rejected task is executed on the caller thread — which is the Netty IO EventLoop thread. This blocks the IO thread from processing other requests/heartbeats, causing severe performance degradation or node unavailability.Root Cause
No validation exists on the
RejectedExecutionHandlerof the provided executor inregisterProcessor/registerDefaultProcessor. Users can silently misconfigure aThreadPoolExecutorwithCallerRunsPolicy, leading to IO thread blocking under high concurrency.Fix
Added a
rejectCallerRunsPolicyvalidation method that checks if the executor is aThreadPoolExecutorwithCallerRunsPolicyand throwsIllegalArgumentExceptionfor fast-fail. The check is applied to:NettyRemotingServer#registerProcessorNettyRemotingServer#registerDefaultProcessorSubRemotingServer#registerProcessorSubRemotingServer#registerDefaultProcessorTests Added
testRegisterProcessorRejectsCallerRunsPolicy— VerifiesregisterProcessorthrowsIllegalArgumentExceptionwhen CallerRunsPolicy is usedtestRegisterDefaultProcessorRejectsCallerRunsPolicy— VerifiesregisterDefaultProcessorthrowsIllegalArgumentExceptionwhen CallerRunsPolicy is usedtestRegisterProcessorAllowsNonCallerRunsPolicy— Verifies AbortPolicy (default) is accepted without errortestRegisterProcessorAllowsNullExecutor— Verifies null executor (falls back to publicExecutor) works correctlytestRegisterProcessorAllowsFixedThreadPool— Verifies standard FixedThreadPool is acceptedImpact
Fixes #9983