Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Optional Invisible Primary Key to History for Replication in MySQL and MariaDB #586

Merged
merged 2 commits into from
Aug 30, 2023

Conversation

sm-shaw
Copy link
Contributor

@sm-shaw sm-shaw commented Aug 22, 2023

Pull Request adds an optional primary key for the history table which is needed for replication.

mysqlhistorypk

option mysql/maria_history_pk is added to the config/CLI.

<schema>
            <mysql_count_ware>1</mysql_count_ware>
            <mysql_num_vu>1</mysql_num_vu>
            <mysql_user>root</mysql_user>
            <mysql_pass>mysql</mysql_pass>
            <mysql_dbase>tpcc</mysql_dbase>
<mysql_storage_engine>innodb</mysql_storage_engine>
            <mysql_partition>false</mysql_partition>
            <mysql_prepared>false</mysql_prepared>
            <mysql_history_pk>false</mysql_history_pk>
        </schema>

Change will check that the InnoDB storage engine is being used and that the MySQL/MariaDB version is at a level that supports inivisible primary keys before adding one. If not it falls back to the default option.

Example change in table with and without.

mysql> show create table history\G
*************************** 1. row ***************************
       Table: history
Create Table: CREATE TABLE `history` (
  `h_c_id` int DEFAULT NULL,
  `h_c_d_id` int DEFAULT NULL,
  `h_c_w_id` int DEFAULT NULL,
  `h_d_id` int DEFAULT NULL,
  `h_w_id` int DEFAULT NULL,
  `h_date` datetime DEFAULT NULL,
  `h_amount` decimal(6,2) DEFAULT NULL,
  `h_data` varchar(24) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL,
  `id` int NOT NULL AUTO_INCREMENT /*!80023 INVISIBLE */,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=30001 DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
*************************** 1. row ***************************
       Table: history
Create Table: CREATE TABLE `history` (
  `h_c_id` int DEFAULT NULL,
  `h_c_d_id` int DEFAULT NULL,
  `h_c_w_id` int DEFAULT NULL,
  `h_d_id` int DEFAULT NULL,
  `h_w_id` int DEFAULT NULL,
  `h_date` datetime DEFAULT NULL,
  `h_amount` decimal(6,2) DEFAULT NULL,
  `h_data` varchar(24) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

When testing on an incompatible version

mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 8.0.20    |
+-----------+
1 row in set (0.00 sec)

Message is reported the minimum supported version but continues anyway without the invisible PK.

Hammerdb Log @ Tue Aug 22 15:18:16 BST 2023
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Vuser 1:Monitor Thread
Vuser 1:CREATING TPCC2 SCHEMA
Vuser 1:Ssl_cipher
Vuser 1:CREATING DATABASE tpcc2
Vuser 1:CREATING TPCC TABLES
Vuser 1:Minimum MySQL version for invisible PK is 8.0.30
Vuser 1:Loading Item

This way it should allow adding the primary key for replication where it is needed, but also provide minimal disruption where it is not.

Same change in MySQL and MariaDB

@abondvt89
Copy link
Contributor

Merging after reviews and approval of the three members of the code maintenance team.

@abondvt89 abondvt89 merged commit 8ea3ab3 into TPC-Council:master Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add PK to be able to bench group replication in MySQL
3 participants