[MDEV-19561] Cardinality error in InnoDB slave statistics Created: 2019-05-23  Updated: 2019-09-11  Resolved: 2019-09-11

Status: Closed
Project: MariaDB Server
Component/s: Data Manipulation - Insert, Replication, Storage Engine - InnoDB
Affects Version/s: 10.3.14
Fix Version/s: 10.2.24, 10.1.39, 10.3.15, 10.4.5

Type: Bug Priority: Major
Reporter: Juan Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: None
Environment:

CentOS Linux release 7.5.1804 (Core)


Attachments: File 28207_G0_global_variables.out     File 28207_G0_server.cnf     File 28207_Slave_server.cnf     File 28207_slave_global_variables.out    
Issue Links:
Relates
relates to MDEV-17605 Statistics for InnoDB table is wrong ... Closed

 Description   

Default configuration (engine-dependent) statistics do not update correctly on slave for InnoDB.

CREATE TABLE `simple` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `val` int(10) unsigned DEFAULT NULL,
  `blah` varchar(511) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `simple_modified` (`modified`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Having this table in a 3 node MariaDB 10.3.14 Galera cluster, and a slave (configurations attached) with the following (default) stats configuration on all servers:

+--------------------------------------+-------------+
| Variable_name                        | Value       |
+--------------------------------------+-------------+
| innodb_stats_auto_recalc             | ON          |
| innodb_stats_include_delete_marked   | OFF         |
| innodb_stats_method                  | nulls_equal |
| innodb_stats_modified_counter        | 0           |
| innodb_stats_on_metadata             | OFF         |
| innodb_stats_persistent              | ON          |
| innodb_stats_persistent_sample_pages | 20          |
| innodb_stats_sample_pages            | 8           |
| innodb_stats_traditional             | ON          |
| innodb_stats_transient_sample_pages  | 8           |
+--------------------------------------+-------------+

as rows are inserted all statistics update correctly except for non-unique key stats on the slave, which incorrectly show unique key cardinality.

Galera node / master:

MariaDB [test]> show index from simple;
+--------+------------+-----------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table  | Non_unique | Key_name        | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+--------+------------+-----------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| simple |          0 | PRIMARY         |            1 | id          | A         |       14391 |     NULL | NULL   |      | BTREE      |         |               |
| simple |          1 | simple_modified |            1 | modified    | A         |        2055 |     NULL | NULL   |      | BTREE      |         |               |
+--------+------------+-----------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
2 rows in set (0.000 sec)
 
MariaDB [test]> select count(*) from simple;
+----------+
| count(*) |
+----------+
|    14722 |
+----------+
1 row in set (0.005 sec)
 
MariaDB [test]> select count(distinct modified) from simple;
+--------------------------+
| count(distinct modified) |
+--------------------------+
|                      362 |
+--------------------------+
1 row in set (0.001 sec)

(this error is statistical & not relevant)

Slave:

MariaDB [test]> show index from simple;
+--------+------------+-----------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table  | Non_unique | Key_name        | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+--------+------------+-----------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| simple |          0 | PRIMARY         |            1 | id          | A         |       14383 |     NULL | NULL   |      | BTREE      |         |               |
| simple |          1 | simple_modified |            1 | modified    | A         |       14383 |     NULL | NULL   |      | BTREE      |         |               |
+--------+------------+-----------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
2 rows in set (0.000 sec)
 
MariaDB [test]> select count(*) from simple;
+----------+
| count(*) |
+----------+
|    14722 |
+----------+
1 row in set (0.005 sec)
 
MariaDB [test]> select count(distinct modified) from simple;
+--------------------------+
| count(distinct modified) |
+--------------------------+
|                      362 |
+--------------------------+
1 row in set (0.001 sec)



 Comments   
Comment by Geoff Montee (Inactive) [ 2019-07-31 ]

Could this be a duplicate of MDEV-17605? That is apparently fixed in MariaDB 10.3.15 and later.

Comment by Juan [ 2019-09-11 ]

Indeed it is. Thanks GeoffMontee

Comment by Juan [ 2019-09-11 ]

MDEV-17605 fixed this issue.

Generated at Thu Feb 08 08:52:38 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.