Skip to content

Commit

Permalink
Initialize replication ID and offset for Redis master
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpaulk committed Jan 31, 2024
1 parent 69dc97f commit ca94fc3
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions course-definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -683,21 +683,18 @@ stages:
### The replication ID and offset
Every Redis master has a replication ID: it is a large pseudo random string, used as an identifier for a dataset.
Every Redis master has a replication ID: it is a large pseudo random string. This is set when the master is booted. Every time
a master instance restarts from scratch, its replication ID is reset.
Each master also takes an offset that increments for every byte of replication stream that it is produced to be sent to replicas,
to update the state of the replicas with the new changes modifying the dataset.
The replication offset is incremented even if no replica is actually connected. It's just a counter of the amount of bytes that
would've been sent to replicas if they were connected.
`Replication ID, offset`
Identifies an exact version of the dataset of a master.
to update the state of the replicas with the new changes modifying the dataset. We won't get into the details of how this offset
is updated in this challenge. Just know that the value starts from `0` when a master is booted and no replicas have connected yet.
In this stage, you'll initialize a replication ID and offset for your master:
- The ID can be any pseudo random alphanumeric string of 40 characters
- The ID can be any pseudo random alphanumeric string of 40 characters.
- For the purposes of this challenge, you don't need to actually generate a random string, you can hardcode it instead.
- As an example, you can hardcode `8371b4fb1155b71f4a04d3e1bc3e18c4a990aeeb` as the replication ID.
- The offset is to be 0.
These two values should be returned as part of the INFO command output, under the `master_replid` and `master_repl_offset` keys respectively.
Expand All @@ -716,10 +713,20 @@ stages:
$ redis-cli info replication
```
Your program should respond with a [Bulk string](https://redis.io/docs/reference/protocol-spec/#bulk-strings) where each line
is a key value pair separated by `:`. The tester will look for the following keys:
- `master_replid`, which should be a 40 character alphanumeric string
- `master_repl_offset`, which should be `0`
### Notes
- Your code should still pass the previous stage tests, so the `role` key still needs to be returned
- We won't test this explicitly, but replicas will return `master_replid` and `master_repl_offset` too. This is because
The response to `info replication` should be a Bulk string, where each line is a key value pair, seperated by ":".
We will look for the `master_replid` key expecting a pseudorandom string and `master_repl_offset` key, expecting a value of `0`.
You can ignore the `# Replication` heading.
marketing_md: |
In this stage, you'll add support for reading a key from an RDB file that contains a single key-value pair. You'll do this by implementing the `KEYS *` command.
Expand Down

0 comments on commit ca94fc3

Please sign in to comment.