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
**🚧 We're still working on instructions for this stage**. You can find notes on how the tester works below.
1
+
In this stage, you’ll begin implementing support for the `WAIT` command on the master.
2
2
3
-
<!--
4
-
In the next 3 stages, you will implement the WAIT command on your master.
5
-
The WAIT command is used to find out how many replicas a write command was propagated to, with the replica ACKing it back. This way we can know how durable the write was. As we haven't implemented periodic ACKs from the replica, in this stage, for WAIT, the master has to send a GETACK to the replica, if the replica replies back with the proper offset, before the WAIT expires, the master can count that replica's write to be a success.
3
+
### The `WAIT` command
6
4
7
-
In this stage you will implement WAIT, when exactly 0 replicas are connected to Master. The Master can just return 0 asap. This way we will gently dive into the implementation.
8
-
-->
5
+
The `WAIT` command is used to check how many replicas have acknowledged a write command. This allows a client to measure the durability of a write command before considering it successful.
6
+
7
+
The command format is:
8
+
9
+
```bash
10
+
WAIT <numreplicas><timeout>
11
+
```
12
+
13
+
Here's what each argument means:
14
+
15
+
-`<numreplicas>`: The minimum number of replicas that must acknowledge the write command.
16
+
-`<timeout>`: The maximum time (in milliseconds) the client is willing to wait.
17
+
18
+
For example:
19
+
20
+
```bash
21
+
$ redis-cli WAIT 3 5000
22
+
(integer) 2
23
+
```
24
+
25
+
Here, the client is asking the master to wait for `3` replicas (with a maximum timeout of 5000 ms). After the timeout passes, the master has only `2` replicas connected, so it immediately replies with `2` as a [RESP integer](https://redis.io/docs/latest/develop/reference/protocol-spec/#integers).
26
+
27
+
For now, we’ll handle the simplest case: when the client needs `0` replicas and the master also has no replicas connected. In this case, `WAIT` should immediately return `0`.
28
+
29
+
We'll get to tracking the number of replicas and responding accordingly in later stages.
9
30
10
31
### Tests
11
32
@@ -15,15 +36,10 @@ The tester will execute your program like this:
15
36
./your_program.sh
16
37
```
17
38
18
-
A redis client will then connect to your master and send`WAIT 0 60000`:
39
+
It will then connect to your master and send:
19
40
20
41
```bash
21
42
$ redis-cli WAIT 0 60000
22
43
```
23
44
24
-
It'll expect to receive `0` back immediately, since no replicas are connected.
25
-
26
-
### Notes
27
-
28
-
- You can hardcode `0` as the response for the WAIT command in this stage. We'll get to tracking the number of replicas and responding
29
-
accordingly in the next stages.
45
+
The tester will expect to receive `0` immediately (as a RESP integer), since no replicas are connected.
0 commit comments