-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(filecache): Scale DB query created when deleting file from filecache #54277
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
base: master
Are you sure you want to change the base?
Conversation
1a92626
to
b10e23e
Compare
b10e23e
to
12ea3fe
Compare
d04ff37
to
ba2ef69
Compare
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.
It makes sense. I guess we could also deprecate the original one to push dev to migrate to the new event ?
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
ba2ef69
to
211ab28
Compare
Considering that |
211ab28
to
505aa5f
Compare
505aa5f
to
281a304
Compare
I'm a bit worried that some apps will not listen to this new event and we break their functionality 🙈 |
The old event is still being sent and apps need to listen to either of them and not both |
Ah ok, I thought you were replacing it entirely. So it just optimizes the listeners, not the event emitting. |
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 just have minor comments, feel free to resolve them if you address them or don't want to.
$cacheEntryRemovedEvents[] = $cacheEntryRemovedEvent; | ||
$this->eventDispatcher->dispatchTyped($cacheEntryRemovedEvent); | ||
} | ||
$this->eventDispatcher->dispatchTyped(new CacheEntriesRemovedEvent($cacheEntryRemovedEvents)); |
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.
thought: if an error happens in any app handling the previous per-item events, the core will never get a chance to handle this event leaving the data around. This is more related to handling events in code, rather than this PR itself.
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.
Changed to send the per-item events after the grouped-item event
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.
But this is worse, it means no events gets emitted if there is an issue halway?
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.
@CarlSchwan if you want to keep the per-item event handling after the grouped one, to avoid what Côme mentions, maybe you can wrap the first with a try-catch(Exception)
, so at least we can try emitting the single ones? The same could be done in reverse, I guess.
Anyways the topic of "what happens when a request crashes" during/before event handling is something that cannot be solved in this PR specifically, I just wanted to raise the point that this may lead to issues and unfortunately there is no easy way around it.
🤦♂️ didn't see that there already was a second review |
56879c4
to
3806553
Compare
…ache Instead of creating a CacheEntryRemovedEvent for each deleted files, create a single CacheEntriesRemovedEvent which wrap multiple CacheEntryRemovedEvent. This allow listener to optimize the query they do when multiple files are deleted at the same time (e.g. when deleting a folder). Signed-off-by: Carl Schwan <carl.schwan@nextclound.com>
Signed-off-by: Carl Schwan <carl.schwan@nextclound.com>
3806553
to
a7bb6fb
Compare
Instead of creating a CacheEntryRemovedEvent for each deleted files, create a single CacheEntriesRemovedEvent which wrap multiple CacheEntryRemovedEvent.
This allow listener to optimize the query they do when multiple files are deleted at the same time (e.g. when deleting a folder).
Summary
Instead of creating a CacheEntryRemovedEvent for each deleted files, create a single CacheEntriesRemovedEvent which wrap multiple CacheEntryRemovedEvent.
This allow listener to optimize the query they do when multiple files are deleted at the same time (e.g. when deleting a folder).
For a folder with 10 files inside, the number of query created by the DELETE http request went from 72-75 to 42
Checklist