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 BulkUpdateDetection Race Condition #728

Merged
merged 1 commit into from
Jan 21, 2025
Merged

Conversation

coreyogburn
Copy link
Contributor

There are 2 parts to a call to BulkUpdateDetection: the original request, and an async portion that does the bulk of the work. Both end with a log statement but during testing it isn't always clear which part of the call will log first. I've added a WaitSync for the request portion so we can control the timing.

InitMock doesn't have to wait on the WaitSync if the parameters of that test case won't kick off the async portion BUT any test case that does make it to the async portion should wait inside a DoAndReturn of the first possible mocked request (BuildBulkIndexer).

In plain english, once the main request is done it marks the nonAsyncWG as Done while the async portion of the request is waiting to build the bulk indexer. This ensures the async portion begins after the original request ends.

There are 2 parts to a call to BulkUpdateDetection: the original request, and an async portion that does the bulk of the work. Both end with a log statement but during testing it isn't always clear which part of the call will log first. I've added a WaitSync for the request portion so we can control the timing.

InitMock doesn't have to wait on the WaitSync if the parameters of that test case won't kick off the async portion BUT any test case that does make it to the async portion should wait inside a DoAndReturn of the first possible mocked request (BuildBulkIndexer).

In plain english, once the main request is done it marks the nonAsyncWG as Done while the async portion of the request is waiting to build the bulk indexer. This ensures the async portion begins after the original request ends.
@coreyogburn coreyogburn merged commit a914d30 into 2.4/dev Jan 21, 2025
3 checks passed
@coreyogburn coreyogburn deleted the cogburn/fix-test-race branch January 21, 2025 22:40
@github-actions github-actions bot locked and limited conversation to collaborators Jan 21, 2025
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.

2 participants