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

fix: latency test race condition #29

Merged
merged 15 commits into from
Dec 8, 2023
Merged

fix: latency test race condition #29

merged 15 commits into from
Dec 8, 2023

Conversation

lvlcn-t
Copy link
Collaborator

@lvlcn-t lvlcn-t commented Dec 5, 2023

Motivation

Address a race condition found within the check method of the Latency Check. The race condition was caused by the concurrent goroutines capturing the loop variable e from the for loop, leading to unpredictable behavior as this variable was shared across all goroutines.

Closes #27

Changes

Introduced a local copy of the loop variable in the for loop to ensure each goroutine receives a unique, stable copy of the target URL.

For additional information look at the commits.

Tests done

The unit tests succeed now.

TODO

  • I've assigned this PR to myself
  • I've labeled this PR correctly

@lvlcn-t lvlcn-t added the bug Something isn't working label Dec 5, 2023
@lvlcn-t lvlcn-t self-assigned this Dec 5, 2023
@lvlcn-t lvlcn-t marked this pull request as draft December 5, 2023 10:06
@y-eight
Copy link
Member

y-eight commented Dec 5, 2023

@lvlcn-t lvlcn-t changed the title fix: copy loop variable to avoid race conditions fix: latency test race condition Dec 5, 2023
@lvlcn-t lvlcn-t marked this pull request as ready for review December 6, 2023 15:25
@lvlcn-t lvlcn-t requested a review from eumel8 as a code owner December 6, 2023 15:25
@lvlcn-t
Copy link
Collaborator Author

lvlcn-t commented Dec 6, 2023

Ready for review.

This PR now also partly addresses #31 but needs to be extended in another PR for the health check and other refinements.

@lvlcn-t
Copy link
Collaborator Author

lvlcn-t commented Dec 6, 2023

And after merging it should also close #33 since I've refactored the latency check to be more lined up with the health check

@lvlcn-t lvlcn-t added refactoring Refactoring of existing code housekeeping labels Dec 6, 2023
Copy link
Collaborator

@puffitos puffitos left a comment

Choose a reason for hiding this comment

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

LGTM; @y-eight / @niklastreml I'll wait for your review as well before merging.

Copy link
Member

@y-eight y-eight left a comment

Choose a reason for hiding this comment

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

LGTM

@lvlcn-t lvlcn-t merged commit 0e297bb into main Dec 8, 2023
6 checks passed
@lvlcn-t lvlcn-t deleted the fix/latency-loop-race branch December 8, 2023 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working housekeeping refactoring Refactoring of existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Test race condition
3 participants