|
43 | 43 | from synapse.api.room_versions import RoomVersion, RoomVersions
|
44 | 44 | from synapse.config.homeserver import HomeServerConfig
|
45 | 45 | from synapse.events import EventBase
|
| 46 | +from synapse.replication.tcp.streams.partial_state import UnPartialStatedRoomStream |
46 | 47 | from synapse.storage._base import SQLBaseStore, db_to_json, make_in_list_sql_clause
|
47 | 48 | from synapse.storage.database import (
|
48 | 49 | DatabasePool,
|
@@ -144,6 +145,13 @@ def __init__(
|
144 | 145 | "stream_id",
|
145 | 146 | )
|
146 | 147 |
|
| 148 | + def process_replication_position( |
| 149 | + self, stream_name: str, instance_name: str, token: int |
| 150 | + ) -> None: |
| 151 | + if stream_name == UnPartialStatedRoomStream.NAME: |
| 152 | + self._un_partial_stated_rooms_stream_id_gen.advance(instance_name, token) |
| 153 | + return super().process_replication_position(stream_name, instance_name, token) |
| 154 | + |
147 | 155 | async def store_room(
|
148 | 156 | self,
|
149 | 157 | room_id: str,
|
@@ -1281,13 +1289,10 @@ async def get_join_event_id_and_device_lists_stream_id_for_partial_state(
|
1281 | 1289 | )
|
1282 | 1290 | return result["join_event_id"], result["device_lists_stream_id"]
|
1283 | 1291 |
|
1284 |
| - def get_un_partial_stated_rooms_token(self) -> int: |
1285 |
| - # TODO(faster_joins, multiple writers): This is inappropriate if there |
1286 |
| - # are multiple writers because workers that don't write often will |
1287 |
| - # hold all readers up. |
1288 |
| - # (See `MultiWriterIdGenerator.get_persisted_upto_position` for an |
1289 |
| - # explanation.) |
1290 |
| - return self._un_partial_stated_rooms_stream_id_gen.get_current_token() |
| 1292 | + def get_un_partial_stated_rooms_token(self, instance_name: str) -> int: |
| 1293 | + return self._un_partial_stated_rooms_stream_id_gen.get_current_token_for_writer( |
| 1294 | + instance_name |
| 1295 | + ) |
1291 | 1296 |
|
1292 | 1297 | async def get_un_partial_stated_rooms_from_stream(
|
1293 | 1298 | self, instance_name: str, last_id: int, current_id: int, limit: int
|
|
0 commit comments