Cardinality=0 for all rows in a TokuDB table
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Percona Server moved to https://jira.percona.com/projects/PS | Status tracked in 5.7 | |||||
5.6 |
Fix Released
|
Critical
|
George Ormond Lorch III | |||
5.7 |
Fix Released
|
Critical
|
George Ormond Lorch III |
Bug Description
Hi,
On a table converted from InnoDB to TokuDB and which was working properly during several days, I suddently hit a strange problem where the cardinality of the table for all the row (even the PK) changed to 0 (with the dramatic impact on all the query plans, the server went down) :
CREATE TABLE `sc_user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`date_creation` timestamp NULL DEFAULT NULL,
`date_validation` timestamp NULL DEFAULT NULL,
`date_
`date_
`date_
`email` varchar(128) NOT NULL DEFAULT '',
`username` varchar(20) DEFAULT '',
`pass` varchar(60) DEFAULT '' COMMENT ' ',
`first_name` varchar(30) DEFAULT NULL,
`last_name` varchar(30) DEFAULT NULL,
`displayed_name` varchar(30) DEFAULT NULL,
`valid_email` tinyint(3) unsigned NOT NULL DEFAULT '0',
`email_
`accept_tos` tinyint(3) unsigned DEFAULT NULL,
`accept_mailing` tinyint(3) unsigned DEFAULT NULL,
`accept_
`gender_id` tinyint(3) unsigned DEFAULT NULL,
`date_of_birth` date DEFAULT NULL,
`country_id` int(10) unsigned DEFAULT NULL,
`zip_code_id` int(10) unsigned DEFAULT NULL,
`zip` varchar(8) DEFAULT NULL,
`state` tinyint(4) NOT NULL DEFAULT '0',
`gen_
`json` text,
`json_avatar` varchar(500) DEFAULT NULL,
`about` text,
`alert_feed` tinyint(3) unsigned NOT NULL DEFAULT '1',
`alert_
`alert_info` tinyint(3) unsigned NOT NULL DEFAULT '1',
`alert_follower` tinyint(3) unsigned NOT NULL DEFAULT '1',
`alert_badge` tinyint(3) unsigned NOT NULL DEFAULT '1',
`alert_
`alert_advice` tinyint(3) NOT NULL DEFAULT '1',
`alert_message` tinyint(3) NOT NULL DEFAULT '1',
`alert_like` tinyint(3) unsigned NOT NULL DEFAULT '1',
`alert_relance` tinyint(3) unsigned NOT NULL DEFAULT '1',
`alert_
`url_www` varchar(200) DEFAULT NULL,
`privacy_profile` tinyint(4) DEFAULT '0',
`privacy_name` tinyint(4) DEFAULT '1',
`privacy_gender` tinyint(4) DEFAULT '1',
`privacy_
`privacy_twitter` tinyint(4) DEFAULT '0',
`privacy_gplus` tinyint(4) DEFAULT '1',
`privacy_age` tinyint(4) DEFAULT '1',
`privacy_avatar` tinyint(4) DEFAULT '1',
`privacy_geo` tinyint(4) DEFAULT '1',
`privacy_about` tinyint(4) DEFAULT '1',
`show_welcome` tinyint(3) unsigned NOT NULL DEFAULT '0',
`show_tv_welcome` tinyint(3) unsigned NOT NULL DEFAULT '1',
`show_
`show_
`show_tv_agenda` tinyint(4) unsigned NOT NULL DEFAULT '1',
`cookie_ref` varchar(32) DEFAULT NULL,
`affinity_ref` tinyint(3) unsigned NOT NULL DEFAULT '0',
`user_
`password_
`date_
`favorite_
`api_id_referrer` int(3) unsigned DEFAULT NULL,
`state_
`state_
`state_
`state_
`date_
`date_delete` timestamp NULL DEFAULT NULL,
`state_admin` int(11) DEFAULT NULL,
`gen_scout_count` int(10) unsigned NOT NULL DEFAULT '0',
`gen_
`gen_
`gen_
`gen_list_count` int(10) NOT NULL DEFAULT '0',
`flag_gen` tinyint(3) unsigned NOT NULL DEFAULT '0',
`subtype_id` int(10) unsigned DEFAULT '15',
`is_merge_
`alert_privilege` tinyint(4) NOT NULL DEFAULT '0',
`alert_agenda` tinyint(4) NOT NULL DEFAULT '1',
`alert_
`alert_contest` tinyint(4) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_user__email` (`email`) USING BTREE,
KEY `idx_username` (`username`),
KEY `idx_flag_gen` (`flag_gen`),
KEY `state` (`state`
KEY `password_
KEY `date_last_session` (`date_
KEY `idx_email_
) ENGINE=TokuDB AUTO_INCREMENT=
SHOW INDEX FROM sc_user;
+------
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+------
| sc_user | 0 | PRIMARY | 1 | id | A | 0 | NULL | NULL | | BTREE | | |
| sc_user | 0 | idx_user__email | 1 | email | A | 0 | NULL | NULL | | BTREE | | |
| sc_user | 1 | idx_username | 1 | username | A | 0 | NULL | NULL | YES | BTREE | | |
| sc_user | 1 | idx_flag_gen | 1 | flag_gen | A | 0 | NULL | NULL | | BTREE | | |
| sc_user | 1 | state | 1 | state | A | 0 | NULL | NULL | | BTREE | | |
| sc_user | 1 | state | 2 | gen_collection_
| sc_user | 1 | password_reset_code | 1 | password_reset_code | A | 0 | NULL | NULL | YES | BTREE | | |
| sc_user | 1 | password_reset_code | 2 | state | A | 0 | NULL | NULL | | BTREE | | |
| sc_user | 1 | password_reset_code | 3 | date_password_reset | A | 0 | NULL | NULL | YES | BTREE | | |
| sc_user | 1 | date_last_session | 1 | date_last_session | A | 0 | NULL | NULL | YES | BTREE | | |
| sc_user | 1 | idx_email_
+------
11 rows in set (0.00 sec)
MariaDB [sc_2]> ANALYZE TABLE sc_user;
+------
| Table | Op | Msg_type | Msg_text |
+------
| sc_2.sc_user | analyze | status | OK |
+------
1 row in set (9.64 sec)
MariaDB [sc_2]> SHOW INDEX FROM sc_user;
+------
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+------
| sc_user | 0 | PRIMARY | 1 | id | A | 0 | NULL | NULL | | BTREE | | |
| sc_user | 0 | idx_user__email | 1 | email | A | 0 | NULL | NULL | | BTREE | | |
| sc_user | 1 | idx_username | 1 | username | A | 0 | NULL | NULL | YES | BTREE | | |
| sc_user | 1 | idx_flag_gen | 1 | flag_gen | A | 0 | NULL | NULL | | BTREE | | |
| sc_user | 1 | state | 1 | state | A | 0 | NULL | NULL | | BTREE | | |
| sc_user | 1 | state | 2 | gen_collection_
| sc_user | 1 | password_reset_code | 1 | password_reset_code | A | 0 | NULL | NULL | YES | BTREE | | |
| sc_user | 1 | password_reset_code | 2 | state | A | 0 | NULL | NULL | | BTREE | | |
| sc_user | 1 | password_reset_code | 3 | date_password_reset | A | 0 | NULL | NULL | YES | BTREE | | |
| sc_user | 1 | date_last_session | 1 | date_last_session | A | 0 | NULL | NULL | YES | BTREE | | |
| sc_user | 1 | idx_email_
+------
11 rows in set (0.00 sec)
After switching it back to InnoDB, it fixes the issue :
ALTER TABLE sc_user ENGINE=InnoDB;
Query OK, 622834 rows affected (1 min 4.93 sec)
Records: 622834 Duplicates: 0 Warnings: 0
MariaDB [sc_2]> show index FROM sc_user;
+------
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+------
| sc_user | 0 | PRIMARY | 1 | id | A | 542895 | NULL | NULL | | BTREE | | |
| sc_user | 0 | idx_user__email | 1 | email | A | 542895 | NULL | NULL | | BTREE | | |
| sc_user | 1 | idx_username | 1 | username | A | 542895 | NULL | NULL | YES | BTREE | | |
| sc_user | 1 | idx_flag_gen | 1 | flag_gen | A | 2 | NULL | NULL | | BTREE | | |
| sc_user | 1 | state | 1 | state | A | 4 | NULL | NULL | | BTREE | | |
| sc_user | 1 | state | 2 | gen_collection_
| sc_user | 1 | password_reset_code | 1 | password_reset_code | A | 8899 | NULL | NULL | YES | BTREE | | |
| sc_user | 1 | password_reset_code | 2 | state | A | 8899 | NULL | NULL | | BTREE | | |
| sc_user | 1 | password_reset_code | 3 | date_password_reset | A | 9048 | NULL | NULL | YES | BTREE | | |
| sc_user | 1 | date_last_session | 1 | date_last_session | A | 542895 | NULL | NULL | YES | BTREE | | |
| sc_user | 1 | idx_email_
+------
11 rows in set (0.00 sec)
Any idea of what could have happened here ? (tokudb_
I'm using MariaDB 10.1.16 with TokuDB 5.6.30-76.3.
Unfortunately I didn't keep the original corrupted TokuDB table.
The server is a Master, so no replication or RFR involved here.
Thanks and regards,
Jocelyn Fournier
description: | updated |
Tokudb specific variables :
tokudb_ pk_insert_ mode=1 cache_size= 64G lock_timeout= 120000 row_format= "tokudb_ small"
tokudb_
tokudb_
tokudb_