Bug #101339 The binlog file was incorrectly purged
Submitted: 27 Oct 2020 12:59 Modified: 28 Oct 2020 8:14
Reporter: KE TWELVE Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.7.29,8.018, 8.0.22, 5.7.32 OS:Linux
Assigned to: CPU Architecture:x86

[27 Oct 2020 12:59] KE TWELVE
Description:
In the master-slave replication mode,  if the binlog used by the sender process on the master behind the current latest binlog, the binlog requested by the sender process may be deleted when purge to the latest binlog is executed, resulting in an abnormal replication

How to repeat:
--source include/have_debug_sync.inc
--source include/have_binlog_format_statement.inc
--source include/master-slave.inc

connect(master2,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect(master3,127.0.0.1,root,,test,$MASTER_MYPORT,);
--connection master
SET @save_debug=@@global.debug;
SET GLOBAL DEBUG='+d,before_dump_thread_acquires_current_mutex';
--let $iter=1
while ($iter)
{
  FLUSH LOGS;
  --connection slave
  --source include/stop_slave.inc
  --source include/start_slave.inc
  --query_vertical show slave status
  # Thread 1
  --connection master
  flush binary logs;
  --echo "Wait_for dump_thread_signal"
  SET DEBUG_SYNC='now WAIT_FOR dump_thread_signal';

  # Thread 2
  --connection master2
  SET DEBUG_SYNC='purge_logs_after_lock_index_before_thread_count SIGNAL parked2 WAIT_FOR go_parked2';
  --send PURGE BINARY LOGS BEFORE '2038-01-19'

  --connection master
  echo "Wait_for parked2";
  SET DEBUG_SYNC='now WAIT_FOR parked2';

  echo "now signal go to all 2 waiting threads";
  SET DEBUG_SYNC='now SIGNAL go_dump_thread';
  SET DEBUG_SYNC='now SIGNAL go_parked2';

  --connection master2
  --reap

  --dec $iter
}

--echo "Cleanup"
--disconnect master2
--disconnect master3

--connection master
SET DEBUG_SYNC='RESET';
SET GLOBAL DEBUG=@save_debug;
source include/rpl_end.inc;
[28 Oct 2020 8:14] MySQL Verification Team
Hello KE TWELVE,

Thank you for the report and feedback.

regards,
Umesh
[28 Oct 2020 8:15] MySQL Verification Team
MySQL Server 5.7.32, 8.0.22 test results

Attachment: 101339_5.7.32_8.0.22.results.txt (text/plain), 59.92 KiB.