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

Fix bug when running presence off master #10149

Merged
merged 4 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/10149.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix bug where presence updates would stop working when using a presence writer worker.
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion synapse/storage/databases/main/presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(
instance_name=self._instance_name,
tables=[("presence_stream", "instance_name", "stream_id")],
sequence_name="presence_stream_sequence",
writers=hs.config.worker.writers.to_device,
writers=hs.config.worker.writers.presence,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hawkward!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inorite

)
else:
self._presence_id_gen = StreamIdGenerator(
Expand Down
12 changes: 12 additions & 0 deletions synapse/storage/util/id_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ def get_next(self):
# ... persist event ...
"""

# If we have a list of instance that are allowed to write to this
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
# stream, make sure we're in it.
assert not self._writers or self._instance_name in self._writers

return _MultiWriterCtxManager(self)

def get_next_mult(self, n: int):
Expand All @@ -406,6 +410,10 @@ def get_next_mult(self, n: int):
# ... persist events ...
"""

# If we have a list of instance that are allowed to write to this
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
# stream, make sure we're in it.
assert not self._writers or self._instance_name in self._writers

return _MultiWriterCtxManager(self, n)

def get_next_txn(self, txn: LoggingTransaction):
Expand All @@ -416,6 +424,10 @@ def get_next_txn(self, txn: LoggingTransaction):
# ... persist event ...
"""

# If we have a list of instance that are allowed to write to this
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
# stream, make sure we're in it.
assert not self._writers or self._instance_name in self._writers

next_id = self._load_next_id_txn(txn)

with self._lock:
Expand Down