Catch IOException in CacheCleaner to prevent upgrade abort on locked cache files - #1820
Conversation
|
Hello @rboadalabelgrup! This is your first pull request on autoupgrade repository of the PrestaShop project. Thank you, and welcome to this Open Source community! |
|
Can you please target the branch About the changes, the changes look good to me but as this is not an actual fix and the cache partially remains, this will require some tests before being approved by the QA. |
33c73e6 to
b34df61
Compare
Agreed, this is a best-effort approach. The upgrade continues and the operator is warned via the log. If a stricter behavior is preferred (e.g. retrying or listing the locked files), I'm open to suggestions. |
|
We also lack actual solution on that. Our investigations showed that any parallel request to the store while the update is running will generate the cache. If the deletion of the cache happens at the same time, we will encounter the collision. |
|
@Quetzacoalt91 Thanks for the context! I had a look at #1523 — makes sense as a first line of defense for back office AJAX requests. My change would cover the cases that guard can't block, like requests coming from the front end or external APIs. The upgrade wouldn't abort in those situations, the locked files would just remain and the operator gets a warning in the log. Not a perfect solution, but it could complement what's already there. Happy to adjust if you have something else in mind. |
|
I've the updated the base branch so the CI does not fail for a missing library |
… files are locked by running processes
b34df61 to
45d6906
Compare
|
Done, rebased on 7.6.x. |
|



During an upgrade, if PHP-FPM processes have cache files open, clearDirectory() throws an IOException and the upgrade process aborts completely.
This change wraps the clearDirectory() call in a try/catch so that locked files produce a warning in the log instead of an unhandled exception, allowing the upgrade to continue.
clearDirectory()throws anIOExceptionand the upgrade process aborts completely. This change wraps theclearDirectory()call in a try/catch so that locked files produce a warning in the log instead of an unhandled exception, allowing the upgrade to continue.2. Start an upgrade while PHP-FPM processes have cache files open
3. Before: the upgrade aborts with an unhandled IOException
4. After: the upgrade continues and a warning appears in the log instead
Possible impacts