[MDEV-25478] Auto-create: Auto partitioning is unsafe for row-based replication Created: 2021-04-21  Updated: 2021-12-29  Resolved: 2021-04-23

Status: Closed
Project: MariaDB Server
Component/s: Partitioning, Replication, Versioned Tables
Affects Version/s: N/A
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Aleksey Midenkov
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-25477 Auto-create breaks replication when t... Closed
Relates
relates to MDEV-17554 Auto-create history partitions for sy... Closed

 Description   

This is a sibling of MDEV-25477. The difference is that MDEV-25477 concerns any replication format, but only transactional engines, while this one concerns any engines, but only RBR format, which means binlog_format=row or binlog_format=mixed when replication automatically switched to RBR, which can happen on a variety of reasons.

Partitioning auto-creation cannot be safely used in a replication topology if there is a chance that the binary log will be written in a row format.

The reason is that when DML ends without affecting any rows, a new partition still can be created, but no row events will be written in the binary log. Thus, the master will have the new partition, but the slave will not. This discrepancy will almost inevitably cause a replication abort some time later.

--source include/have_partition.inc
--source include/have_binlog_format_row.inc
--source include/master-slave.inc
 
create table t (a int) with system versioning
  partition by system_time interval 1 hour auto;
 
insert into t values (1),(2);
set @@timestamp= @@timestamp+3601;
 
update t set a = 3 limit 0;
 
show create table t;
 
--sync_slave_with_master
 
show create table t;
 
--connection master
alter table t drop partition p0;
 
--sync_slave_with_master

bb-10.6-midenok-MDEV-17554 edbc73ac48

show create table t;
Table	Create Table
t	CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
 PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR STARTS TIMESTAMP'2021-04-21 23:00:00' AUTO
PARTITIONS 3
connection slave;
show create table t;
Table	Create Table
t	CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING
 PARTITION BY SYSTEM_TIME INTERVAL 1 HOUR STARTS TIMESTAMP'2021-04-21 23:00:00' AUTO
PARTITIONS 2

Last_Errno	4128
Last_Error	Error 'Wrong partitions for `t`: must have at least one HISTORY and exactly one last CURRENT' on query. Default database: 'test'. Query: 'alter table t drop partition p0'


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