I’m stuck on Replication-14.
In Replication-14(ACKs with no commands), I am asked to implement a mechanism below:
Just like in the previous stages, your replica should complete the handshake with the master and receive an empty RDB file.
The master will then send REPLCONF GETACK *
to your replica. It’ll expect to receive REPLCONF ACK 0
as a reply.
It looks like as long as if I just let the master send a REPLCONF GETACK *
to the slave after sending the empty RDB file, everything will be fine.
But when I test the code, I find there is something wrong with the Replication-10 part, I debug for a long time and I can not figure hot to deal with it.
Here are my logs:
[replication-10] Running tests for Replication > Stage #10: Empty RDB Transfer
[replication-10] $ ./spawn_redis_server.sh --port 6379
[your_program] 2024-04-10T02:00:49.732532Z INFO redis_starter_rust: Server started on port 6379
[replication-10] client: $ redis-cli PING
[replication-10] client: Sent bytes: "*1\r\n$4\r\nPING\r\n"
[your_program] 2024-04-10T02:00:49.769601Z INFO redis_starter_rust::redis_store::connection: read request: ["PING"]
[replication-10] client: Received bytes: "+PONG\r\n"
[replication-10] client: Received RESP value: "PONG"
[replication-10] Received "PONG"
[replication-10] client: $ redis-cli REPLCONF listening-port 6380
[replication-10] client: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$14\r\nlistening-port\r\n$4\r\n6380\r\n"
[your_program] 2024-04-10T02:00:49.770936Z INFO redis_starter_rust::redis_store::connection: read request: ["REPLCONF", "listening-port", "6380"]
[replication-10] client: Received bytes: "+OK\r\n"
[replication-10] client: Received RESP value: "OK"
[replication-10] Received "OK"
[replication-10] client: $ redis-cli REPLCONF capa psync2
[replication-10] client: Sent bytes: "*3\r\n$8\r\nREPLCONF\r\n$4\r\ncapa\r\n$6\r\npsync2\r\n"
[replication-10] client: Received bytes: "+OK\r\n"
[replication-10] client: Received RESP value: "OK"
[your_program] 2024-04-10T02:00:49.772258Z INFO redis_starter_rust::redis_store::connection: read request: ["REPLCONF", "capa", "psync2"]
[replication-10] Received "OK"
[replication-10] client: $ redis-cli PSYNC ? -1
[replication-10] client: Sent bytes: "*3\r\n$5\r\nPSYNC\r\n$1\r\n?\r\n$2\r\n-1\r\n"
[your_program] 2024-04-10T02:00:49.773610Z INFO redis_starter_rust::redis_store::connection: read request: ["PSYNC", "?", "-1"]
[replication-10] client: Received bytes: "+FULLRESYNC 8371b4fb1155b71f4a04d3e1bc3e18c4a990aeeb 0\r\n"
[replication-10] client: Received RESP value: "FULLRESYNC 8371b4fb1155b71f4a04d3e1bc3e18c4a990aeeb 0"
[replication-10] Received "FULLRESYNC 8371b4fb1155b71f4a04d3e1bc3e18c4a990aeeb 0"
[replication-10] Reading RDB file...
[replication-10] client: Received bytes: "$88\r\nREDIS0011\xfa\tredis-ver\x057.2.0\xfa\nredis-bits\xc0@\xfa\x05ctime\xc2m\b\xbce\xfa\bused-mem°\xc4\x10\x00\xfa\baof-base\xc0\x00\xff\xf0n;\xfe\xc0\xffZ\xa2"
[replication-10] Found extra data: "$88\r\nREDIS0011\xfa\tredis-ver\x057.2.0\xfa\nredis-bits\xc0@\xfa\x05ctime\xc2m\b\xbce\xfa\bused-mem°\xc4\x10\x00\xfa\baof-base\xc0\x00\xff\xf0n;\xfe\xc0\xffZ\xa2*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n"
[replication-10] Test failed
[replication-10] Terminating program
[replication-10] Program terminated successfully
The tester thinks there is extra data, but the data is belong to REPLCONF GETACK *
which is asked to implemented in Replication-14
How can I deal with it?
And here is my repo: