Bug #105270 Mysql switch off the semi replication automatically
Submitted: 20 Oct 2021 2:41 Modified: 22 Oct 2021 7:08
Reporter: wiser zhang Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Cluster: Replication Severity:S1 (Critical)
Version:5.7.21-20 OS:Any
Assigned to: MySQL Verification Team CPU Architecture:Any

[20 Oct 2021 2:41] wiser zhang
Description:
Recently we encountered a case that,when the requests wait for slave ack meanwhile shutdown the linux system Mysql will switch off the semi replication automatically

How to repeat:
cluster: master with 2 slaves 

rpl_semi_sync_master_wait_for_slave_count=1

1) begin  send request to Mysql
2) stop 2 slaves
3) reboot/shutdown master os system

then will recv log like :
[ERROR] Semi-sync master failed on net_flush() before waiting for slave reply
[ERROR] Semi-sync master failed on net_flush() before waiting for slave reply
[Warning] SEMISYNC: Forced shutdown. Some updates might not be replicated.

seems that Mysql allows the semi repl automatically shutdown ,but in some cases we hope that never happended

Suggested fix:
we have some questions 
1) we have found that this 'feature' still in the newest source code in mysql, does it means MySQL offically allows the semi repl shutdown automatically ? 
2) in some cases ,we never wants the semi repl shutdown especially in financal databases,is there any suggests for us to turn off this feature ?
[20 Oct 2021 2:45] wiser zhang
paste the source code here
  void ReplSemiSyncMaster::remove_slave()
   {
     lock();
     rpl_semi_sync_master_clients--;
   
     /* Only switch off if semi-sync is enabled and is on */
     if (getMasterEnabled() && is_on())
     {
   
       /*
         If user has chosen not to wait if no enough semi-sync slave available
         and after a slave exists, turn off semi-semi master immediately if active
         slaves are less then required slave numbers.
       */
       if ((rpl_semi_sync_master_clients ==
            rpl_semi_sync_master_wait_for_slave_count - 1) &&
           (!rpl_semi_sync_master_wait_no_slave || abort_loop))
       {
         if (abort_loop)
         {
           if (commit_file_name_inited_ && reply_file_name_inited_)
           {
             int cmp = ActiveTranx::compare(reply_file_name_, reply_file_pos_ ,
                                            commit_file_name_, commit_file_pos_);
             if (cmp < 0)
               sql_print_warning("SEMISYNC: Forced shutdown. Some updates might "
                                 "not be replicated.");
           }
         }
         switch_off();
       }
     }
     unlock();
   }
[22 Oct 2021 7:08] MySQL Verification Team
We're sorry, but the bug system is not the appropriate forum for asking help on using MySQL products. Your problem is not the result of a bug.

For details on getting support for MySQL products see http://www.mysql.com/support/
You can also check our forums (free) at http://forums.mysql.com/

Thank you for your interest in MySQL.