Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synapse 1.100rc1 makes Postgres eat the whole CPU #16844

Closed
tulir opened this issue Jan 24, 2024 · 2 comments · Fixed by #16849
Closed

Synapse 1.100rc1 makes Postgres eat the whole CPU #16844

tulir opened this issue Jan 24, 2024 · 2 comments · Fixed by #16849

Comments

@tulir
Copy link
Contributor

tulir commented Jan 24, 2024

Description

Didn't happen immediately after upgrade, I'm not exactly sure what triggered it. #16833 sounds relevant since postgres active queries had lots of FROM event_auth_chain_links WHERE origin_chain_id = ANY(ARRAY[...]). Postgres was using the whole CPU by having multiple threads running similar queries.

image

After restarting synapse it calmed down slightly, but at least one postgres thread started running those queries again and immediately used 100% of a core, so I downgraded to 1.99 to avoid the whole CPU being eaten again overnight.

Steps to reproduce

  1. Upgrade to Synapse 1.100rc1
  2. Wait a while?
  3. Observe the system load exploding

Homeserver

maunium.net

Synapse Version

1.100rc1

Installation Method

Docker (dock.mau.dev/maunium/synapse)

Database

PostgreSQL

Workers

Multiple workers

Platform

Docker on Ubuntu 22.04

@erikjohnston
Copy link
Member

Hopefully fixed by #16849

@Revertron
Copy link

Revertron commented Sep 23, 2024

It seems that this problem is not fixed in 1.115.0+bookworm1.
I get very often these kind of slow requests:

2024-09-23 20:48:38.842 CEST [155885] synapse@synapse LOG:  duration: 13944.595 ms  statement:
                    WITH RECURSIVE links(chain_id) AS (
                        SELECT
                            DISTINCT origin_chain_id
                        FROM event_auth_chain_links WHERE origin_chain_id = ANY(ARRAY[<exactly 1000 ids>])
                        UNION
                        SELECT
                            target_chain_id
                        FROM event_auth_chain_links
                        INNER JOIN links ON (chain_id = origin_chain_id)
                    )
                    SELECT
                        origin_chain_id, origin_sequence_number,
                        target_chain_id, target_sequence_number
                    FROM links
                    INNER JOIN event_auth_chain_links ON (chain_id = origin_chain_id)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants