element-hq / element-hq/dendrite
Membership updater sometimes populates `sender_nid` and `target_nid`s for which no state key entries are assigned
- Dominant language
- Go
- Stars
- 965
- Forks
- 101
- PR merge metrics
- No merged PRs in 30d
Description
*This issue was originally created by [**@neilalexander**](https://github.com/neilalexander) at .*
I suspect this may be something to do with invites.
```
SELECT * FROM roomserver_membership AS m WHERE NOT EXISTS (
SELECT event_state_key_nid FROM roomserver_event_state_keys AS s
WHERE m.sender_nid = s.event_state_key_nid
);
```
```
SELECT * FROM roomserver_membership AS m WHERE NOT EXISTS (
SELECT event_state_key_nid FROM roomserver_event_state_keys AS s
WHERE m.target_nid = s.event_state_key_nid
);
```
PR #2213 will stop it from being fatal for syncing key updates for now but we really should get to the bottom of what's going on here. I suspect it's around the `assignStateKeyNID` call sites.
Contributor guide
Research direction
Start with the roomserver membership updater and trace the assignStateKeyNID call sites, paying particular attention to the invite path mentioned in the issue. Run the two supplied NOT EXISTS queries to reproduce the missing state-key entries and determine where the invariant breaks. Done means identifying and correcting the cause so both queries return no invalid membership rows.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100