element-hq / element-hq/synapse

`room_stats_current.current_state_events` database table is not updated when the server is no longer in the room

Open
#17,457 0 comments 0 reactions 0 assignees View on GitHub
A-Database A-Sync T-Enhancement
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

When a server is no longer in a room, the [`current_state_events` table is cleared for that `room_id`](https://github.com/element-hq/synapse/blob/develop/synapse/storage/databases/main/events.py#L1167-L1194). But we never update the `room_stats_current` table -> `current_state_events` to reflect this state.

The `room_stats_current.joined_members` does get updated `0` though.

### Reproduction instructions

1. Create a room
1. Notice the `current_state_events` count is > 0 (probably `7`) in the database: `psql synapse` -> `SELECT * FROM room_stats_current WHERE room_id = '!my-room'`
1. Leave the room (no one else should be left in the room) which will cause the server to no longer be in the room
1. The `current_state_events` will be cleared out for that room (0 rows, expected :white_check_mark: ): `psql synapse` -> `SELECT * FROM current_state_events WHERE room_id = '!my-room'`
1. Notice the `current_state_events` count is still `7` in the database (unexpected :x:): `psql synapse` -> `SELECT * FROM room_stats_current WHERE room_id = '!my-room'`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.