LockTests - use 3 locks for random threads instead of 2 to improve UT stability #1160
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
After migrating to GH Runners for CI, we started seeing that the
raceToLockstest inLockTestsclass started failing intermittently. The test fails because sometimes the wait time for threads with "shared lock" is lesser than that of threads using "random lock" - the thread randomly chooses one lock from the two available locks. To stabilize this, instead of using two locks, we use three. See below on how was this tested.Related issues
N/A
How has this been tested?
Scenario 1
Available locks: 2

Test run count: 10
Total failures: 2
Total success: 8
PR: visheshruparelia#4 (See diff)
Builds: https://github.com/visheshruparelia/async-profiler/actions/runs/13686306015 (Notice that Attempt 6 and Attempt 8 failed - attached screenshot)
Scenario 2
Available locks: 3

Test run count: 10
Total failures: 0
Total success: 10
PR: visheshruparelia#3 (See diff)
Builds: https://github.com/visheshruparelia/async-profiler/actions/runs/13686282839 (Notice that all the runs passed - attached screenshot)
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.