[MDEV-26833] Missed statement rollback in case transaction drops or create temporary table Created: 2021-10-14  Updated: 2022-03-08  Resolved: 2021-10-28

Status: Closed
Project: MariaDB Server
Component/s: Replication
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 10.2.41, 10.3.32, 10.4.22, 10.5.13, 10.6.5, 10.7.1

Type: Bug Priority: Blocker
Reporter: Valerii Kravchuk Assignee: Andrei Elkin
Resolution: Fixed Votes: 1
Labels: temporary-table-replication


 Description   

Consider the following test case (based on real life issue and simplified by Elkin):

CREATE TABLE `ti_pk` (
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL,
PRIMARY KEY (`a`)
) ENGINE=InnoDB;
 
# for the MIXED binlog format version of the bug (and it exists with ROW format as well) the direct logging needs to be non-default
set @@session.binlog_direct_non_transactional_updates=1;
set @@binlog_format=mixed;
# Bug
begin;
DROP TEMPORARY TABLE IF EXISTS `tmp_0`;
CREATE TEMPORARY TABLE tmp_0 (a int primary key);
insert into tmp_0 set a=1;
INSERT into ti_pk select a,1 from tmp_0;
INSERT into ti_pk set a=3;
# --error
INSERT into ti_pk values (2,1),(3,2) /* hit the dup key by the 2nd row */;
 
commit;
show binlog events; /* a=2 ROW event is there */

You should get error upon INSERT, but the event that causes the problem is in the binary log. Now check this output on master vs slave:

select count(*) = 0 from ti_pk where a = 2;

Slave is already out of sync and on every next event it may easily break/hit error that does not happen on master.



 Comments   
Comment by Brandon Nesterenko [ 2021-10-25 ]

Added a few comments to 7c318a6. Looks good otherwise to me!

Comment by Brandon Nesterenko [ 2021-10-28 ]

d155769 approved to push

Comment by Andrei Elkin [ 2021-10-28 ]

To resolve conflicts at merging
10.2->10.3 use bb-10.3-MDEV-26833-andrei,
10.4 > 10.5 use bb-10.5MDEV-26833-andrei.

Comment by Valerii Kravchuk [ 2021-11-10 ]

Why don't we see this bug mentioned in the release notes and even changelogs for the versions where it is supposed to be fixed. It was a blocker!

Comment by Alice Sherepa [ 2021-11-10 ]

valerii it is in changelogs in 10.2.41 https://mariadb.com/kb/en/mariadb-10241-changelog/ - and in 10.3+ it has "Includes all fixes from MariaDB 10.2.41"

Generated at Thu Feb 08 09:48:18 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.