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 add support for sending an empty RDB file as a master. This is part of the "full resynchronization" process.
1
+
In this stage, you'll add support for sending an empty RDB file as a master.
2
2
3
-
### Full resynchronization
3
+
### Full Resynchronization
4
4
5
-
When a replica connects to a master for the first time, it sends a `PSYNC ? -1` command. This is the replica's way of
6
-
telling the master that it doesn't have any data yet, and needs to be fully resynchronized.
5
+
When a replica connects to a master for the first time, it sends a `PSYNC ? -1` command. This is the replica's way of telling the master that it doesn't have any data yet and needs to be fully resynchronized.
7
6
8
-
The master acknowledges this by sending a `FULLRESYNC` response to the replica.
7
+
The master responds in two steps:
9
8
10
-
After sending the `FULLRESYNC` response, the master will then send a RDB file of its current state to the replica. The replica is expected to load the file into memory, replacing its current state.
9
+
- It acknowledges with a `FULLRESYNC` response (Handled in a previous stage)
10
+
- It sends a snapshot of its current state as an [RDB file](https://rdb.fnordig.de/file_format.html).
11
11
12
-
For the purposes of this challenge, you don't have to actually construct an RDB file. We'll assume that the master's database is always empty,
13
-
and just hardcode an empty RDB file to send to the replica.
12
+
The replica is expected to load the file into memory and replace its current state with the master's data.
14
13
15
-
You can find the hex representation of an empty RDB file[here](https://github.com/codecrafters-io/redis-tester/blob/main/internal/assets/empty_rdb_hex.md).
14
+
For this challenge, you don’t need to build an RDB file yourself. Instead, you can hardcode an empty RDB file, since we’ll assume the master’s database is always empty.
16
15
17
-
The tester will accept any valid RDB file that is empty, you don't need to send the exact file above.
16
+
You can find the hex and base64 representation of an empty RDB file [here](https://github.com/codecrafters-io/redis-tester/blob/main/internal/assets/empty_rdb_hex.md). You need to decode these into binary contents before sending them to the replica.
18
17
19
18
The file is sent using the following format:
20
19
21
20
```
22
21
$<length_of_file>\r\n<binary_contents_of_file>
23
22
```
24
23
25
-
(This is similar to how [Bulk Strings](https://redis.io/topics/protocol#resp-bulk-strings) are encoded, but without the trailing `\r\n`)
24
+
This is similar to how [bulk strings](https://redis.io/topics/protocol#resp-bulk-strings) are encoded, but without the trailing `\r\n`.
26
25
27
26
### Tests
28
27
@@ -32,22 +31,22 @@ The tester will execute your program like this:
32
31
./your_program.sh --port <PORT>
33
32
```
34
33
35
-
It'll then connect to your TCP server as a replica and execute the following commands:
34
+
It will then connect to your TCP server as a replica and execute the following commands:
0 commit comments