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

Commit

Permalink
Rework groups in the stream token.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Apr 19, 2022
1 parent 89c017c commit 267d382
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 deletions.
17 changes: 0 additions & 17 deletions synapse/storage/databases/main/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ def __init__(

self._push_rule_id_gen = IdGenerator(db_conn, "push_rules", "id")
self._push_rules_enable_id_gen = IdGenerator(db_conn, "push_rules_enable", "id")
self._group_updates_id_gen = StreamIdGenerator(
db_conn, "local_group_updates", "stream_id"
)

self._cache_id_gen: Optional[MultiWriterIdGenerator]
if isinstance(self.database_engine, PostgresEngine):
Expand Down Expand Up @@ -198,20 +195,6 @@ def __init__(
prefilled_cache=curr_state_delta_prefill,
)

_group_updates_prefill, min_group_updates_id = self.db_pool.get_cache_dict(
db_conn,
"local_group_updates",
entity_column="user_id",
stream_column="stream_id",
max_value=self._group_updates_id_gen.get_current_token(),
limit=1000,
)
self._group_updates_stream_cache = StreamChangeCache(
"_group_updates_stream_cache",
min_group_updates_id,
prefilled_cache=_group_updates_prefill,
)

self._stream_order_on_start = self.get_room_max_stream_ordering()
self._min_stream_order_on_start = self.get_room_min_stream_ordering()

Expand Down
3 changes: 0 additions & 3 deletions synapse/storage/databases/main/group_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,3 @@ def __init__(
# Register a legacy groups background update as a no-op.
database.updates.register_noop_background_update("local_group_updates_index")
super().__init__(database, db_conn, hs)

def get_group_stream_token(self) -> int:
return self._group_updates_id_gen.get_current_token() # type: ignore[attr-defined]
4 changes: 2 additions & 2 deletions synapse/streams/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def get_current_token(self) -> StreamToken:
push_rules_key = self.store.get_max_push_rules_stream_id()
to_device_key = self.store.get_to_device_stream_token()
device_list_key = self.store.get_device_stream_token()
groups_key = self.store.get_group_stream_token()

token = StreamToken(
room_key=self.sources.room.get_current_key(),
Expand All @@ -65,7 +64,8 @@ def get_current_token(self) -> StreamToken:
push_rules_key=push_rules_key,
to_device_key=to_device_key,
device_list_key=device_list_key,
groups_key=groups_key,
# Groups key is unused.
groups_key=0,
)
return token

Expand Down
4 changes: 4 additions & 0 deletions synapse/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ class StreamToken:
push_rules_key: int
to_device_key: int
device_list_key: int
# Note that the groups key is no longer used and may have bogus values.
groups_key: int

_SEPARATOR = "_"
Expand Down Expand Up @@ -701,6 +702,9 @@ async def to_string(self, store: "DataStore") -> str:
str(self.push_rules_key),
str(self.to_device_key),
str(self.device_list_key),
# Note that the groups key is no longer used, but it is still
# serialized so that there will not be confusion in the future
# if additional tokens are added.
str(self.groups_key),
]
)
Expand Down

0 comments on commit 267d382

Please sign in to comment.