This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Background process rotate_notifs
fails due to unique constraint violation #14641
Closed
Description
Description
We've recently started seeing an exception being thrown every 30s from the background process 'rotate_notifs'. There does not appear to be any impact on users.
synapse.metrics.background_process_metrics: [rotate_notifs-179] Background process 'rotate_notifs' threw an exception
This appears to be the result of a violation of a unique constraint on the event_push_summary
table. Full stack trace of the error is provided below.
Steps to reproduce
- Tail logs
Homeserver
self-hosted
Synapse Version
{"server_version":"1.70.1","python_version":"3.9.13"}
Installation Method
Other (please mention below)
Database
SQLite
Workers
Single process
Platform
Running on NixOS using the Nix package on AWS instance.
Configuration
Some users have enabled threads.
Relevant log output
synapse.metrics.background_process_metrics: [rotate_notifs-179] Background process 'rotate_notifs' threw an exception
Traceback (most recent call last):
File "/nix/store/5mwm1djp7w1vzvijjwwc4x9wx9y4cwzf-matrix-synapse-1.70.1/lib/python3.9/site-packages/synapse/metrics/background_process_metrics.py", line 240, in run
return await func(*args, **kwargs)
File "/nix/store/5mwm1djp7w1vzvijjwwc4x9wx9y4cwzf-matrix-synapse-1.70.1/lib/python3.9/site-packages/synapse/storage/databases/main/event_push_actions.py", line 1307, in _rotate_notifs
caught_up = await self.db_pool.runInteraction(
File "/nix/store/5mwm1djp7w1vzvijjwwc4x9wx9y4cwzf-matrix-synapse-1.70.1/lib/python3.9/site-packages/synapse/storage/database.py", line 881, in runInteraction
return await delay_cancellation(_runInteraction())
File "/nix/store/n2a4bbdslmh0mj9h9bv2cxwpgzgvcg0a-python3.9-Twisted-22.4.0/lib/python3.9/site-packages/twisted/internet/defer.py", line 1656, in _inlineCallbacks
result = current_context.run(
File "/nix/store/n2a4bbdslmh0mj9h9bv2cxwpgzgvcg0a-python3.9-Twisted-22.4.0/lib/python3.9/site-packages/twisted/python/failure.py", line 514, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/nix/store/5mwm1djp7w1vzvijjwwc4x9wx9y4cwzf-matrix-synapse-1.70.1/lib/python3.9/site-packages/synapse/storage/database.py", line 848, in _runInteraction
result = await self.runWithConnection(
File "/nix/store/5mwm1djp7w1vzvijjwwc4x9wx9y4cwzf-matrix-synapse-1.70.1/lib/python3.9/site-packages/synapse/storage/database.py", line 976, in runWithConnection
return await make_deferred_yieldable(
File "/nix/store/n2a4bbdslmh0mj9h9bv2cxwpgzgvcg0a-python3.9-Twisted-22.4.0/lib/python3.9/site-packages/twisted/python/threadpool.py", line 244, in inContext
result = inContext.theWork() # type: ignore[attr-defined]
File "/nix/store/n2a4bbdslmh0mj9h9bv2cxwpgzgvcg0a-python3.9-Twisted-22.4.0/lib/python3.9/site-packages/twisted/python/threadpool.py", line 260, in <lambda>
inContext.theWork = lambda: context.call( # type: ignore[attr-defined]
File "/nix/store/n2a4bbdslmh0mj9h9bv2cxwpgzgvcg0a-python3.9-Twisted-22.4.0/lib/python3.9/site-packages/twisted/python/context.py", line 117, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/nix/store/n2a4bbdslmh0mj9h9bv2cxwpgzgvcg0a-python3.9-Twisted-22.4.0/lib/python3.9/site-packages/twisted/python/context.py", line 82, in callWithContext
return func(*args, **kw)
File "/nix/store/n2a4bbdslmh0mj9h9bv2cxwpgzgvcg0a-python3.9-Twisted-22.4.0/lib/python3.9/site-packages/twisted/enterprise/adbapi.py", line 282, in _runWithConnection
result = func(conn, *args, **kw)
File "/nix/store/5mwm1djp7w1vzvijjwwc4x9wx9y4cwzf-matrix-synapse-1.70.1/lib/python3.9/site-packages/synapse/storage/database.py", line 969, in inner_func
return func(db_conn, *args, **kwargs)
File "/nix/store/5mwm1djp7w1vzvijjwwc4x9wx9y4cwzf-matrix-synapse-1.70.1/lib/python3.9/site-packages/synapse/storage/database.py", line 710, in new_transaction
r = func(cursor, *args, **kwargs)
File "/nix/store/5mwm1djp7w1vzvijjwwc4x9wx9y4cwzf-matrix-synapse-1.70.1/lib/python3.9/site-packages/synapse/storage/databases/main/event_push_actions.py", line 1530, in _rotate_notifs_txn
self._rotate_notifs_before_txn(
File "/nix/store/5mwm1djp7w1vzvijjwwc4x9wx9y4cwzf-matrix-synapse-1.70.1/lib/python3.9/site-packages/synapse/storage/databases/main/event_push_actions.py", line 1643, in _rotate_notifs_before_txn
self.db_pool.simple_upsert_many_txn(
File "/nix/store/5mwm1djp7w1vzvijjwwc4x9wx9y4cwzf-matrix-synapse-1.70.1/lib/python3.9/site-packages/synapse/storage/database.py", line 1464, in simple_upsert_many_txn
return self.simple_upsert_many_txn_native_upsert(
File "/nix/store/5mwm1djp7w1vzvijjwwc4x9wx9y4cwzf-matrix-synapse-1.70.1/lib/python3.9/site-packages/synapse/storage/database.py", line 1571, in simple_upsert_many_txn_native_upsert
return txn.execute_batch(sql, args)
File "/nix/store/5mwm1djp7w1vzvijjwwc4x9wx9y4cwzf-matrix-synapse-1.70.1/lib/python3.9/site-packages/synapse/storage/database.py", line 368, in execute_batch
self.executemany(sql, args)
File "/nix/store/5mwm1djp7w1vzvijjwwc4x9wx9y4cwzf-matrix-synapse-1.70.1/lib/python3.9/site-packages/synapse/storage/database.py", line 391, in executemany
self._do_execute(self.txn.executemany, sql, *args)
File "/nix/store/5mwm1djp7w1vzvijjwwc4x9wx9y4cwzf-matrix-synapse-1.70.1/lib/python3.9/site-packages/synapse/storage/database.py", line 436, in _do_execute
return func(sql, *args, **kwargs)
sqlite3.IntegrityError: UNIQUE constraint failed: event_push_summary.user_id, event_push_summary.room_id
Anything else that would be useful to know?
From the debug logs - the sql values looking at user_id
, room_id
and thread_id
are unique, but user_id
and room_id
are not.
Metadata
Metadata
Assignees
Labels
DB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the dbThreaded messagesMost users are unlikely to come across this or unexpected workflowBlocks non-critical functionality, workarounds exist.Bugs, crashes, hangs, security vulnerabilities, or other reported issues.This issue is blocked awaiting information from the reporter