Repository navigation
fix: LiveQuery role cache is not invalidated for all users affected by a role write or delete - #10629
AdrianCurtin wants to merge 1 commit into
Conversation
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughRole changes now publish LiveQuery cache-invalidation messages even when no acting user is present. The server processes global invalidation messages by clearing its authorization cache and, when available, its role cache. Messages without the global-clear flag retain targeted invalidation. ChangesLiveQuery role-cache invalidation
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~15 minutes Severity of issue fixed: Medium Suggested reviewers: 🚥 Pre-merge checks | ✅ 7✅ Passed checks (7 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…y a role write or delete
23c8c89 to
a946ab6
Compare
Pull Request
Issue
Closes #10628.
LiveQueryController.clearCachedRoles(user)invalidated the LiveQuery server's cached auth for one user, the actor on the request, and only when there was one. Two cases were never invalidated:userwas falsy, so a master key role write or delete published nothing at all. Managing roles with the master key, from admin tooling or cloud code, is the common case.{ userId }andParseLiveQueryServer#_clearCachedRolesresolved_Sessionrows for that one user. A role write changes the effective closure of every member of the role and of any role inheriting from it. Adding a member is the clearest example: the actor is the admin doing the write, the affected user is the member being added, and only the actor was invalidated.Until its
authCacheentry expired oncacheTimeout, a subscriber kept receiving events decided from a stale role closure.Approach
clearCachemessages now carryclearAll: true, and a LiveQuery server receiving one drops its wholeauthCacherather than one user's sessions. Entries are repopulated lazily bygetAuthForSessionToken, so the cost is a re-resolution per active session after a role write, and role writes are rare relative to events.Three details worth reviewer attention:
userIdis still published when it is known. A LiveQuery server on an older version ignoresclearAlland readsuserId, so it keeps doing exactly what it does today rather than silently doing nothing. Mixed-version deployments degrade to current behavior instead of breaking._clearCachedRoles(userId)is kept for the reverse direction, an older Parse Server publishing{ userId }to a LiveQuery server on this version.cacheController.role.clear()never touched. Failures there are caught and logged rather than propagated, matching_clearCachedRoles.The whole cache is cleared rather than a computed set of affected sessions because the affected set cannot be reconstructed for a delete: by the time the message is published, the
_Rolerow and its_Joinrows are gone. Snapshotting members before the destroy would put the cost on every delete and still miss transitive members.Tests
spec/ParseLiveQueryServer.spec.jsgains arole cache invalidationblock:clearAll, which is the master key case that previously published nothing.userIdalongsideclearAll, pinning the back compat contract.clearAllmessage routes to the full clear, and a message without it routes to the targeted clear.authCacheand clears the role cache.spec/ParseLiveQueryServer.spec.js,spec/ParseLiveQuery.spec.js,spec/ParseRole.spec.js,spec/Auth.spec.jsandspec/rest.spec.jsall pass against MongoDB 8.Tasks
Summary by CodeRabbit