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
Background
Identified during code review of PR #114 (global grant scope + group/topic lookup split).
Problem
When any grantor activates a global grant,
findActiveGrantsForChannelon 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 NuserIsGroupMemberDB queries, all returningfalse, but the cache is never reset back to"0".Impact
falsebut cache stays stale at1indefinitelyProposed Fix
After all
grantorCanReadChannelchecks complete with 0 qualifying grantors, write back"0"to that channel's cache entry. This prevents permanently-hot false-positive cache entries.References