Skip to content

Commit

Permalink
Fixed bug in semi-sync that caused rpl.rpl_semi_sync_slave_reply_fail…
Browse files Browse the repository at this point in the history
… to fail

This was caused by the patch for
MDEV-32567 Remove thr_alarm from server codebase
  • Loading branch information
montywi committed Feb 22, 2024
1 parent ae6684d commit 8d5512e
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion sql/net_serv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ static ulong my_real_read(NET *net, size_t *complen,
size_t length;
uint i,retry_count=0;
ulong len=packet_error;
my_bool expect_error_packet __attribute__((unused))= 0;
retry:

uint32 remain= (net->compress ? NET_HEADER_SIZE+COMP_HEADER_SIZE :
Expand Down Expand Up @@ -863,7 +864,31 @@ static ulong my_real_read(NET *net, size_t *complen,
#endif
if (net->buff[net->where_b + 3] != (uchar) net->pkt_nr)
{
goto packets_out_of_order;
if (net->pkt_nr_can_be_reset)
{
/*
We are using a protocol like semi-sync where master and slave
sends packets in parallel.
Copy current one as it can be useful for debugging.
*/
net->pkt_nr= net->buff[net->where_b + 3];
}
else
{
#ifndef MYSQL_SERVER
if (net->buff[net->where_b + 3] == (uchar) (net->pkt_nr -1))
{
/*
If the server was killed then the server may have missed the
last sent client packet and the packet numbering may be one off.
*/
DBUG_PRINT("warning", ("Found possible out of order packets"));
expect_error_packet= 1;
}
else
#endif
goto packets_out_of_order;
}
}
net->compress_pkt_nr= ++net->pkt_nr;
#ifdef HAVE_COMPRESS
Expand Down Expand Up @@ -906,6 +931,21 @@ static ulong my_real_read(NET *net, size_t *complen,
server_extension= NULL;
}
}
#ifndef MYSQL_SERVER
else if (expect_error_packet)
{
/*
This check is safe both for compressed and not compressed protocol
as for the compressed protocol errors are not compressed anymore.
*/
if (net->buff[net->where_b] != (uchar) 255)
{
/* Restore pkt_nr to original value */
net->pkt_nr--;
goto packets_out_of_order;
}
}
#endif
}

end:
Expand Down

0 comments on commit 8d5512e

Please sign in to comment.