Bug #80395 semi-sync: incorrect crash recovery handling
Submitted: 16 Feb 2016 12:54 Modified: 6 Nov 2018 16:36
Reporter: Matthew Lord Email Updates:
Status: Open Impact on me:
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:5.7.11 OS:Any
Assigned to: David Moss CPU Architecture:Any

[16 Feb 2016 12:54] Matthew Lord
When mysqld is killed while an open semi-sync replication transaction is waiting for the master timeout, that prepared *but uncommitted* transaction is NOT property rolled back when the master performs its subsequent automated crash recovery.

This was verified on OL 7.2 x86_64, using MySQL 5.7.11-community. 

How to repeat:
mkdir /tmp/bug
chown mysql:mysql /tmp/bug

mysqld --no-defaults --initialize-insecure --datadir=/tmp/bug --user=mysql  

mysqld --no-defaults --user=mysql --port=3399 --socket=/tmp/bug/mysql.sock --datadir=/tmp/bug --log-bin --server-id=1 &

mysql --no-defaults --socket=/tmp/bug/mysql.sock

create database bug;
use bug;
create table ssbug (id int not null primary key, name varchar(100));

INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';
SET GLOBAL rpl_semi_sync_master_enabled=ON;
show global variables like "rpl%";

# open a second shell, get the pid of this running mysqld process 
# prepare kill -9 <pid> to execute after the following INSERT statement 

insert into ssbug (id, name) values (1, "matt");

# while this is waiting for the master timeout
# execute the kill -9 <pid> 

mysqld --no-defaults --user=mysql --port=3399 --socket=/tmp/bug/mysql.sock --datadir=/tmp/bug --log-bin --server-id=1 &

mysql --no-defaults --socket=/tmp/bug/mysql.sock

select * from bug.ssbug;

# examine the MySQL error log 

Suggested fix:
This uncommitted transaction needs to be rolled back during crash recovery.
[20 Sep 2016 3:41] anup bharti
This cannot be a bug .As soon as time out occurs Semi sync will switch to async replication mode and hence will not care about slave ack or slave running and will simply go and Commit the transaction if not committed during the time will commit while Recovery.