element-hq / element-hq/synapse

Host got stuck trying to resolve room state possibly due to low cache size

Open
#11,747 0 comments 0 reactions 0 assignees View on GitHub
S-Minor T-Defect
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#11747](https://github.com/matrix-org/synapse/issues/11747).

---

### Description

An EMS host went into a crash loop cycle due to being limited by memory. Once freed from that limit, it tried to resolve state for room `!aLUvbtiCWIkfYAjXTc:libera.chat` (`1 biggest rooms for state-res by CPU time: ['!aLUvbtiCWIkfYAjXTc:libera.chat (37.16s)']`) . From the graphs it looks like this was failing due to low cache sizes (100K events, 1 global factor). The database was being hammered into death until we got an alert for that and proceeded to up the caches (750K events, 4 global factor).

After restarting, the database hammering stopped and it looks like the host managed to move forward to continue resolving state for the room.

The host is still furiously working but not killing the database and seemingly not stuck.

The most intensive queries to the database seem to be:

`SELECT e.event_id, e.stream_ordering, ej.internal_metadata, ej.json, ej.format_version, r.room_version, rej.reason, e.outlier FROM events AS e JOIN event_json AS ej USING (event_id) LEFT JOIN rooms r ON r.room_id = e.room_id LEFT JOIN rejections as rej USING (event_id) WHERE e.event_id = ANY(ARRAY[?])`

`SELECT event_id FROM event_auth_chains AS c, (VALUES (?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?),(?,?,?)`

Times: UTC+2
Crash loop fixed: ~9:05
Caches bumped: ~10:40

Please ping for EMS host name if logs needed.

![Selection_999(842)](https://user-images.githubusercontent.com/1174866/149488770-86c7e31f-8618-4a00-955f-df55ea8e3948.png)

![Selection_999(843)](https://user-images.githubusercontent.com/1174866/149488792-9ad054b5-b72d-4b0f-a538-0b83e76d719a.png)

![Selection_999(844)](https://user-images.githubusercontent.com/1174866/149488812-3cc7448f-1fb6-49a3-9d82-c993eee7eb6b.png)

![Selection_999(845)](https://user-images.githubusercontent.com/1174866/149488836-9c699c19-5cfc-4017-92b8-79ecb083d974.png)

![Selection_999(846)](https://user-images.githubusercontent.com/1174866/149488859-c641ec25-4c20-4034-b69e-53b93eb36952.png)

![Selection_999(847)](https://user-images.githubusercontent.com/1174866/149488954-32eb274b-e1f5-432b-bd46-6253a5ebe268.png)

![Selection_999(848)](https://user-images.githubusercontent.com/1174866/149488967-cb45b5f0-b1fa-4bb0-ad6a-1f54a703adc4.png)

### Version information

- **Homeserver**: EMS customer, please ping for host name

- **Version**: v1.49.2

- **Platform**: EMS

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.