[MDEV-30430] Enabling system versioning on tables without primary key breaks replication Created: 2023-01-18  Updated: 2023-08-15  Resolved: 2023-04-25

Status: Closed
Project: MariaDB Server
Component/s: Replication, Versioned Tables
Affects Version/s: 10.6.10
Fix Version/s: 11.1.1, 10.11.3, 11.0.2, 10.4.29, 10.5.20, 10.6.13, 10.8.8, 10.9.6, 10.10.4

Type: Bug Priority: Critical
Reporter: Maria M Pflaum Assignee: Brandon Nesterenko
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
is duplicated by MDEV-24273 System versioning replication fails w... Closed
Relates
relates to MDEV-21181 Automatic invisible primary key Open
relates to MDEV-24001 Implement hidden PK for RBR of no-uni... Open
relates to MDEV-24273 System versioning replication fails w... Closed

 Description   

MariaDB [(mydata)]> show variables like "binlog_format";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW   |
+---------------+-------+
1 row in set (0.001 sec)
 
MariaDB [mydata]> show variables like 'system%';
+---------------------------------+---------+
| Variable_name                   | Value   |
+---------------------------------+---------+
| system_time_zone                | UTC     |
| system_versioning_alter_history | ERROR   |
| system_versioning_asof          | DEFAULT |
+---------------------------------+---------+
3 rows in set (0.000 sec)
 
MariaDB [mydata]> show variables like 'secure%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| secure_auth      | ON    |
| secure_file_priv | /tmp/ |
| secure_timestamp | NO    |
+------------------+-------+
3 rows in set (0.000 sec)
 
MariaDB [mydata]> show variables like 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit    | ON    |
+---------------+-------+
1 row in set (0.001 sec)
 
MariaDB [mydata]> create table mytest as select * from mysql.innodb_index_stats where 0=9;
Query OK, 0 rows affected (0.015 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
MariaDB [mydata]> alter table mytest add system versioning;
Query OK, 0 rows affected (0.020 sec)              
Records: 0  Duplicates: 0  Warnings: 0
 
MariaDB [mydata]> show create table mytest\G
*************************** 1. row ***************************
       Table: mytest
Create Table: CREATE TABLE `mytest` (
  `database_name` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL,
  `table_name` varchar(199) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL,
  `index_name` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL,
  `last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `stat_name` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL,
  `stat_value` bigint(20) unsigned NOT NULL,
  `sample_size` bigint(20) unsigned DEFAULT NULL,
  `stat_description` varchar(1024) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci WITH SYSTEM VERSIONING
1 row in set (0.000 sec) 
 
MariaDB [mydata]> insert into mytest select * from mysql.innodb_index_stats;
Query OK, 80 rows affected (0.005 sec)
Records: 80  Duplicates: 0  Warnings: 0
 
MariaDB [mydata]> insert into mytest select * from mysql.innodb_index_stats;
Query OK, 80 rows affected (0.005 sec)
Records: 80  Duplicates: 0  Warnings: 0
 
MariaDB [mydata]> insert into mytest select * from mysql.innodb_index_stats;
Query OK, 80 rows affected (0.006 sec)
Records: 80  Duplicates: 0  Warnings: 0
 
MariaDB [mydata]> select count(*) from mytest;
+----------+
| count(*) |
+----------+
|      240 |
+----------+
1 row in set (0.001 sec)
 
MariaDB [mydata]> select count(*) from mytest where table_name='customers';
+----------+
| count(*) |
+----------+
|       21 |
+----------+
1 row in set (0.000 sec)
 
MariaDB [mydata]> delete from mytest where table_name='customers';
Query OK, 21 rows affected (0.004 sec)
 
MariaDB [mydata]> select count(*) from mytest where table_name='customers';
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.000 sec)
 
 
ON REPLICA
====================
MariaDB [mydata]> select count(*) from mytest where table_name='customers';
+----------+
| count(*) |
+----------+
|       14 |
+----------+
1 row in set (0.001 sec)



 Comments   
Comment by Brandon Nesterenko [ 2023-04-13 ]

Hi Andrei!

This is ready for review: PR 2600

Comment by Andrei Elkin [ 2023-04-24 ]

Reviewed with suggestions.

Comment by Brandon Nesterenko [ 2023-04-25 ]

Pushed into 10.4 as 29fb041

Merge conflicts observed in 10.5, 10.9 and 10.11 with resolutions in respective branches 10.5-merge-30430, 10.9-merge-30430, and 10.11-merge-30430

Generated at Thu Feb 08 10:16:11 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.