Skip to content

perf: per-channel grant cache never resets to 0 when no grantor is a member #116

@lml2468

Description

@lml2468

Background

Identified during code review of PR #114 (global grant scope + group/topic lookup split).

Problem

When any grantor activates a global grant, findActiveGrantsForChannel on the group path returns all global grants (unfiltered by channel). The per-channel cache is then written to "1".

As a result, every group channel cache entry becomes "1" — even for groups where no grantor is actually a member. Every inbound group message subsequently triggers N userIsGroupMember DB queries, all returning false, but the cache is never reset back to "0".

Impact

  • Unnecessary DB fan-out on every inbound group message
  • Query results are always false but cache stays stale at 1 indefinitely
  • Worsens linearly with number of groups and global grant holders

Proposed Fix

After all grantorCanReadChannel checks complete with 0 qualifying grantors, write back "0" to that channel's cache entry. This prevents permanently-hot false-positive cache entries.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P2Medium — next sprinttype:bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions