A semi-sync master can sometimes error when it is issued SHUTDOWN WAIT FOR ALL SLAVES as a semi-sync slave is stopping its IO thread. If the slave's repl_semisync_slave::slave_stop() executes as or after the master stops listening for connections, the slave's semi-sync connection can stay active, and follow up with a mysql_close() on that connection, thereby issuing COM_QUIT on an active semi-sync connection. The ACK receiver thread sees this and fails with "[ERROR] Read semi-sync reply magic number error". See the attached image for a visualization of the issue.