-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
BUGFIX: Fix race-condition when initializing I18n Service #3188
BUGFIX: Fix race-condition when initializing I18n Service #3188
Conversation
The previous implementation was an example of a check-then-act race-condition: There is no guarantee that the cached value still exists when it is subsequently read out. This would cause errors later when `$this->localCollection` could suddenly have the value `false`.
b82054f
to
6f9716e
Compare
@kitsunet Any chance of getting this merged? Anything I can help with? |
Oops! I made a mistake and need to undo the change. I forgot to run the unit tests locally, and they failed because of that change. So, we need to fix that first before we can move forward. Tak for din contribution @christianharrington ❤️ |
Should I open a new PR @markusguenther? |
That would be very kind :) |
@markusguenther Done so here :) |
We noticed in our error logs that we had quite a few errors being thrown from here:
My best guess is that this is due to a race-condition when the service is called for the first time on a host by multiple requests simultaneously.
In general, the pattern of first checking if some value is in the cache, and then reading the value out afterwards without checking it is never safe, as a different process/thread could have removed it.
The safe way is to read the value out once, and verify that it is set correctly (e.g. it should not
=== false
).I think there's a few other places that follow the same unsafe pattern, but I suggest that they are addresses separately from this PR.
I haven't added any tests for this case, but please let me know if you have any ideas of how to test this.
Checklist
FEATURE|TASK|BUGFIX
!!!
and have upgrade-instructions