Move device changes off the main process (#18581)
The main goal of this PR is to handle device list changes onto multiple writers, off the main process, so that we can have logins happening whilst Synapse is rolling-restarting. This is quite an intrusive change, so I would advise to review this commit by commit; I tried to keep the history as clean as possible. There are a few things to consider: - the `device_list_key` in stream tokens becomes a `MultiWriterStreamToken`, which has a few implications in sync and on the storage layer - we had a split between `DeviceHandler` and `DeviceWorkerHandler` for master vs. worker process. I've kept this split, but making it rather writer vs. non-writer worker, using method overrides for doing replication calls when needed - there are a few operations that need to happen on a single worker at a time. Instead of using cross-worker locks, for now I made them run on the first writer on the list --------- Co-authored-by: Eric Eastwood <erice@element.io>
This commit is contained in:
@@ -28,7 +28,7 @@ from synapse.api.constants import EduTypes, EventTypes
|
||||
from synapse.api.errors import NotFoundError
|
||||
from synapse.events import EventBase
|
||||
from synapse.federation.units import Transaction
|
||||
from synapse.handlers.device import DeviceHandler
|
||||
from synapse.handlers.device import DeviceWriterHandler
|
||||
from synapse.handlers.presence import UserPresenceState
|
||||
from synapse.handlers.push_rules import InvalidRuleException
|
||||
from synapse.module_api import ModuleApi
|
||||
@@ -819,7 +819,7 @@ class ModuleApiTestCase(BaseModuleApiTestCase):
|
||||
|
||||
# Delete the device.
|
||||
device_handler = self.hs.get_device_handler()
|
||||
assert isinstance(device_handler, DeviceHandler)
|
||||
assert isinstance(device_handler, DeviceWriterHandler)
|
||||
self.get_success(device_handler.delete_devices(user_id, [device_id]))
|
||||
|
||||
# Check that the callback was called and the pushers still existed.
|
||||
|
||||
Reference in New Issue
Block a user