mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 04:13:46 +01:00
Also discard 'caches' and 'backfill' stream POSITIONS (#16655)
Follow on from #16640
This commit is contained in:
parent
bdb0cbc5ca
commit
6fec2d035f
2 changed files with 17 additions and 0 deletions
1
changelog.d/16655.misc
Normal file
1
changelog.d/16655.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
More efficiently handle no-op `POSITION` over replication.
|
|
@ -305,6 +305,14 @@ class BackfillStream(Stream):
|
||||||
# which means we need to negate it.
|
# which means we need to negate it.
|
||||||
return -self.store._backfill_id_gen.get_minimal_local_current_token()
|
return -self.store._backfill_id_gen.get_minimal_local_current_token()
|
||||||
|
|
||||||
|
def can_discard_position(
|
||||||
|
self, instance_name: str, prev_token: int, new_token: int
|
||||||
|
) -> bool:
|
||||||
|
# Backfill stream can't go backwards, so we know we can ignore any
|
||||||
|
# positions where the tokens are from before the current token.
|
||||||
|
|
||||||
|
return new_token <= self.current_token(instance_name)
|
||||||
|
|
||||||
|
|
||||||
class PresenceStream(_StreamFromIdGen):
|
class PresenceStream(_StreamFromIdGen):
|
||||||
@attr.s(slots=True, frozen=True, auto_attribs=True)
|
@attr.s(slots=True, frozen=True, auto_attribs=True)
|
||||||
|
@ -519,6 +527,14 @@ class CachesStream(Stream):
|
||||||
return self.store._cache_id_gen.get_minimal_local_current_token()
|
return self.store._cache_id_gen.get_minimal_local_current_token()
|
||||||
return self.current_token(self.local_instance_name)
|
return self.current_token(self.local_instance_name)
|
||||||
|
|
||||||
|
def can_discard_position(
|
||||||
|
self, instance_name: str, prev_token: int, new_token: int
|
||||||
|
) -> bool:
|
||||||
|
# Caches streams can't go backwards, so we know we can ignore any
|
||||||
|
# positions where the tokens are from before the current token.
|
||||||
|
|
||||||
|
return new_token <= self.current_token(instance_name)
|
||||||
|
|
||||||
|
|
||||||
class DeviceListsStream(_StreamFromIdGen):
|
class DeviceListsStream(_StreamFromIdGen):
|
||||||
"""Either a user has updated their devices or a remote server needs to be
|
"""Either a user has updated their devices or a remote server needs to be
|
||||||
|
|
Loading…
Reference in a new issue