Issue #460: Locking session while saving large content #461
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.
The description of the problem and steps to repeat are provided in Issue #460.
Profiling shows that 95% of time is spent inside
h5p.classes.php: H5PExport > createExportFile > $zip->Close()
call:https://github.com/h5p/h5p-php-library/blob/c84217f8414c06ebabe3dedb046a77c42c2f0dbf/h5p.classes.php#L1931
However, the library submodule is used not only with Moodle. For this reason the patch is proposed for Moodle plugin.
The solution for the session locking would be to write_close() the session before finishing zip file. It will allow other pages to use session without waiting on the file operation to finish.
The main concern is that
framework::messages()
should not be called before the session is closed.My testing confirms that
framework::messages()
is not called at all when the file content is being saved.moodle-mod_hvp/classes/framework.php
Lines 321 to 330 in 9d9e785
framework::messages() is only called when the content is loaded for viewing or editing. However, in such case the session is not closed (the session will be closed only before the file storing).
The testing method is described in Issue #460. Although the file saving can take considerable time (which is expected for large files), the session is not locked and another page can be opened in a separate tab without giving errors.