Repository navigation
fix(sync): don't return the mailbox as new messages from the initial sync - #13823
dillardblom wants to merge 1 commit into
Conversation
|
Since this PR overlaps with my own goals, I tested this on my local stack: Nextcloud 33.0.9, PHP 8.4 with Sync without known ids
Sync with known ids (unchanged)
Trigger On current
Two small points on the change
Hope this helps. |
|
Thanks a lot for testing this so thoroughly, on mailboxes that size, and for the comparison table. That is more than I could reproduce here. Both points:
|
|
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.) |
|
Thanks for the patch I don't have the time for a deep dive but from what I remember about the sync logic is that there are initial and partial syncs. And the OOM only happens if an incorrect partial sync is performed. |
|
In my tests the empty With So maybe the initial sync just shouldn't return new messages. I couldn't reproduce the priority inbox case from the PR description, so that one may be different. |
Yes, agree. Initial sync should not be handled like a partial one. |
…sync When a mailbox isn't cached yet, the client syncs it with init set and no known ids (initializeCache() in Mailbox.vue), then loads the first page from the message list. The initial sync returned every message of the mailbox as new anyway, and ran each one through the preview enhancer. On an INBOX of 33,000 messages that request ran out of memory, and the client retried it. The initial sync now only fills the cache and returns the mailbox stats. Partial syncs are unchanged. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Dillard Blom <dillard.blom@ensembia.com>
f90aef7 to
6b79f18
Compare
|
Thanks both. @stiller is right, and I can't find the priority inbox case from my original description in the code either: it was most likely the same initial sync being retried. Sorry for the noise there. I've reworked the PR as suggested: the initial sync no longer returns new messages, only the mailbox stats, and the 20-message limit is gone. The client already loads the first page from the message list right after |
Summary
When a mailbox isn't cached yet, the client syncs it with
init: trueand no known ids (initializeCache()inMailbox.vue), and then loads the first page from the message list endpoint. The initial sync returned every message of the mailbox as new anyway:getDatabaseSyncChanges()treated the cache as unknown to the client and ran each message through thePreviewEnhancer.On an INBOX with 33,000 messages that request ran out of PHP memory (1 GB) in the MIME parser and charset converter, and the client retried it, so the log filled with
Allowed memory size … exhaustederrors. The same mailbox syncs fine fromocc mail:account:sync(peak 79 MB), because that path doesn't run the database diff.The initial sync now only fills the cache and returns the mailbox stats. Partial syncs are unchanged.
Thanks to @stiller for tracing the request to
initializeCache().Test plan
SyncServiceTestandMailboxesControllerTestgreen, php-cs-fixer clean on the changed files.