Skip to content

fix: lock adding to tailnet waitgroup to avoid race (and fix flake) #14195

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

Conversation

ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Aug 7, 2024

Fixes #14143.
Fixes a race condition that can occur when a tailnet connection is closed just before a network telemetry event is about to be sent off. Specifically, where waitgroup.Add(n) is called on a waitgroup where waitgroup.Wait() is currently blocking another goroutine.

This works as we only call Wait() on the telemetryWg waitgroup when the Conn mutex is held, and only after the closed channel has been closed. We then require that the goroutine sending the telemetry event acquire said mutex, and that the channel is not closed, before adding to the waitgroup and sending the event.

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @ethanndickson and the rest of your teammates on Graphite Graphite

@ethanndickson ethanndickson marked this pull request as ready for review August 7, 2024 05:49
@ethanndickson ethanndickson merged commit e09ad1d into main Aug 7, 2024
40 checks passed
@ethanndickson ethanndickson deleted the 08-07-fix_lock_adding_to_tailnet_waitgroup_to_avoid_race_and_fix_flake_ branch August 7, 2024 05:52
@github-actions github-actions bot locked and limited conversation to collaborators Aug 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flake: TestSSH/RemoteForward
2 participants