Use Mutex#synchronize to solve JRuby mutex not locked error #4957
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.
What does this PR do?
Uses Mutex#synchronize instead of manual lock & unlock calls to (hopefully) properly unlock the mutex in remote config worker.
Motivation:
Flaky tests on JRuby: https://github.com/DataDog/ruby-guild/issues/256, https://datadoghq.atlassian.net/browse/LANGPLAT-871
The issue is that sometimes mutex is attempted to be unlocked when it is not locked.
Change log entry
Yes: core/fix: improve locking code for remote configuration worker
Additional Notes:
I also attempted this alternate diff which also fixed the issue:
How to test the change?
Following @Strech 's investigation in https://datadoghq.atlassian.net/browse/LANGPLAT-871, I reproduced the failure locally (both in and not in docker) using the following:
After a couple of iterations, this would fail with the above error. The seeds specified in the ticket did not reproduce the failure for me - running the tests without explicitly specifying the seeds was needed.
With the change in this PR, I ran the above command for ~5 minutes without errors.
I have not further investigated the interaction between remote config worker and test polling intervals.