Skip to content

optimize: disable rpcinfo pool by default - #1973

Open
ChocoLZS wants to merge 9 commits into
cloudwego:mainfrom
ChocoLZS:feat/rpcinfo-pool-disabled-by-default
Open

optimize: disable rpcinfo pool by default#1973
ChocoLZS wants to merge 9 commits into
cloudwego:mainfrom
ChocoLZS:feat/rpcinfo-pool-disabled-by-default

Conversation

@ChocoLZS

@ChocoLZS ChocoLZS commented Jun 29, 2026

Copy link
Copy Markdown
Member

What type of PR is this?

optimize

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
zh(optional):

(Optional) Which issue(s) this PR fixes:

Related to #1958

(optional) The PR that updates user documentation:

cloudwego/cloudwego.github.io#1559

@ChocoLZS
ChocoLZS requested review from a team as code owners June 29, 2026 01:59
@ChocoLZS
ChocoLZS marked this pull request as draft June 29, 2026 02:04
@ChocoLZS ChocoLZS changed the title [Diff] Feat/rpcinfo pool disabled by default optimize: disable rpcinfo pool by default Jun 29, 2026
@ChocoLZS
ChocoLZS force-pushed the feat/rpcinfo-pool-disabled-by-default branch 3 times, most recently from 150aa03 to f3c2150 Compare June 29, 2026 05:10
@ChocoLZS
ChocoLZS marked this pull request as ready for review June 30, 2026 10:30
Copilot AI lite review requested due to automatic review settings August 6, 2026 04:51
@ChocoLZS
ChocoLZS force-pushed the feat/rpcinfo-pool-disabled-by-default branch from 1dbfa28 to 8bbc0d8 Compare August 6, 2026 04:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes Kitex’s RPCInfo pooling behavior to be disabled by default to avoid panics/data races when RPCInfo is accessed asynchronously after framework cleanup (per Issue #1958), while preserving opt-in compatibility via environment switches and deprecated APIs.

Changes:

  • Disable RPCInfo pooling by default; add KITEX_ENABLE_RPCINFO_POOL (and keep KITEX_DISABLE_RPCINFO_POOL) to control the legacy pooling during migration.
  • Guard server-side tracer finish/reset logic so RPCStats isn’t reset when pooling is disabled (avoids racing with async readers).
  • Expand unit tests across client/server/transports to assert RPCInfo remains readable when pooling is disabled, and adjust existing tests to account for the new default.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
server/service_inline_test.go Adds async RPCInfo-read test around service-inline server finish lifecycle.
server/server_test.go Ensures tests that require pooling explicitly enable/restore it.
server/local_caller_test.go Adds async RPCInfo-read test for LocalCaller finish lifecycle.
pkg/rpcinfo/rpcstats.go Adds deprecation/migration notes to legacy stats/event pooling.
pkg/rpcinfo/rpcinfo.go Disables pooling by default; adds env-based initialization and deprecation notes.
pkg/rpcinfo/rpcinfo_test.go Adds tests for env initialization behavior and precedence.
pkg/rpcinfo/rpcinfo_inline.go Adds deprecation notes for inline RPCInfo pooling/recycling APIs.
pkg/rpcinfo/rpcconfig.go Adds deprecation/migration notes to rpcConfig pooling/recycling.
pkg/rpcinfo/remoteinfo/remoteInfo.go Adds deprecation/migration notes to remoteInfo pooling/recycling.
pkg/rpcinfo/invocation.go Adds deprecation/migration notes to invocation pooling/recycling.
pkg/rpcinfo/endpointInfo.go Adds deprecation/migration notes to endpointInfo pooling/recycling.
pkg/rpcinfo/ctx.go Adds deprecation notes to PutRPCInfo (legacy recycling).
pkg/rpcinfo/ctx_test.go Refactors RPCInfo creation helper and adds pooling on/off assertions.
pkg/remote/trans/nphttp2/server_handler_test.go Adds coverage ensuring RPCInfo remains readable after unary finish when pooling is disabled.
pkg/remote/trans/netpollmux/server_handler.go Avoids resetting RPCStats on finish when pooling is disabled.
pkg/remote/trans/netpollmux/server_handler_test.go Adds mux-server test ensuring RPCInfo readability after finish with pooling disabled.
pkg/remote/trans/default_server_handler.go Avoids resetting RPCStats on finish when pooling is disabled; documents rationale.
pkg/remote/trans/default_server_handler_test.go Updates InitOrReset mock and adds test for readability after OnRead with pooling disabled.
client/service_inline_test.go Adds client-side service-inline test asserting RPCInfo remains readable after call.
client/rpctimeout_test.go Adds helpers and a timeout-path test asserting RPCInfo remains readable post-timeout with pooling disabled.
client/client_test.go Adds multi-scenario lifecycle test ensuring async RPCInfo reads don’t panic across retry paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/rpcinfo/ctx_test.go Outdated
func newCtxTestRPCInfo() rpcinfo.RPCInfo {
method := "TestMethod"
svcName := "TestServiceName"
netAddr := utils.NewNetAddr("TestNetWork", "TestAddress")
Comment thread client/client_test.go Outdated
Comment on lines +197 to +199
func TestCallDisablePoolKeepsRPCInfoReadableAcrossLifecycle(t *testing.T) {
mockErr := errors.New("mock")
testcases := []struct {
Comment thread server/service_inline_test.go Outdated
Comment on lines +198 to +201
func TestServiceInlineDisablePoolNoRaceWithAsyncServerRPCInfoReadDuringFinish(t *testing.T) {
stop := make(chan struct{})
started := make(chan struct{})
done := make(chan any, 1)
Comment thread server/local_caller_test.go Outdated
Comment on lines +310 to +313
func TestLocalCallerDisablePoolNoRaceWithAsyncRPCInfoReadDuringFinish(t *testing.T) {
stop := make(chan struct{})
started := make(chan struct{})
done := make(chan any, 1)
Comment on lines +214 to +216
func TestDefaultSvrTransHandlerDisablePoolKeepsRPCInfoReadableAfterOnRead(t *testing.T) {
buf := remote.NewReaderWriterBuffer(1024)
ext := &MockExtension{
Comment on lines +558 to +559
func TestDisablePoolKeepsRPCInfoReadableAfterUnaryFinish(t *testing.T) {
opt := newMockServerOption()
Comment on lines +297 to +299
func TestMuxSvrOnReadDisablePoolKeepsRPCInfoReadableAfterFinish(t *testing.T) {
const body = "hello world"
buf := netpoll.NewLinkBuffer(1024)
Comment thread client/service_inline_test.go Outdated
Comment on lines +87 to +90
func TestServiceInlineDisablePoolKeepsClientRPCInfoReadableAfterCall(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

Comment thread client/rpctimeout_test.go Outdated
Comment on lines +191 to +196
func TestRpcTimeoutMWDisablePoolKeepsRPCInfoReadableAfterTimeout(t *testing.T) {
timeoutCtxCh := make(chan context.Context, 1)
stop := make(chan struct{})
started := make(chan struct{})
done := make(chan any, 1)
mw := rpcTimeoutMW(context.Background())
Copilot AI review requested due to automatic review settings August 6, 2026 07:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated no new comments.

Suppressed comments (8)

server/local_caller_test.go:310

  • Typo in test name: "Aceess" should be "Access" for readability and to avoid confusing go test output.
func TestRPCInfoAceessNoRace(t *testing.T) {

client/service_inline_test.go:87

  • Typo in test name: "Aceess" should be "Access" for readability and to avoid confusing go test output.
func TestServiceInlineRPCInfoAceessNoRace(t *testing.T) {

client/rpctimeout_test.go:191

  • Typo in test name: "Aceess" should be "Access" for readability and to avoid confusing go test output.
func TestRpcTimeoutMWRPCInfoAceessNoRace(t *testing.T) {

client/client_test.go:197

  • Typo in test name: "Aceess" should be "Access" for readability and to avoid confusing go test output.
func TestClientRPCInfoAceessNoRace(t *testing.T) {

pkg/remote/trans/netpollmux/server_handler_test.go:297

  • Typo in test name: "Aceess" should be "Access" for readability and to avoid confusing go test output.
func TestRPCInfoAceessNoRace(t *testing.T) {

server/service_inline_test.go:198

  • Typo in test name: "Aceess" should be "Access" for readability and to avoid confusing go test output.
func TestRPCInfoAceessNoRace(t *testing.T) {

pkg/remote/trans/default_server_handler_test.go:214

  • Typo in test name: "Aceess" should be "Access" for readability and to avoid confusing go test output.
func TestRPCInfoAceessNoRace(t *testing.T) {

pkg/remote/trans/nphttp2/server_handler_test.go:558

  • Typo in test name: "Aceess" should be "Access" for readability and to avoid confusing go test output.
func TestRPCInfoAceessNoRace(t *testing.T) {

Copilot AI review requested due to automatic review settings August 6, 2026 08:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated no new comments.

Suppressed comments (10)

server/service_inline_test.go:143

  • Typo in test name: "Aceess" should be "Access" for readability and consistency (e.g., grep/test filtering).
func TestRPCInfoAceessNoRace(t *testing.T) {

server/local_caller_test.go:274

  • reader is assigned inside middleware; if the middleware isn't executed, reader stays nil and reader.StopAndAssert will panic with a nil-pointer dereference. Add an explicit assertion before stopping.
	reader.StopAndAssert(t)

server/service_inline_test.go:169

  • reader is assigned inside middleware; if the middleware chain changes or isn't executed, reader stays nil and reader.StopAndAssert will panic with a nil-pointer dereference. Add an explicit assertion before stopping.
	reader.StopAndAssert(t)

server/local_caller_test.go:255

  • Typo in test name: "Aceess" should be "Access" for readability and consistency (e.g., grep/test filtering).
func TestRPCInfoAceessNoRace(t *testing.T) {

pkg/remote/trans/nphttp2/server_handler_test.go:507

  • Typo in test name: "Aceess" should be "Access" for readability and consistency (e.g., grep/test filtering).
func TestRPCInfoAceessNoRace(t *testing.T) {

pkg/remote/trans/netpollmux/server_handler_test.go:246

  • Typo in test name: "Aceess" should be "Access" for readability and consistency (e.g., grep/test filtering).
func TestRPCInfoAceessNoRace(t *testing.T) {

pkg/remote/trans/default_server_handler_test.go:163

  • Typo in test name: "Aceess" should be "Access" for readability and consistency (e.g., grep/test filtering).
func TestRPCInfoAceessNoRace(t *testing.T) {

client/client_test.go:186

  • Typo in test name: "Aceess" should be "Access" for readability and consistency (e.g., grep/test filtering).
func TestClientRPCInfoAceessNoRace(t *testing.T) {

client/service_inline_test.go:88

  • Typo in test name: "Aceess" should be "Access" for readability and consistency (e.g., grep/test filtering).
func TestServiceInlineRPCInfoAceessNoRace(t *testing.T) {

client/rpctimeout_test.go:118

  • Typo in test name: "Aceess" should be "Access" for readability and consistency (e.g., grep/test filtering).
func TestRpcTimeoutMWRPCInfoAceessNoRace(t *testing.T) {

Comment thread pkg/rpcinfo/rpcinfo.go Outdated
junliurs
junliurs previously approved these changes Aug 7, 2026
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 18.18182% with 63 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.95%. Comparing base (8bb270e) to head (b6bf232).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
internal/test/rpcinfotest/rpcinfo.go 0.00% 63 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1973      +/-   ##
==========================================
- Coverage   62.95%   62.95%   -0.01%     
==========================================
  Files         394      397       +3     
  Lines       30267    30416     +149     
==========================================
+ Hits        19056    19148      +92     
- Misses       9924     9984      +60     
+ Partials     1287     1284       -3     
Flag Coverage Δ
integration 51.85% <92.85%> (-0.02%) ⬇️
unit 53.52% <7.79%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants