-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat(occ): New command to delete previews #35189
Conversation
Seems promising. Tested also on local filesystem? |
Just tested it on local storage configuration. It worked as well. |
core/Command/Preview/Delete.php
Outdated
->leftJoin('a', 'filecache', 'b', $qb->expr()->eq( | ||
$qb->expr()->castColumn('a.name', IQueryBuilder::PARAM_INT), 'b.fileid' | ||
)) | ||
->where($and); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might still be a good idea to limit the results and rather run multiple queries after each other in a php loop to avoid massive queries against the db.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can first narrow down the preview search on the storage that holds the preview folder.
Then do you have in mind something like "SELECT ... FROM ... LIMIT a OFFSET a*x", with for loop on x? If so, do you know what a good batch size would be?
If the issue is not the mysql query size itself, but on the call for deletions, these deletions are actually done in a for loop in deletePreviews function (line 109).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was thinking about the query size itself. You wouldn't need the offset as when going through the chunk the entries would be deleted from the table so the next query with the same limit should just give you the next batch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can first narrow down the preview search on the storage that holds the preview folder.
This should still be fine to keep in the query as the storage column is indexed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can first narrow down the preview search on the storage that holds the preview folder.
This should still be fine to keep in the query as the storage column is indexed.
I updated the sql query with a condition on storage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was thinking about the query size itself. You wouldn't need the offset as when going through the chunk the entries would be deleted from the table so the next query with the same limit should just give you the next batch.
I added an option to delete previews by batch.
Two notes:
- Batch deletion is incompatible with dry mode, as it relies on actually deleting previews (the proposed code takes care of catching these incompatible options).
- This option makes the code not in line with lib/private/Preview/BackgroundCleanupJob.php or core/Command/Preview/ResetRenderedTexts.php that do not have a batch mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor comments, otherwise that seems reasonable :)
7fe61cd
to
c37a557
Compare
php-cs is not happy :) |
This comment was marked as resolved.
This comment was marked as resolved.
You can drop them, only add changes from
It should automatically use the |
Hi, this PR is still active? Because i need it for fix my s3 issues 🙄 |
up ? |
I hope it is still active. I've been waiting for review and approval. I have fixed conflicts with latest master a few times. I can fix them again if I know there is an intention to include this PR. |
I hope too, in the meantime I deactivate previews... |
@charleypaulus Please fix the conflicts in this PR, it's running a little late but hopefully this will get in for NC30 |
Too late for 30. 😕 If anyone do so, please ping me directly, I'll do my best to review ans assist to get this in in our early 31 release cycle!! 💪 |
Hi, any updates on this? We are really struggling without this feature. |
@skjnldsv I can retake it and try to fix conflicts in the next 2 months. |
In the meantime I've merged a simpler version of this PR |
Provides a new occ command to delete previews, with options:
Tested on NC 26, with S3 as primary object storage, and with local storage. Tested all combinations of options. Verified that previews are actually deleted from S3 storage and from filecache.
Addressing these issues (as a manual command):
#26014, #20344, #18416, #35290
@szaimen, @solracsf, @arpadmuller, @skjnldsv, @SimplyCorbett, @MorrisJobke