This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
postgresql deadlock - INSERT INTO user_ips #14199
Copy link
Copy link
Closed
Labels
A-DatabaseDB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the dbDB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the dbO-UncommonMost users are unlikely to come across this or unexpected workflowMost users are unlikely to come across this or unexpected workflowS-MinorBlocks non-critical functionality, workarounds exist.Blocks non-critical functionality, workarounds exist.T-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Description
Description
Dear Synapse,
Deadlock is happen so often in Posgresql because
synapse workers tries to update lots of client ips on background process.
Also, sometimes it takes over 5 secs to process insert user_ips.
Is there any way to turn off inserting client ips? or any configuration?
Can I block(comment out) some store such as ClientIpBackgroundUpdateStore?
Is it independent from other synapse modules? So, it does not side-effect from that?
Thanks you.
Best Regards
Hyosung
Steps to reproduce
Reproducing
Reproducing is not easy. It is only shown on our synapse homeserver.
- GET /sync is called somewhat often.
Synapse Deployment
- Master and 3 workers to handle /sync from clients.
Synapse Usage
- About 18 hz for /sync at peak time for each worker
Homeserver
another homeserver
Synapse Version
1.35.0
Installation Method
Docker (matrixdotorg/synapse)
Platform
Operating System
- vmware, ubuntu, 28cpu, 60gb
Relevant log output
### Synapse Worker3 Log
2022-10-14 14:12:05
{"log":" 0/5\n"}
2022-10-14 14:12:05
{"log":"CONTEXT: while inserting index tuple (21022,25) in relation \"user_ips\"\n"}
2022-10-14 14:12:05
{"log":"HINT: See server log for query details.\n"}
2022-10-14 14:12:05
{"log":"Process 42 waits for ShareLock on transaction 716397986; blocked by process 96.\n"}
2022-10-14 14:12:05
{"log":"DETAIL: Process 96 waits for ShareLock on transaction 716398006; blocked by process 42.\n"}
2022-10-14 14:12:05
{"log":"2022-10-14 13:12:05,483 - synapse.storage.txn - 534 - WARNING - update_client_ips-123492- [TXN OPERROR] {_update_client_ips_batch-96c00a} deadlock detected\n"}Anything else that would be useful to know?
Posgresql Log
2022-10-14 13:12:05.561 UTC [96] STATEMENT: INSERT INTO user_ips (user_id, access_token, ip, user_agent, device_id, last_seen) VALUES ('@wuc_199_b63b8a6b-79a5-452d-83f4-9e00cc1607be:default', '<ACCESS_TOKEN_1_REDACTED>', '51.219.48.16', 'okhttp/3.12.1', '94978d8bf8d35545', 1665753120691) ON CONFLICT (user_id, access_token, ip) DO UPDATE SET user_agent=EXCLUDED.user_agent, device_id=EXCLUDED.device_id, last_seen=EXCLUDED.last_seen
2022-10-14 13:12:05.561 UTC [96] ERROR: could not serialize access due to concurrent update
2022-10-14 13:12:05.481 UTC [96] STATEMENT: INSERT INTO user_ips (user_id, access_token, ip, user_agent, device_id, last_seen) VALUES ('@wuc_415_904f65fe-bc50-4aa2-97ef-f0d1cf942c62:default', '<ACCESS_TOKEN_2_REDACTED>', '51.241.170.92', 'iPECS%20ONE/2 CFNetwork/1335.0.3 Darwin/21.6.0', '1C17A6BA-6C8B-4FD9-BD6F-A47E93C27145', 1665753121063) ON CONFLICT (user_id, access_token, ip) DO UPDATE SET user_agent=EXCLUDED.user_agent, device_id=EXCLUDED.device_id, last_seen=EXCLUDED.last_seen
2022-10-14 13:12:05.481 UTC [96] CONTEXT: while inserting index tuple (21022,25) in relation "user_ips"
2022-10-14 13:12:05.481 UTC [96] HINT: See server log for query details.
Process 42: INSERT INTO user_ips (user_id, access_token, ip, user_agent, device_id, last_seen) VALUES ('@wuc_199_b63b8a6b-79a5-452d-83f4-9e00cc1607be:default', '<ACCESS_TOKEN_1_REDACTED>', '51.219.48.16', 'okhttp/3.12.1', '94978d8bf8d35545', 1665753120457) ON CONFLICT (user_id, access_token, ip) DO UPDATE SET user_agent=EXCLUDED.user_agent, device_id=EXCLUDED.device_id, last_seen=EXCLUDED.last_seen
Process 96: INSERT INTO user_ips (user_id, access_token, ip, user_agent, device_id, last_seen) VALUES ('@wuc_415_904f65fe-bc50-4aa2-97ef-f0d1cf942c62:default', '<ACCESS_TOKEN_2_REDACTED>', '51.241.170.92', 'iPECS%20ONE/2 CFNetwork/1335.0.3 Darwin/21.6.0', '1C17A6BA-6C8B-4FD9-BD6F-A47E93C27145', 1665753121063) ON CONFLICT (user_id, access_token, ip) DO UPDATE SET user_agent=EXCLUDED.user_agent, device_id=EXCLUDED.device_id, last_seen=EXCLUDED.last_seen
Process 42 waits for ShareLock on transaction 716397986; blocked by process 96.
2022-10-14 13:12:05.481 UTC [96] DETAIL: Process 96 waits for ShareLock on transaction 716398006; blocked by process 42.
2022-10-14 13:12:05.481 UTC [96] ERROR: deadlock detected
Metadata
Metadata
Assignees
Labels
A-DatabaseDB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the dbDB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the dbO-UncommonMost users are unlikely to come across this or unexpected workflowMost users are unlikely to come across this or unexpected workflowS-MinorBlocks non-critical functionality, workarounds exist.Blocks non-critical functionality, workarounds exist.T-DefectBugs, crashes, hangs, security vulnerabilities, or other reported issues.Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
