Skip to content

fix: add isAvailable check in getInvoker to prevent idle eviction race condition#140

Merged
wardseptember merged 1 commit into
trpc-group:masterfrom
Phoebe0126:fix/rpcclient-idle-eviction-race-condition
May 7, 2026
Merged

fix: add isAvailable check in getInvoker to prevent idle eviction race condition#140
wardseptember merged 1 commit into
trpc-group:masterfrom
Phoebe0126:fix/rpcclient-idle-eviction-race-condition

Conversation

@Phoebe0126
Copy link
Copy Markdown
Contributor

What

Add an isAvailable() check on the fast path of DefClusterInvoker.getInvoker().

Why

When the idle scanner (scanUnusedClient) closes an RpcClient, there is a time window between client.close() and the closeFuture callback removing the invoker from invokerCache. During this window, business threads can obtain a stale invoker whose underlying transport is already shut down, resulting in Client stop errors.

How

If the cached invoker's RpcClient is no longer available (STOPPING/STOPPED state), fall through to createInvoker() which rebuilds a new RpcClient under proper synchronization.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Phoebe0126
Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@Phoebe0126 Phoebe0126 force-pushed the fix/rpcclient-idle-eviction-race-condition branch from 61e84d6 to 920dd3a Compare May 7, 2026 06:42
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.84151%. Comparing base (953a3c6) to head (f4b3873).

Additional details and impacted files

Impacted file tree graph

@@                  Coverage Diff                  @@
##                master        #140         +/-   ##
=====================================================
- Coverage     85.86041%   85.84151%   -0.01891%     
+ Complexity        4325        4321          -4     
=====================================================
  Files              436         436                 
  Lines            14371       14373          +2     
  Branches          1286        1287          +1     
=====================================================
- Hits             12339       12338          -1     
- Misses            2032        2035          +3     
Files with missing lines Coverage Δ
...ncent/trpc/core/cluster/def/DefClusterInvoker.java 75.96154% <100.00000%> (+1.45174%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Phoebe0126 Phoebe0126 force-pushed the fix/rpcclient-idle-eviction-race-condition branch 2 times, most recently from b632803 to 2450a32 Compare May 7, 2026 07:15
@Phoebe0126 Phoebe0126 force-pushed the fix/rpcclient-idle-eviction-race-condition branch from 2450a32 to f4b3873 Compare May 7, 2026 07:17
@wardseptember wardseptember merged commit 063c0d2 into trpc-group:master May 7, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants