MariaDB client connection hangs when semi-sync is enabled but not connected

Description

When using semi-sync replication with the master configured to block writes until the number of semi-sync slaves is > 1 with a long (or infinite) timeout there seems to be a bug when inserting data when a slave is disconnected.

Specifically if a write query is executed it's successfully blocked however once the slave is connected the client connection isn't unblocked (and never receives any data indicating success or failure of the query). Things however get more strange as the query is actually successfully executed on connection of the slave and the data is properly replicated.
This results in the client connection hanging forever also, which isn't a great failure condition as it's impossible to determine if the write was successful or not.

You can reproduce this by doing the following.

Start a master server.

Enable semi-sync replication with the following:

CREATE USER 'flynn'@'%' IDENTIFIED BY 'flynn'
GRANT ALL ON . TO 'flynn'@'%' WITH GRANT OPTION
FLUSH PRIVILEGES
INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so'
SET GLOBAL rpl_semi_sync_master_wait_point = "AFTER_SYNC"
SET GLOBAL rpl_semi_sync_master_timeout = 18446744073709551615
SET GLOBAL rpl_semi_sync_master_enabled = 1
SET GLOBAL rpl_semi_sync_master_wait_no_slave = 1

Execute a query that would write data. The bug is reproducible with DDL and DML, CREATE DATABASE is probably the easiest option. Note that your client will now be hung. This goes for any connector and the mysql command line client.

Create a slave from a backup of the master, populating the GTID of the master (or at the time of backup if the master has progressed):

INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so'
SET GLOBAL rpl_semi_sync_slave_enabled = 1
SET GLOBAL gtid_slave_pos = MASTER_GTID'
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=13306, MASTER_USER='flynn', MASTER_PASSWORD='flynn', MASTER_CONNECT_RETRY=10, MASTER_USE_GTID=current_pos
STOP SLAVE IO_THREAD
START SLAVE IO_THREAD
START SLAVE

The master should now be writable again but your initial write should still be hung.
However if you connect another session you should see that your statement has actually executed.

Let me know if any additional information can be supplied, happy to do the leg work running debug builds etc.

Environment

Ubuntu 14.04, official MariaDB packages.

Status

Assignee

Kristian Nielsen

Reporter

Joseph Glanville

Labels

None

External issue ID

None

External issue ID

None

Components

Fix versions

Affects versions

10.1.11

Priority

Major