Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roachprod: fix leaky goroutine in SyncedCluster.Monitor #106341

Merged
merged 1 commit into from
Jul 7, 2023

Conversation

renatolabs
Copy link
Contributor

The Monitor function would leak a goroutine per node waiting for context cancelation even after the monitor loop had already exited (for example, when a OneShot monitor check was requested).

This commit updates that function so that we use a cancelable context derived from the context passed as argument; when the monitor loop exits, we cancel that context, which causes the leaky goroutine to terminate appropriately.

This leaked goroutine shows up in the newly introduced roachtest leaktest, where there is one leaked goroutine per node in the cluster created by the test; the monitor is created during the assertNoDeadNode post-test assertion.

Epic: none

Release note: None

The `Monitor` function would leak a goroutine per node waiting for
context cancelation even after the monitor loop had already
exited (for example, when a `OneShot` monitor check was requested).

This commit updates that function so that we use a cancelable context
derived from the context passed as argument; when the monitor loop
exits, we cancel that context, which causes the leaky goroutine to
terminate appropriately.

This leaked goroutine shows up in the newly introduced roachtest
`leaktest`, where there is one leaked goroutine per node in the
cluster created by the test; the monitor is created during the
`assertNoDeadNode` post-test assertion.

Epic: none

Release note: None
@renatolabs renatolabs requested a review from a team as a code owner July 6, 2023 21:18
@renatolabs renatolabs requested review from herkolategan and srosenberg and removed request for a team July 6, 2023 21:18
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@srosenberg srosenberg left a comment

Choose a reason for hiding this comment

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

Nice!

@renatolabs renatolabs added the backport-23.1.x Flags PRs that need to be backported to 23.1 label Jul 7, 2023
@renatolabs
Copy link
Contributor Author

TFTR!

bors r=srosenberg

@craig
Copy link
Contributor

craig bot commented Jul 7, 2023

Build succeeded:

@craig craig bot merged commit 821ee3a into cockroachdb:master Jul 7, 2023
@renatolabs renatolabs deleted the rc/fix-monitor-leak branch July 7, 2023 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.1.x Flags PRs that need to be backported to 23.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants