Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Lock] Remove released semaphore#27357
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
stof commentedMay 23, 2018
Can we have tests reproducing the issue ? AFAIK, all tests of the SemaphoreStore are green with the existing implementation, so having it non-working means that the testsuite is not covering things properly. |
stof commentedMay 23, 2018
and you worked on an outdated version of Symfony master (or you targeted the wrong branch when opening the PR), as this conflicts. |
2bdfb09 to97026c7Comparejderusse commentedMay 23, 2018
Added a test case and fix target branch |
stof commentedMay 24, 2018
I'd rather see a test about the behavior of the store (to prevent the bug beign reported) rather than a test enforcing this specific implementation (which does not prove that this implementation is the right one, but forbids replacing it) |
jderusse commentedMay 24, 2018
@stof unless I missed a point, the bug reported is The test asserts that amount of semaphores used on the OS does not increase when the lock is acquired then released, regardless of the implementation. An other way to test it would be to reproduce the reported bug. Meaning either
Do you see another way to test the behavior? |
stof commentedMay 24, 2018
Is |
jderusse commentedMay 24, 2018
Wouldn't say so.
If your application can control the amount of distinguished resource, you should For the record, we have exactly the same issue with the original implementation of |
| } | ||
| } | ||
| if (!$acquired) { |
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.
Just wondering: can this happen at all now? do we need some sort of timeout in the while above?
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.
yes, if\PHP_VERSION_ID >= 50601 and!$blocking
| while ($blocking && !$acquired) { | ||
| $resource =sem_get($keyId); | ||
| $acquired = @sem_acquire($resource, !$blocking); |
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.
the value of $blocking is known here
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.
fixed
| $acquired =sem_acquire($resource, !$blocking); | ||
| $acquired = @sem_acquire($resource, !$blocking); | ||
| while ($blocking && !$acquired) { |
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.
This loop can be moved outside of the if/else
| } | ||
| }else { | ||
| $acquired =sem_acquire($resource, !$blocking); | ||
| $acquired = @sem_acquire($resource, !$blocking); |
nicolas-grekasJun 4, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
By swapping the order of the if/else, we can simplify the condition: if (PHP>=...) elseif !$blovking throw
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.
done
nicolas-grekas commentedJun 8, 2018
Thank you@jderusse. |
This PR was merged into the 3.4 branch.Discussion----------[Lock] Remove released semaphore| Q | A| ------------- | ---| Branch? | 3.4| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#27356| License | MIT| Doc PR | NAThis PR remove the semaphore with `sem_remove`. By removing without releasing the semaphore, all pending blocking acquiring will fail that's why the acquire method has also been update to handle such caseCommits-------77b9f90 Remove released semaphore
pdias commentedNov 21, 2018
I do not know if there is anything to do with this topic, but in a console command I do this: `` `` And i have this warning:
I'm using SF3.4. Thanks. |
This PR remove the semaphore with
sem_remove. By removing without releasing the semaphore, all pending blocking acquiring will fail that's why the acquire method has also been update to handle such case