Bug #109530 Fail to write drop temp table binlog event in semi sync mode
Submitted: 4 Jan 2023 9:42 Modified: 5 Jan 2023 10:58
Reporter: ggwdwsbs W Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:8.0.30, 8.0.31 OS:Any
Assigned to: CPU Architecture:Any

[4 Jan 2023 9:42] ggwdwsbs W
Description:
When binlog is running with stmt format and semi sync plugin is instlled, the binlog query event "DROP /*!40005 TEMPORARY */ TABLE IF EXISTS" will miss after close a connection. 

This bug is included by WL#14585 in 8.0.29,an unexpected error returned during run hook Trans_delegate::before_commit. 

This bug may case replication interrupt and data inconsistent.

How to repeat:
--source include/have_binlog_format_statement.inc

install plugin rpl_semi_sync_master soname 'semisync_master.so';
install plugin rpl_semi_sync_slave soname 'semisync_slave.so';

RESET MASTER;

CREATE TABLE t1(a INT) ENGINE=InnoDB;

--source include/count_sessions.inc

--connect(con1,localhost,root)

# A DROP should be logged for the following tables because CREATE TABLE
# is logged
CREATE TEMPORARY TABLE tmp1 ENGINE=InnoDB SELECT * FROM t1;
CREATE TEMPORARY TABLE tmp5 (a INT) ENGINE=InnoDB;
CREATE TEMPORARY TABLE tmp7 LIKE t1;

--disconnect con1
--connection default
--source include/wait_until_count_sessions.inc

--source include/show_binlog_events.inc

# Expect result of show binlog events
 binlog.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tmp1 ENGINE=InnoDB SELECT * FROM t1
 binlog.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tmp5 (a INT) ENGINE=InnoDB
 binlog.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tmp7 LIKE t1
-binlog.000001	#	Query	#	#	use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `tmp7`,`tmp5`,`tmp1`

# The real execution result of show binlog events
 binlog.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tmp1 ENGINE=InnoDB SELECT * FROM t1
 binlog.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tmp5 (a INT) ENGINE=InnoDB
 binlog.000001	#	Query	#	#	use `test`; CREATE TEMPORARY TABLE tmp7 LIKE t1

Suggested fix:
Add more condition for conditional statement Trans_delegate::before_commit,to avoid affect DROP TEMPORARY TABLE query event.
[5 Jan 2023 10:58] MySQL Verification Team
Hello!

Thank you for the report and feedback.

regards,
Umesh