⚠️ This issue respects the following points: ⚠️
Bug description
Summary
OCA\FilesReminders\Dav\PropFindPlugin preloads reminders information for an entire collection during PROPFIND requests. ReminderService has a cacheFolder method which uses CappedMemoryCache as cache. The problem is that the default size for this cache is 512 meaning that if a directory has more than 512 files inside we start getting cache misses and start querying the DB.
What's worse is that once the condition hits, it always voids the pre-cached data and causes N+1 queries because:
- the preload mechanism starts caching reminders for all files in a directory
- once the limit of the
CappedMemoryCache is reached, the information that was cached earlier is discarded
- when the PROPFIND is serialized into XML, the first file is no longer in the cache, causing a query for the single file
- the result is cached, pushing another older result out of the cache
Steps to reproduce
- Create a folder
- Upload more than 512 files
- Do a PROPFIND request on the folder
- See that the code runs >512 queries targeting the reminders table
Expected behavior
Queries are executed in N+1 way only if there are more than 512 reminders in files in a folder.
Nextcloud Server version
35 (master)
Operating system
None
PHP engine version
None
Web server
None
Database engine version
None
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
None
What user-backends are you using?
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
Additional info
No response
Bug description
Summary
OCA\FilesReminders\Dav\PropFindPluginpreloads reminders information for an entire collection duringPROPFINDrequests.ReminderServicehas acacheFoldermethod which usesCappedMemoryCacheas cache. The problem is that the default size for this cache is 512 meaning that if a directory has more than 512 files inside we start getting cache misses and start querying the DB.What's worse is that once the condition hits, it always voids the pre-cached data and causes N+1 queries because:
CappedMemoryCacheis reached, the information that was cached earlier is discardedSteps to reproduce
Expected behavior
Queries are executed in N+1 way only if there are more than 512 reminders in files in a folder.
Nextcloud Server version
35 (master)
Operating system
None
PHP engine version
None
Web server
None
Database engine version
None
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
None
What user-backends are you using?
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
Additional info
No response