-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Avoid locking the php session #32162
Conversation
d42911c
to
b8a0eb8
Compare
Needs extra care for talk which seems to have issues with no session locking and there this PR could then lead to similar problems where the one session might be lost if the other one writes |
any connection with #31286 ? |
74d3fbc
to
f8650f3
Compare
Tested with the Talk edge case of joining a public room with a different user and seems to work. Further cases to test:
|
7b32b07
to
bb46321
Compare
bb46321
to
56a0166
Compare
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.
👍
please rebase/fixup |
Sessions are a locking operation until we write close them, so close them early and reopen later in case we want to write to them Signed-off-by: Julius Härtl <[email protected]>
… read_and_close Fixed #29356 Signed-off-by: Julius Härtl <[email protected]>
Signed-off-by: Julius Härtl <[email protected]>
56a0166
to
1b43fbe
Compare
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.
👍🏻
Slightly different approach about has the same target as #29356 to reduce the time that request might need to wait for locked sessions.
We already try to write and close the session early but on multiple concurrent requests that is still not fast enough to not have noticeable wait time on the lock. To my knowledge we don't write anything into the session that would be critical in terms of using already read value that has been updated by another request, so I think this approach should be fine from the potential race condition perspective, especially with reopening the session we would read again.
Impact on page load can be tested by adding a sleep for specific routes:
Currently every request writes to the session
server/lib/base.php
Line 455 in d42911c
I decided to go for a config flag for this, as for most setups having a session timeout that is happening at the exact second might not be really needed. If that is not used, PHP may clean up the session at a later point depending on the session garbage collection configuration. If using redis, the session lifetime will be set anyways on redis, so redis would take care of the deletion using configured key eviction policy.