Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Filtering logic for state events (used to speed up ACL federation checks) seems broken? #2969

@ara4n

Description

@ara4n

storage/state.py's _get_state_for_groups claims that if you pass in a types list with an entry with a state_key of None, the None will match all state_keys of the given type:

def _get_state_for_groups(self, groups, types=None):
"""Given list of groups returns dict of group -> list of state events
with matching types. `types` is a list of `(type, state_key)`, where
a `state_key` of None matches all state_keys. If `types` is None then
all events are returned.

This looks to be correct when we're querying the cache, thanks to:

if state_key is None:
type_to_key[typ] = None

However, it doesn't look like it's correct when we're querying the DB - where the None looks like it's turned into an AND state_key = NULL or similar?

clause_to_args = [
(
"AND type = ? AND state_key = ?",
(etype, state_key)
)
for etype, state_key in types

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions