Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit c955f22

Browse files
committed
Fix bug when running presence off master (#10149)
Hopefully fixes #10027.
1 parent e0ddd82 commit c955f22

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

changelog.d/10149.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug which caused presence updates to stop working some time after restart, when using a presence writer worker.

synapse/storage/databases/main/presence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
instance_name=self._instance_name,
5151
tables=[("presence_stream", "instance_name", "stream_id")],
5252
sequence_name="presence_stream_sequence",
53-
writers=hs.config.worker.writers.to_device,
53+
writers=hs.config.worker.writers.presence,
5454
)
5555
else:
5656
self._presence_id_gen = StreamIdGenerator(

synapse/storage/util/id_generators.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,11 @@ def get_next(self):
397397
# ... persist event ...
398398
"""
399399

400+
# If we have a list of instances that are allowed to write to this
401+
# stream, make sure we're in it.
402+
if self._writers and self._instance_name not in self._writers:
403+
raise Exception("Tried to allocate stream ID on non-writer")
404+
400405
return _MultiWriterCtxManager(self)
401406

402407
def get_next_mult(self, n: int):
@@ -406,6 +411,11 @@ def get_next_mult(self, n: int):
406411
# ... persist events ...
407412
"""
408413

414+
# If we have a list of instances that are allowed to write to this
415+
# stream, make sure we're in it.
416+
if self._writers and self._instance_name not in self._writers:
417+
raise Exception("Tried to allocate stream ID on non-writer")
418+
409419
return _MultiWriterCtxManager(self, n)
410420

411421
def get_next_txn(self, txn: LoggingTransaction):
@@ -416,6 +426,11 @@ def get_next_txn(self, txn: LoggingTransaction):
416426
# ... persist event ...
417427
"""
418428

429+
# If we have a list of instances that are allowed to write to this
430+
# stream, make sure we're in it.
431+
if self._writers and self._instance_name not in self._writers:
432+
raise Exception("Tried to allocate stream ID on non-writer")
433+
419434
next_id = self._load_next_id_txn(txn)
420435

421436
with self._lock:

0 commit comments

Comments
 (0)