You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this stage, you'll implement part 2 of the handshake that happens when a replica connects to master.
1
+
In this stage, you'll implement the second part of the replication handshake.
2
2
3
-
### Handshake (continued from previous stage)
3
+
### The Handshake Process (Recap)
4
4
5
-
As a recap, there are three parts to the handshake:
5
+
As a recap, there are three parts to the handshake process:
6
6
7
-
- The replica sends a `PING` to the master (Previous stage)
8
-
- The replica sends `REPLCONF` twice to the master (**This stage**)
9
-
- The replica sends `PSYNC` to the master (Next stage)
7
+
1. The replica sends a `PING` to the master (Handled in the previous stage)
8
+
2. The replica sends `REPLCONF` twice to the master
9
+
3. The replica sends `PSYNC` to the master
10
10
11
-
After receiving a response to `PING`, the replica then sends 2 [REPLCONF](https://redis.io/commands/replconf/) commands to the master.
11
+
For this stage, you'll handle the second part of this process.
12
12
13
-
The `REPLCONF`command is used to configure replication. Replicas will send this command to the master twice:
13
+
### The `REPLCONF`Command
14
14
15
-
- The first time, it'll be sent like this: `REPLCONF listening-port <PORT>`
16
-
- This is the replica notifying the master of the port it's listening on (for [monitoring/logging purposes](https://github.com/redis/redis/blob/90178712f6eccf1e5b61daa677c5c103114bda3a/src/replication.c#L107-L130), not for actual propagation).
17
-
- The second time, it'll be sent like this: `REPLCONF capa psync2`
18
-
- This is the replica notifying the master of its capabilities ("capa" is short for "capabilities")
19
-
- You can safely hardcode these capabilities for now, we won't need to use them in this challenge.
15
+
The `REPLCONF` command is used to configure a connected replica. After receiving a response to `PING`, the replica sends two `REPLCONF` commands to the master:
20
16
21
-
These commands should be sent as RESP Arrays, so the exact bytes will look something like this:
17
+
1.`REPLCONF listening-port <PORT>`: This tells the master which port the replica is listening on. This value is used for [monitoring and logging](https://github.com/redis/redis/blob/90178712f6eccf1e5b61daa677c5c103114bda3a/src/replication.c#L107-L130), not for replication itself.
18
+
2.`REPLCONF capa psync2`: This notifies the master of the replica's capabilities.
19
+
-`capa` stands for "capabilities". It indicates that the next argument is a feature the replica supports.
20
+
-`psync2` signals that the replica supports the PSYNC 2.0 protocol, which is an improved version of the [partial synchronization](https://redis.io/docs/latest/operate/oss_and_stack/management/replication/) feature used to resynchronize a replica with its master.
21
+
- You can safely hardcode `capa psync2` for now.
22
+
23
+
Both commands should be sent as RESP arrays, so the exact bytes will look something like this:
22
24
23
25
```
24
26
# REPLCONF listening-port <PORT>
@@ -28,7 +30,7 @@ These commands should be sent as RESP Arrays, so the exact bytes will look somet
For both commands, the master will respond with `+OK\r\n` ("OK" encoded as a RESP Simple String).
33
+
For both commands, the master will respond with `+OK\r\n`. That's the string `OK` encoded as a [simple string](https://redis.io/docs/latest/develop/reference/protocol-spec/#simple-strings).
32
34
33
35
### Tests
34
36
@@ -38,12 +40,12 @@ The tester will execute your program like this:
0 commit comments