From f250f7644f2ab6f594e4adf148833dc867681d65 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 3 May 2022 09:42:37 +0100 Subject: [PATCH 1/3] Don't log at INFO when we get a POSITION --- synapse/replication/tcp/handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/synapse/replication/tcp/handler.py b/synapse/replication/tcp/handler.py index 615f1828dd73..e11d27aabc90 100644 --- a/synapse/replication/tcp/handler.py +++ b/synapse/replication/tcp/handler.py @@ -537,7 +537,7 @@ def on_POSITION(self, conn: IReplicationConnection, cmd: PositionCommand) -> Non # Ignore POSITION that are just our own echoes return - logger.info("Handling '%s %s'", cmd.NAME, cmd.to_line()) + logger.debug("Handling '%s %s'", cmd.NAME, cmd.to_line()) self._add_command_to_stream_queue(conn, cmd) @@ -590,7 +590,7 @@ async def _process_position( [stream.parse_row(row) for row in rows], ) - logger.info("Caught up with stream '%s' to %i", stream_name, cmd.new_token) + logger.info("Caught up with stream '%s' to %i", stream_name, cmd.new_token) # We've now caught up to position sent to us, notify handler. await self._replication_data_handler.on_position( From fbf6a9846b0bad943c44aa96207ac8928362490c Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 3 May 2022 09:42:48 +0100 Subject: [PATCH 2/3] Add some comments around POSITION and events --- synapse/replication/tcp/handler.py | 5 +++++ synapse/replication/tcp/resource.py | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/synapse/replication/tcp/handler.py b/synapse/replication/tcp/handler.py index e11d27aabc90..9aba1cd45111 100644 --- a/synapse/replication/tcp/handler.py +++ b/synapse/replication/tcp/handler.py @@ -567,6 +567,11 @@ async def _process_position( # between then and now. missing_updates = cmd.prev_token != current_token while missing_updates: + # Note: There may very well not be any new updates, but we check to + # make sure. This can particularly happen for the event stream where + # event persisters continuously send `POSITION`. See `resource.py` + # for why this can happen. + logger.info( "Fetching replication rows for '%s' between %i and %i", stream_name, diff --git a/synapse/replication/tcp/resource.py b/synapse/replication/tcp/resource.py index c6870df8f954..99f09669f00b 100644 --- a/synapse/replication/tcp/resource.py +++ b/synapse/replication/tcp/resource.py @@ -204,6 +204,15 @@ async def _run_notifier_loop(self) -> None: # turns out that e.g. account data streams share # their "current token" with each other, meaning # that it is *not* safe to send a POSITION. + + # Note: `last_token` may not *actually* be the + # last token we sent out in a RDATA or POSITION. + # This can happen if we sent out an RDATA for + # position X when our current token was say X+1. + # Other workers will see RDATA for X and then a + # POSITION with last token of X+1, which will + # cause them to check if there were any missing + # updates between X and X+1. logger.info( "Sending position: %s -> %s", stream.NAME, From f2a2ff469459ba198c8ef192f489f9328573589a Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 3 May 2022 09:50:43 +0100 Subject: [PATCH 3/3] Newsfile --- changelog.d/12610.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/12610.misc diff --git a/changelog.d/12610.misc b/changelog.d/12610.misc new file mode 100644 index 000000000000..02efe0c72f51 --- /dev/null +++ b/changelog.d/12610.misc @@ -0,0 +1 @@ +Reduce log spam when running multiple event persisters.