Skip to content

Commit 8d5512e

Browse files
committed
Fixed bug in semi-sync that caused rpl.rpl_semi_sync_slave_reply_fail to fail
This was caused by the patch for MDEV-32567 Remove thr_alarm from server codebase
1 parent ae6684d commit 8d5512e

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

sql/net_serv.cc

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,7 @@ static ulong my_real_read(NET *net, size_t *complen,
793793
size_t length;
794794
uint i,retry_count=0;
795795
ulong len=packet_error;
796+
my_bool expect_error_packet __attribute__((unused))= 0;
796797
retry:
797798

798799
uint32 remain= (net->compress ? NET_HEADER_SIZE+COMP_HEADER_SIZE :
@@ -863,7 +864,31 @@ static ulong my_real_read(NET *net, size_t *complen,
863864
#endif
864865
if (net->buff[net->where_b + 3] != (uchar) net->pkt_nr)
865866
{
866-
goto packets_out_of_order;
867+
if (net->pkt_nr_can_be_reset)
868+
{
869+
/*
870+
We are using a protocol like semi-sync where master and slave
871+
sends packets in parallel.
872+
Copy current one as it can be useful for debugging.
873+
*/
874+
net->pkt_nr= net->buff[net->where_b + 3];
875+
}
876+
else
877+
{
878+
#ifndef MYSQL_SERVER
879+
if (net->buff[net->where_b + 3] == (uchar) (net->pkt_nr -1))
880+
{
881+
/*
882+
If the server was killed then the server may have missed the
883+
last sent client packet and the packet numbering may be one off.
884+
*/
885+
DBUG_PRINT("warning", ("Found possible out of order packets"));
886+
expect_error_packet= 1;
887+
}
888+
else
889+
#endif
890+
goto packets_out_of_order;
891+
}
867892
}
868893
net->compress_pkt_nr= ++net->pkt_nr;
869894
#ifdef HAVE_COMPRESS
@@ -906,6 +931,21 @@ static ulong my_real_read(NET *net, size_t *complen,
906931
server_extension= NULL;
907932
}
908933
}
934+
#ifndef MYSQL_SERVER
935+
else if (expect_error_packet)
936+
{
937+
/*
938+
This check is safe both for compressed and not compressed protocol
939+
as for the compressed protocol errors are not compressed anymore.
940+
*/
941+
if (net->buff[net->where_b] != (uchar) 255)
942+
{
943+
/* Restore pkt_nr to original value */
944+
net->pkt_nr--;
945+
goto packets_out_of_order;
946+
}
947+
}
948+
#endif
909949
}
910950

911951
end:

0 commit comments

Comments
 (0)