diff options
author | Richard van der Hoff <richard@matrix.org> | 2018-08-17 00:43:43 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2018-08-17 00:43:43 +0100 |
commit | 0e8d78f6aa56020ffb948a4b2c6feadba2d16712 (patch) | |
tree | 391fb5435e9a314730c27c3e041cd06fee5d0e03 /synapse/replication/tcp/commands.py | |
parent | Merge pull request #3705 from matrix-org/erikj/fix_inbound_fed_worker (diff) | |
download | synapse-0e8d78f6aa56020ffb948a4b2c6feadba2d16712.tar.xz |
Logcontexts for replication command handlers
Run the handlers for replication commands as background processes. This should improve the visibility in our metrics, and reduce the number of "running db transaction from sentinel context" warnings. Ideally it means converting the things that fire off deferreds into the night into things that actually return a Deferred when they are done. I've made a bit of a stab at this, but it will probably be leaky.
Diffstat (limited to 'synapse/replication/tcp/commands.py')
-rw-r--r-- | synapse/replication/tcp/commands.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/synapse/replication/tcp/commands.py b/synapse/replication/tcp/commands.py index f3908df642..327556f6a1 100644 --- a/synapse/replication/tcp/commands.py +++ b/synapse/replication/tcp/commands.py @@ -59,6 +59,12 @@ class Command(object): """ return self.data + def get_logcontext_id(self): + """Get a suitable string for the logcontext when processing this command""" + + # by default, we just use the command name. + return self.NAME + class ServerCommand(Command): """Sent by the server on new connection and includes the server_name. @@ -116,6 +122,9 @@ class RdataCommand(Command): _json_encoder.encode(self.row), )) + def get_logcontext_id(self): + return "RDATA-" + self.stream_name + class PositionCommand(Command): """Sent by the client to tell the client the stream postition without @@ -190,6 +199,9 @@ class ReplicateCommand(Command): def to_line(self): return " ".join((self.stream_name, str(self.token),)) + def get_logcontext_id(self): + return "REPLICATE-" + self.stream_name + class UserSyncCommand(Command): """Sent by the client to inform the server that a user has started or |