I’m stuck on Stage#yd3 .
After reading FULLRESYNC
command, when replica starts to read RDB file, it gets EOF but on some occasions it reads RDB file but gets EOF when reading command REPLCONF GETACK *
thus loop breaks and gives this error
Here are my logs:
[tester::#XV6] Received: "" (no content received)
[tester::#XV6] ^ error
[tester::#XV6] Error: Expected start of a new RESP2 value (either +, -, :, $ or *)
[tester::#XV6] Test failed
And here’s a snippet of my code:
func (kv *KVStore) SendHandshake(master *net.Conn) {
rdr := bufio.NewReader(*master)
buff := []string{"PING"}
res := []byte{}
fmt.Println("sent ping")
(*master).Write([]byte(resp.ToArray(buff)))
res, _ = rdr.ReadBytes('\n')
fmt.Println(string(res))
fmt.Println("sent replconf1")
buff = []string{"REPLCONF", "listening-port", kv.Info.Port}
(*master).Write(resp.ToArray(buff))
res, _ = rdr.ReadBytes('\n')
fmt.Println(string(res))
fmt.Println("sent replconf2")
buff = []string{"REPLCONF", "capa", "psync2"}
(*master).Write(resp.ToArray(buff))
res, _ = rdr.ReadBytes('\n')
fmt.Println(string(res))
fmt.Println("sent psync")
(*master).Write(resp.ToArray([]string{"PSYNC", "?", "-1"}))
res, _ = rdr.ReadBytes('\n')
fmt.Println(string(res))
}
Here is complete code: