-
Notifications
You must be signed in to change notification settings - Fork 4
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: request count race condition #35
Conversation
fcbc8b5
to
e64ec7c
Compare
e64ec7c
to
bc6cf15
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add tests that would cover the problem?
Ideally they would fail without changes and run happily with. 🙏
@sofib-form3 Done. The test fails without the fix as expected. I did have to make a change to the concurrent requests tests as they weren't actually running the requests concurrently. |
for _, res := range s.userResponses { | ||
s.assert.Equal(res.StatusCode, s.modifiedNameStatusCode, "expected user status code") | ||
for i, res := range s.userResponses { | ||
if s.modifiedNameAttempt == nil || *s.modifiedNameAttempt == i+1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modifying attempt and number of concurrent requests have different results here - runs are concurrent so it may be out of order, perhaps the test would be more valuable if window of opportunity to fail was greater like using another fixture in test for example 10 requests per second and modify on attempt 4, or 7.
you'd need to figure a way to identify request with response in another way though
closed as duplicate of #46 |
When handling simultaneous requests that affect the same interaction we get a race condition for the request count when applying any modifiers. This is because we increment and retrieve the request count for an interaction in different steps without a lock.
This PR fixes this issue by not relying on the request count that could have been modified by another request.