Laravel-Excel
Laravel-Excel copied to clipboard
[Bug]: File gets deleted after first chunk while using ShouldQueueWithoutChain
Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?
- [x] Yes, it's still reproducable
What version of Laravel Excel are you using?
3.1.36
What version of Laravel are you using?
8.12
What version of PHP are you using?
8.1
Describe your issue
Excel file in remote (s3) location gets deleted after first queue chunk is processed while using ShouldQueueWithoutChain concern
Therefore showing following error while processing other queue chunk.
File not found at path: tmp/laravel-excel-xxxxxxxx.xlsx
What should be the expected behaviour?
The file should stay until the last queue is processed and then deleted
Or there should be option to keep the file and not delete, we can always delete is using schedule.
I think the issue is that you using without chain, there's no way for us to know if its the last chunk or not.
I think the issue is that you using without chain, there's no way for us to know if its the last chunk or not.
Yes, I'm using without chain.
But the problem is "AfterImportJob" is processed first and it removes the tmp file in remote directory (s3).
The delay is also not being considered in $jobs->push($afterImportJob->delay($delayCleanup));
I'm using SQS and S3 on Laravel Vapor
As I said, without the chain it is not possible to be sure a specific job executes last. Depending on the amount of workers any job could be the first or last
@mahdi29 try setting the the following property in your import class. If you are using vapor 900 seconds is the longest it can wait. This should ensure that cleanup doesn't happen until 10 minutes after the job is finished. Though it's odd yours fires immediately as 10 minutes is the default for this property.
/**
* Specify the Cleanup Delay for 10 minutes.
* @var int
*/
public int $delayCleanup = 600;
I forgot we had that option. That should indeed prevent the clean-up of the remote file until 10 minutes later. Perhaps not all queue worker support it? Are you using redis/horizon?
Locally redis/horizon. But Vapor for staging/production.
@mgratch sorry the question was intended at @mahdi29 haha. Make sense it work on those 2 yes.
@mgratch sorry the question was intended at @mahdi29 haha. Make sense it work on those 2 yes.
I use Vapor and it supports delay. However, after delay (15 min) the AfterImportJob runs and deletes file, but during that time only half of my queue were processed and other half gives "File not found at path" error.
I believe the only solution would be to use SQS FIFO but that's not supported in laravel vapor.
The other solution would be to completely skip AfterImportJob, but I don't find any way to do it.
Having SkipAfterImportJob/SkipFileDelete concern would solve the issue.
I would be fine with a SkipCleanup concern
Any plans to address this @patrickbrouwers ? I am hitting the same problem using Bref and SQS.
Actually the solution is pretty simple, using FIFO after complete job will be processed last. Opened a PR https://github.com/SpartnerNL/Laravel-Excel/pull/3986, thanks