Bug #103595 using zstd and zlib compression algorithm,master dump thread always be killed
Submitted: 6 May 2021 2:17 Modified: 9 Jun 2021 9:32
Reporter: sheng wei (OCA) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:8.0.18,8.0.24 OS:Linux
Assigned to: CPU Architecture:Any

[6 May 2021 2:17] sheng wei
Description:
Enable semi synchronous replication,Using the change master command to change the compression algorithm between master and slave,Using TPCC tool to do transaction pressure test on master.The error occurred in the observation log file:Got an error reading communication packets.The dump thread is constantly being kill and re created.

How to repeat:
1. Installing the semi synchronous plug-in
2. Setting parameters rpl_semi_sync_master_enabled and rpl_semi_sync_slave_enabled =ON
3. change master to master_compression_algorithms='zlib' or 'zstd'
4. start slave and use TPCC tool

master error log:
  [MY-000000] [Server] failed to read or write packet, errno: 32, errmsg: Broken pipe
  [MY-011171] [Repl] Stop semi-sync binlog_dump to slave (server_id: ***)
  [MY-010014] [Repl] While initializing dump thread for slave with UUID <***>, found a zombie dump thread with the same UUID. Master is killing the zombie dump thread(337).
  [MY-010462] [Repl] Start binlog_dump to master_thread_id(338) slave_server(***), pos(, 4)

slave error log:
  [MY-010557] [Repl] Error reading packet from server for channel '': Lost connection to MySQL server during query (server_errno=2013)
  [MY-011027] [Repl] Failed registering on master, reconnecting to try again, log 'mysql-bin.***' at position ***.  for channel ''.

Suggested fix:
file sql/rpl_semisync_master.cc 
ReplSemiSyncMaster::readSlaveReply(NET *net, const char *event_buf)
{
  ***
  net_clear(net, 0);
  net->pkt_nr++;
+++if(net->compress) net->compress_pkt_nr= net->pkt_nr;
  result = 0;
  ***
}

reason:
  Using the compression algorithm,net_clear function uses net->compress_pkt_nr  set to 0,the net->pkt_nr value needs to be assigned to net->compress_pkt_nr
[7 May 2021 12:21] MySQL Verification Team
Thank you very much for your patch contribution, we appreciate it!

In order for us to continue the process of reviewing your contribution to MySQL, please send us a signed copy of the Oracle Contributor Agreement (OCA) as outlined in http://www.oracle.com/technetwork/community/oca-486395.html

Signing an OCA needs to be done only once and it's valid for all other Oracle governed Open Source projects as well.

Getting a signed/approved OCA on file will help us facilitate your contribution - this one, and others in the future.  

Please let me know, if you have any questions.

Thank you for your interest in MySQL.
[9 Jun 2021 9:32] NEHA KUMARI
This bug is a duplicate of BUG#32759421: semi sync connection is often
dropped when using compressed protocol
which was pushed in 8.0.26.