sourcegraph/internal/memcmd
Geoffrey Gilmore 4fb5ba3ca6
fix/internal/memcmd: close the explicit stop channel before cancelling context (#63214)
This PR tweaks the logic in the linux memory observer that skips over
context cancellation errors that occur when we deliberately stop the
observer.


553b5c55ac/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.
2024-06-12 06:08:29 -07:00
..
BUILD.bazel feat/internal/memcmd: ignore context cancellation errors from Stop() (#63208) 2024-06-11 12:23:39 -07:00
observer_darwin_test.go feat/internal/memcmd: add internal/memcmd package to allow for memory tracking of exec.Cmd processes (#62803) 2024-06-10 14:20:15 -07:00
observer_darwin.go feat/internal/memcmd: add internal/memcmd package to allow for memory tracking of exec.Cmd processes (#62803) 2024-06-10 14:20:15 -07:00
observer_example_test.go feat/internal/memcmd: add internal/memcmd package to allow for memory tracking of exec.Cmd processes (#62803) 2024-06-10 14:20:15 -07:00
observer_linux_test.go feat/internal/memcmd: ignore context cancellation errors from Stop() (#63208) 2024-06-11 12:23:39 -07:00
observer_linux.go fix/internal/memcmd: close the explicit stop channel before cancelling context (#63214) 2024-06-12 06:08:29 -07:00
observer_test.go feat/internal/memcmd: add internal/memcmd package to allow for memory tracking of exec.Cmd processes (#62803) 2024-06-10 14:20:15 -07:00
observer.go feat/internal/memcmd: add internal/memcmd package to allow for memory tracking of exec.Cmd processes (#62803) 2024-06-10 14:20:15 -07:00