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

Commit e3c91a3

Browse files
authored
Make SlavedIdTracker.advance have same interface as MultiWriterIDGenerator (#8171)
1 parent 4c6c56d commit e3c91a3

File tree

12 files changed

+16
-15
lines changed

12 files changed

+16
-15
lines changed

changelog.d/8171.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make `SlavedIdTracker.advance` have the same interface as `MultiWriterIDGenerator`.

synapse/replication/slave/storage/_slaved_id_tracker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def __init__(self, db_conn, table, column, extra_tables=[], step=1):
2121
self.step = step
2222
self._current = _load_current_id(db_conn, table, column, step)
2323
for table, column in extra_tables:
24-
self.advance(_load_current_id(db_conn, table, column))
24+
self.advance(None, _load_current_id(db_conn, table, column))
2525

26-
def advance(self, new_id):
26+
def advance(self, instance_name, new_id):
2727
self._current = (max if self.step > 0 else min)(self._current, new_id)
2828

2929
def get_current_token(self):

synapse/replication/slave/storage/account_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ def get_max_account_data_stream_id(self):
4141

4242
def process_replication_rows(self, stream_name, instance_name, token, rows):
4343
if stream_name == TagAccountDataStream.NAME:
44-
self._account_data_id_gen.advance(token)
44+
self._account_data_id_gen.advance(instance_name, token)
4545
for row in rows:
4646
self.get_tags_for_user.invalidate((row.user_id,))
4747
self._account_data_stream_cache.entity_has_changed(row.user_id, token)
4848
elif stream_name == AccountDataStream.NAME:
49-
self._account_data_id_gen.advance(token)
49+
self._account_data_id_gen.advance(instance_name, token)
5050
for row in rows:
5151
if not row.room_id:
5252
self.get_global_account_data_by_type_for_user.invalidate(

synapse/replication/slave/storage/deviceinbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(self, database: DatabasePool, db_conn, hs):
4646

4747
def process_replication_rows(self, stream_name, instance_name, token, rows):
4848
if stream_name == ToDeviceStream.NAME:
49-
self._device_inbox_id_gen.advance(token)
49+
self._device_inbox_id_gen.advance(instance_name, token)
5050
for row in rows:
5151
if row.entity.startswith("@"):
5252
self._device_inbox_stream_cache.entity_has_changed(

synapse/replication/slave/storage/devices.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ def __init__(self, database: DatabasePool, db_conn, hs):
5050

5151
def process_replication_rows(self, stream_name, instance_name, token, rows):
5252
if stream_name == DeviceListsStream.NAME:
53-
self._device_list_id_gen.advance(token)
53+
self._device_list_id_gen.advance(instance_name, token)
5454
self._invalidate_caches_for_devices(token, rows)
5555
elif stream_name == UserSignatureStream.NAME:
56-
self._device_list_id_gen.advance(token)
56+
self._device_list_id_gen.advance(instance_name, token)
5757
for row in rows:
5858
self._user_signature_stream_cache.entity_has_changed(row.user_id, token)
5959
return super().process_replication_rows(stream_name, instance_name, token, rows)

synapse/replication/slave/storage/groups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def get_group_stream_token(self):
4040

4141
def process_replication_rows(self, stream_name, instance_name, token, rows):
4242
if stream_name == GroupServerStream.NAME:
43-
self._group_updates_id_gen.advance(token)
43+
self._group_updates_id_gen.advance(instance_name, token)
4444
for row in rows:
4545
self._group_updates_stream_cache.entity_has_changed(row.user_id, token)
4646

synapse/replication/slave/storage/presence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def get_current_presence_token(self):
4444

4545
def process_replication_rows(self, stream_name, instance_name, token, rows):
4646
if stream_name == PresenceStream.NAME:
47-
self._presence_id_gen.advance(token)
47+
self._presence_id_gen.advance(instance_name, token)
4848
for row in rows:
4949
self.presence_stream_cache.entity_has_changed(row.user_id, token)
5050
self._get_presence_for_user.invalidate((row.user_id,))

synapse/replication/slave/storage/push_rule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def process_replication_rows(self, stream_name, instance_name, token, rows):
3030
assert isinstance(self._push_rules_stream_id_gen, SlavedIdTracker)
3131

3232
if stream_name == PushRulesStream.NAME:
33-
self._push_rules_stream_id_gen.advance(token)
33+
self._push_rules_stream_id_gen.advance(instance_name, token)
3434
for row in rows:
3535
self.get_push_rules_for_user.invalidate((row.user_id,))
3636
self.get_push_rules_enabled_for_user.invalidate((row.user_id,))

synapse/replication/slave/storage/pushers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ def get_pushers_stream_token(self):
3434

3535
def process_replication_rows(self, stream_name, instance_name, token, rows):
3636
if stream_name == PushersStream.NAME:
37-
self._pushers_id_gen.advance(token)
37+
self._pushers_id_gen.advance(instance_name, token)
3838
return super().process_replication_rows(stream_name, instance_name, token, rows)

synapse/replication/slave/storage/receipts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def invalidate_caches_for_receipt(self, room_id, receipt_type, user_id):
4646

4747
def process_replication_rows(self, stream_name, instance_name, token, rows):
4848
if stream_name == ReceiptsStream.NAME:
49-
self._receipts_id_gen.advance(token)
49+
self._receipts_id_gen.advance(instance_name, token)
5050
for row in rows:
5151
self.invalidate_caches_for_receipt(
5252
row.room_id, row.receipt_type, row.user_id

0 commit comments

Comments
 (0)