Skip to content

fix: cache invalidation issues#2330

Merged
provokateurin merged 2 commits intomasterfrom
fixCacheInvalidation
Feb 12, 2026
Merged

fix: cache invalidation issues#2330
provokateurin merged 2 commits intomasterfrom
fixCacheInvalidation

Conversation

@solracsf
Copy link
Member

@solracsf solracsf commented Feb 1, 2026

Problem

Context: nextcloud/server#57973 and nextcloud/server#49126

Files shared with teams were not syncing properly on desktop clients. When files were added, modified, or deleted in team-shared directories, the ETag was correctly updated in the database but clients received stale ETags from the distributed cache, preventing synchronization.

Root causes:

  1. The clearCache() method in ShareWrapperService was broken - it used singleId as the cache key but actual keys follow the format singleId#nodeId#probeSum, causing cache invalidation to silently fail
  2. No event listeners existed to detect file modifications and trigger cache invalidation - cache was only cleared when shares or memberships changed, never when files themselves were modified

Fix nextcloud/server#57973

Note

While testing, please enable debug mode to print debug messages.

@solracsf solracsf force-pushed the fixCacheInvalidation branch 2 times, most recently from c440368 to b17f1e8 Compare February 1, 2026 09:00
@solracsf solracsf marked this pull request as ready for review February 1, 2026 09:00
@solracsf solracsf self-assigned this Feb 1, 2026
@solracsf solracsf force-pushed the fixCacheInvalidation branch from b17f1e8 to 2e1669b Compare February 1, 2026 09:22
@Ornanovitch

This comment was marked as resolved.

@Ornanovitch
Copy link

/backport to stable33

@Ornanovitch
Copy link

/backport to stable32

@Ornanovitch
Copy link

/backport to stable31

@CarlSchwan
Copy link
Member

Make sense to me

@cristianscheid
Copy link
Contributor

cristianscheid commented Feb 11, 2026

@solracsf I was investigating this issue as well, and what you did makes a lot of sense to me.

Unfortunately, when testing the fixCacheInvalidation branch with server on master branch, I get this error when trying to rename a file:

Toast (feedback):
Could not rename "<filename>"

Request:

MOVE
http://nextcloud.local/remote.php/dav/files/admin/new/<old_name_before_rename>
500 Internal Server Error

Response:

<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:exception>Error</s:exception>
  <s:message>Call to undefined method OCP\Files\Events\Node\NodeRenamedEvent::getNode()</s:message>
</d:error>

Does this happen for you as well?

Other than that, adding/removing files from within a shared folder correctly updated the folder etag in my tests. I verified this using curl as suggested in issue #57973, and running the command before and after the file operation confirmed the etag updated and matched the value in the oc_filecache table:

curl -X PROPFIND -u "{user}:{pass}" \
        -H "Depth: 0" \
        "https://{server}/remote.php/dav/files/{user}/{team_shared_folder}/" \
        --data '<?xml version="1.0"?><d:propfind xmlns:d="DAV:"><d:prop><d:getetag/></d:prop></d:propfind>'

@solracsf solracsf marked this pull request as draft February 11, 2026 14:44
@solracsf
Copy link
Member Author

solracsf commented Feb 11, 2026

@cristianscheid try latest commit a7baf35 on your patched instance

Tested locally, rename works as expected.

@cristianscheid
Copy link
Contributor

cristianscheid commented Feb 11, 2026

@cristianscheid try latest commit a7baf35 on your patched instance

Tested locally, rename works as expected.

@solracsf Thanks for the adjustment! I tested locally again using curl before and after renaming a file, and it worked as expected.

@solracsf solracsf marked this pull request as ready for review February 11, 2026 16:46
@solracsf
Copy link
Member Author

Thanks for testing.
Let's wait for reviews from other maintainers 👍🏻

@CarlSchwan
Copy link
Member

btw the red psalm ci is fixed by #2356 in case anyone wants to review ;)

@provokateurin
Copy link
Member

@solracsf please rebase

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf solracsf force-pushed the fixCacheInvalidation branch from a7baf35 to 1cdb52d Compare February 12, 2026 09:46
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf
Copy link
Member Author

@provokateurin rebased and all green 🟢

@provokateurin provokateurin merged commit 18f9d9c into master Feb 12, 2026
44 checks passed
@provokateurin provokateurin deleted the fixCacheInvalidation branch February 12, 2026 09:53
@solracsf
Copy link
Member Author

/backport 1cdb52d to stable33

@solracsf
Copy link
Member Author

/backport 1cdb52d to stable32

@solracsf
Copy link
Member Author

/backport 1cdb52d to stable31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: files shared with a team do not sync (ETag cache is not invalidated)

5 participants