Skip to content
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

[Core] Allow parallel handling of requests from same session #7445

Merged
merged 2 commits into from
Dec 19, 2022

Conversation

driusan
Copy link
Collaborator

@driusan driusan commented May 10, 2021

This adds a session_write_close() call to the end of NDB_Client,
after the last reference to $_SESSION has been made. This causes
PHP to release the lock it holds on the session file which prevents
further incoming requests from being handled. After this point in
NDB_Client all of our session related state should be read from
the PSR request, not the superglobal.

PHP by default holds a lock on the session until it is closed in case
there is a write to the superglobal. However, this prevents other
requests from the same session from reading the variable (which
is where our login state is stored) until the end of the request,
when the lock is released. Closing it explicitly releases the lock
and allows us to handle multiple requests from the same user in parallel
instead of in series.

@xlecours
Copy link
Contributor

I think I found write operations on $_SESSION['State'] that occur after session_write_close

  1. $_SESSION['State']->setProperty('filter', $newFilters);
  2. $_SESSION['State']->setProperty('keyword', $key);

@driusan
Copy link
Collaborator Author

driusan commented May 12, 2021

Thanks.. that looks like dead code, but I think it might actually be why the MRI Violations tests are failing, since MRI Violations hasn't been converted to React yet. Gonna have to think about if there's an easier way to do this than rewriting the module for this PR..

@driusan
Copy link
Collaborator Author

driusan commented May 12, 2021

I think since MRI violations is the last module in https://github.com/aces/Loris/projects/8 I might as well just do it and then delete that code in this PR.

@driusan driusan added the Blocked PR awaiting the merge, resolution or rejection of an other Pull Request label May 12, 2021
@driusan driusan added Bug PR or issue introducing/requiring bug fixes (not mutually exclusive with the Feature label) Cleanup PR or issue introducing/requiring at least one clean-up operation php Pull requests that update Php code and removed Blocked PR awaiting the merge, resolution or rejection of an other Pull Request labels Jul 27, 2021
@ridz1208
Copy link
Collaborator

This is cool !

This adds a session_write_close() call to the end of NDB_Client,
after the last reference to $_SESSION has been made. This causes
PHP to release the lock it holds on the session file which prevents
further incoming requests from being handled. After this point in
NDB_Client all of our session related state should be read from
the PSR request, not the superglobal.

PHP by default holds a lock on the session until it is closed in case
there is a write to the superglobal. However, this prevents other
requests from the same session from reading the variable (which
is where our login state is stored) until the end of the request,
when the lock is released. Closing it explicitly releases the lock
and allows us to handle multiple requests from the same user in parallel
instead of in series.
@ridz1208
Copy link
Collaborator

Approving. noticeable difference in request speed. currenlty working on CBIGR biobank

@driusan driusan merged commit 8058aef into aces:main Dec 19, 2022
@driusan
Copy link
Collaborator Author

driusan commented Dec 19, 2022

Note: Talked to @cmadjar before skipping the tests and we agreed to rely on manual testing the mri violations module for now, because of the significant performance implications for other modules (biobank, eeg, etc)

@ridz1208 ridz1208 added this to the 25.0.0 milestone Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug PR or issue introducing/requiring bug fixes (not mutually exclusive with the Feature label) Cleanup PR or issue introducing/requiring at least one clean-up operation php Pull requests that update Php code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants