Repository navigation
Test 48490: Temporary directory cannot be deleted after an import - #12197
lukas-heinrich wants to merge 1 commit into
Conversation
e316240 to
f001de0
Compare
| return $this->error_reading_zip; | ||
| } | ||
|
|
||
| public function __destruct() |
There was a problem hiding this comment.
This does what PHP already does when the ZipArchive is freed, so it does not change the lifetime of the handle. Additionally, since the return value of open() is not checked in the constructor, error_reading_zip can be false for an archive that was never opened, and close() would then throw a ValueError from the destructor. I'd rather release the resources at the end of extract().
|
|
||
| $unzip = $this->archives->unzip(Streams::ofResource(fopen($file_to_import, 'r')), $options); | ||
| $unzip->extract(); | ||
| unset($unzip); |
There was a problem hiding this comment.
This is the change that actually fixes the issue here, but only for this consumer. If Unzip::extract() releases its handles itself, this is no longer necessary.
|
Hi @lukas-heinrich, thanks for tracking this down, the analysis regarding open handles on NFS is right. However, I think this PR only fixes the symptom in one consumer and not the cause in
I'd suggest fixing this in
With that, the I'll take care of the implementation myself: I'd like to fix the cause in |
|
As announced, the fix in |
Hello everyone,
This PR addresses the issue described in Ticket 0048490. There is a problem while deleting the temporary import directory after a test has been imported successfully. Even though the import is completed and the test object was created, the user is facing an error screen.
We were able to trace the issue to a race condition that occurs when importing large test objects, caused by the file handlers not being closed correctly after the upload is extracted. As a result, the directory cannot be completely deleted during cleanup. According to our analysis, NFS file systems are particularly affected by this issue.
In my opinion, the best way to resolve this issue is to release this handler in the
Unzipdestructor. For this reason, I've introduced the object destructor to theUnzipclass. The second change in the test component is an additional safeguard that deletes that object instance as early as possible.I'd appreciate any feedback or suggestions for alternative solutions.
Best
@lukas-heinrich
/cc @thojou