Skip to content

balancer/rls: fix goroutine leak in control_channel_test - #8898

Merged
eshitachandwani merged 3 commits into
grpc:masterfrom
maishivamhoo123:fix-rls-goroutine-leak
Feb 24, 2026
Merged

balancer/rls: fix goroutine leak in control_channel_test#8898
eshitachandwani merged 3 commits into
grpc:masterfrom
maishivamhoo123:fix-rls-goroutine-leak

Conversation

@maishivamhoo123

Copy link
Copy Markdown
Contributor

Description

This PR fixes a goroutine leak in balancer/rls/control_channel_test.go.
The leak occurred because an unbuffered channel was used in a test with time.After. If the test timed out, the receiver would stop listening, causing the sender (the callback) to block forever. This change buffers the channel (make(chan error, 1)), allowing the goroutine to exit even if the receiver is gone.

Related Issue

Fixes #8892

Testing

  • Ran go test -v ./balancer/rls/... (Passed)
  • Ran ./scripts/vet.sh (Passed)
  • Ran go test -race ./balancer/rls/... (Passed)

RELEASE NOTES: n/a

@linux-foundation-easycla

linux-foundation-easycla Bot commented Feb 11, 2026

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: maishivamhoo123 / name: Shivam Kumar (ae02009)

@codecov

codecov Bot commented Feb 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.42%. Comparing base (2c113ab) to head (ae02009).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8898      +/-   ##
==========================================
+ Coverage   81.41%   81.42%   +0.01%     
==========================================
  Files         416      416              
  Lines       33429    33429              
==========================================
+ Hits        27216    27221       +5     
+ Misses       4660     4655       -5     
  Partials     1553     1553              

see 16 files with indirect coverage changes

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

@maishivamhoo123

Copy link
Copy Markdown
Contributor Author

@eshitachandwani ma'am i didn't change anything
advancedtls_test.go:895: Server side error mismatch, got true, want false FAIL FAIL google.golang.org/grpc/security/advancedtls 6.922s ? google.golang.org/grpc/security/advancedtls/internal/testutils [no test files] FAIL Error: Process completed with exit code 1.
in this part i just changed this file ‎balancer/rls/control_channel_test.go
and all the test got passed in local machine can you please help why it is falling here ?

@eshitachandwani

Copy link
Copy Markdown
Member

Hey @maishivamhoo123 , the tests are failing on master too, so it is not because of your changes. We will be fixing it soon.

@maishivamhoo123

Copy link
Copy Markdown
Contributor Author

@eshitachandwani can i also work on that issue ma'am?

@maishivamhoo123

maishivamhoo123 commented Feb 11, 2026

Copy link
Copy Markdown
Contributor Author

@eshitachandwani and I have one more question if it is falling here . what it didn't fail during testing in my local machine?
i run all the test
Ran go test -v ./balancer/rls/... (Passed) Ran ./scripts/vet.sh (Passed) Ran go test -race ./balancer/rls/... (Passed)

@eshitachandwani

Copy link
Copy Markdown
Member

@eshitachandwani can i also work on that issue ma'am?

Hey , thank you for volunteering to help but I am already working on it.

@eshitachandwani

Copy link
Copy Markdown
Member

@eshitachandwani and I have one more question if it is falling here . what it didn't fail during testing in my local machine? i run all the test Ran go test -v ./balancer/rls/... (Passed) Ran ./scripts/vet.sh (Passed) Ran go test -race ./balancer/rls/... (Passed)

The command you used will only run tests balancer/rls . To run the tests in security/advancedtls we need to follow this :

cd security/advancedtls
go test ./... // this runs all the tests in the directory you are in

@eshitachandwani

Copy link
Copy Markdown
Member

Hey @maishivamhoo123 , the tests have been fixed, please merge master to get the tests passing on your PR.

@maishivamhoo123

Copy link
Copy Markdown
Contributor Author

@eshitachandwani @team can you please review the PR?

@eshitachandwani

eshitachandwani commented Feb 12, 2026

Copy link
Copy Markdown
Member

/gemini review

@eshitachandwani eshitachandwani self-assigned this Feb 14, 2026
@mbissa mbissa assigned eshitachandwani and unassigned mbissa Feb 24, 2026
@easwars

easwars commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request correctly fixes a potential goroutine leak in the RLS control channel tests. The issue stemmed from using an unbuffered channel to communicate results from a goroutine back to the main test goroutine, which was also waiting on a timeout. In the case of a timeout, the main goroutine would stop listening on the channel, causing the worker goroutine to block indefinitely when trying to send the result. By changing the channel to be buffered with a size of 1, the worker goroutine can send its result and terminate, even if the receiver is no longer present. The changes are applied consistently where this pattern occurs and are a good fix for this common concurrency issue in tests. The code is ready to be merged.

@eshitachandwani
eshitachandwani merged commit d2eab68 into grpc:master Feb 24, 2026
14 of 16 checks passed
@maishivamhoo123
maishivamhoo123 deleted the fix-rls-goroutine-leak branch February 25, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A potential goroutine leak in balancer/rls/control_channel_test.go

4 participants