Interesting. I am also seeing the same issue I think. I wish someone takes a look at this. I was asserting if I get proper ‘REPL ACK ’ back but, my server doesn’t receive anything from slave, so test doesn’t pass.
I’m stuck on Replication 18 WAIT with multiple commands.
I tried to print message receive from slave, but i receive nothing in this stage. I got correct message in my environment.
Here are my logs:
[your_program] server receive *3
[your_program] $4
[your_program] WAIT
[your_program] $1
[your_program] 3
[your_program] $3
[your_program] 500
[your_program]
[your_program] Server offset: 0
[your_program] Master try to get offset of 12
[your_program] Master try to get offset of 11
[your_program] Master try to get offset of 10
[your_program] Master try to get offset of 9
[your_program] Master try to get offset of 8
[your_program] Master try to get offset of 7
[your_program] Master try to get offset of 6
[your_program] Master try to get offset of 5
[replication-17] client: Received bytes: ":0\r\n"
[replication-17] client: Received RESP value: 0
[replication-17] Expected 8, got 0
[replication-17] Test failed
[replication-17] Terminating program
[replication-17] Program terminated successfully
And here’s a snippet of my code:
while (true)
{
bool reply = (server->ismaster) || (clientfd != server->masterfd);
int cur_location = 0;
std::string replyMsg(server->clients[clientfd].buffer.begin(), server->clients[clientfd].buffer.end());
ReplyParser parser(replyMsg);
cur_location = 0;
int msg_len = parser.parseReply(cur_location);
if (msg_len <= 0)// uncomplete message
{
return -1;
}
std::cout << "server receive " << replyMsg<< std::endl;
....
case WAIT:{
auto now = std::chrono::steady_clock().now();
std::chrono::milliseconds duration(std::stoi(parser.tokens[1]));
auto expire_timepoint = now + duration;
std::thread t(waitprocess, server, clientfd, std::stoi(parser.tokens[0]), expire_timepoint);
t.detach();
}
....
waitprocess(){
....
for (auto it = server->needReplica_fd.begin(); it != server->needReplica_fd.end();)
{
std::cout<<"Master try to get offset of "<<*it<<std::endl;
if(send(*it, "*3\r\n$8\r\nREPLCONF\r\n$6\r\nGETACK\r\n$1\r\n*\r\n", 37, 0)<0)std::cout<<"Send GETACK ERROR"<<std::endl;
it = server->needReplica_fd.erase(it);
}
....
}
Yep, I think we just need proper instructions here - it is expected that some slaves will not respond to ACKs, that’s what we explicitly test in this stage.
Note: I’ve updated the title of this post to include the stage ID (#NA2). You can learn about the stages rename here: Upcoming change: Stages overhaul.