Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

fix/internal/memcmd: close the explicit stop channel before cancelling context#63214

Merged
ggilmore merged 1 commit into
mainfrom
06-11-fix_internal_memcmd_close_the_explicit_stop_channel_before_cancelling_context
Jun 12, 2024
Merged

fix/internal/memcmd: close the explicit stop channel before cancelling context#63214
ggilmore merged 1 commit into
mainfrom
06-11-fix_internal_memcmd_close_the_explicit_stop_channel_before_cancelling_context

Conversation

@ggilmore

@ggilmore ggilmore commented Jun 11, 2024

Copy link
Copy Markdown
Contributor

This PR tweaks the logic in the linux memory observer that skips over context cancellation errors that occur when we deliberately stop the observer.

https://github.com/sourcegraph/sourcegraph/blob/553b5c55ac60986a3b8d3a1a0ba8b3118f94731b/internal/memcmd/observer_linux.go#L156-L172

Before it was possible for the above code to run after the context was cancelled, but before the explicitlyStopped channel was closed. This would cause the function to incorrectly keep the context cancellation error.

Now, we make sure to close the channel before canceling the context in Stop - thus fixing the above issue.

Test plan

Existing unit tests (you can't really test a race condition like this).

Changelog

This PR fixes a logspam bug in the linux memory observer that was due to do slightly faulty synchronizzation logic.

@cla-bot cla-bot Bot added the cla-signed label Jun 11, 2024

ggilmore commented Jun 11, 2024

Copy link
Copy Markdown
Contributor Author

@github-actions github-actions Bot added team/product-platform team/source Tickets under the purview of Source - the one Source to graph it all labels Jun 11, 2024
@ggilmore ggilmore requested a review from a team June 11, 2024 20:52
@ggilmore ggilmore marked this pull request as ready for review June 11, 2024 20:52
@graphite-app

graphite-app Bot commented Jun 12, 2024

Copy link
Copy Markdown

TV gif. Timmy from Shaun the Sheep blinks and extends 2 thumbs up as a lopsided grin emerges on the side of his face. (Added via Giphy)

@ggilmore ggilmore merged commit 4fb5ba3 into main Jun 12, 2024
@ggilmore ggilmore deleted the 06-11-fix_internal_memcmd_close_the_explicit_stop_channel_before_cancelling_context branch June 12, 2024 13:08

Copy link
Copy Markdown
Contributor Author

Merge activity

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

Labels

cla-signed team/product-platform team/source Tickets under the purview of Source - the one Source to graph it all

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants