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

Commit afb216c

Browse files
authored
Remove no-op send_command for Redis replication. (#15274)
With Redis commands do not need to be re-issued by the main process (they fan-out to all processes at once) and thus it is no longer necessary to worry about them reflecting recursively forever.
1 parent b0a0fb5 commit afb216c

File tree

4 files changed

+3
-89
lines changed

4 files changed

+3
-89
lines changed

changelog.d/15272.misc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Remove unused class `DirectTcpReplicationClientFactory`.
1+
Clean-up direct TCP replication code.

changelog.d/15274.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clean-up direct TCP replication code.

synapse/replication/tcp/handler.py

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -625,23 +625,6 @@ def on_REMOTE_SERVER_UP(
625625

626626
self._notifier.notify_remote_server_up(cmd.data)
627627

628-
# We relay to all other connections to ensure every instance gets the
629-
# notification.
630-
#
631-
# When configured to use redis we'll always only have one connection and
632-
# so this is a no-op (all instances will have already received the same
633-
# REMOTE_SERVER_UP command).
634-
#
635-
# For direct TCP connections this will relay to all other connections
636-
# connected to us. When on master this will correctly fan out to all
637-
# other direct TCP clients and on workers there'll only be the one
638-
# connection to master.
639-
#
640-
# (The logic here should also be sound if we have a mix of Redis and
641-
# direct TCP connections so long as there is only one traffic route
642-
# between two instances, but that is not currently supported).
643-
self.send_command(cmd, ignore_conn=conn)
644-
645628
def new_connection(self, connection: IReplicationConnection) -> None:
646629
"""Called when we have a new connection."""
647630
self._connections.append(connection)
@@ -689,21 +672,14 @@ def connected(self) -> bool:
689672
"""
690673
return bool(self._connections)
691674

692-
def send_command(
693-
self, cmd: Command, ignore_conn: Optional[IReplicationConnection] = None
694-
) -> None:
675+
def send_command(self, cmd: Command) -> None:
695676
"""Send a command to all connected connections.
696677
697678
Args:
698679
cmd
699-
ignore_conn: If set don't send command to the given connection.
700-
Used when relaying commands from one connection to all others.
701680
"""
702681
if self._connections:
703682
for connection in self._connections:
704-
if connection == ignore_conn:
705-
continue
706-
707683
try:
708684
connection.send_command(cmd)
709685
except Exception:

tests/replication/tcp/test_remote_server_up.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)