codership / galera

Synchronous multi-master replication library
GNU General Public License v2.0
447 stars 177 forks source link

Index cardinality not rebuilt #616

Open MichaelOC-AU opened 2 years ago

MichaelOC-AU commented 2 years ago

OS: Ubuntu 18.04 MariaDB-server-10.3.34 (1:10.3.34+maria~bionic) Galera 3 v25.3.35-bionic

3 nodes running in Galera cluster and run a ALTER TABLE to change the datatype of a field on DB1

After the ALTER TABLE query has been run and finished withtout errors on DB1 + DB2 + DB3, the index cardinality has been reset to 0 on the whole table on DB1 and the index never gets rebuild. This makes all following queries on DB1 run without index. On DB2 + DB3 the index cardinality has been rebuilt after a short while (5-30 seconds), but the index on DB1 never gets rebuilt.

If I run ANALYZE TABLE myTable the Cardinality index is rebuilt correctly. Also if I run the same query on DB1 with Galera disabled wsrep_on=OFFthe index gets rebuilt correctly.

DB1: ALTER TABLE myTable CHANGE id id BIGINT;

Wait 1 minute

DB1:

MariaDB [test]> show indexes from myTable;
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table   | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| myTable |          0 | PRIMARY  |            1 | id          | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

DB2:

MariaDB [test]> show indexes from myTable;
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table   | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| myTable |          0 | PRIMARY  |            1 | id          | A         |         100 |     NULL | NULL   |      | BTREE      |         |               |
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

DB3:

MariaDB [test]> show indexes from myTable;
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table   | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| myTable |          0 | PRIMARY  |            1 | id          | A         |         100 |     NULL | NULL   |      | BTREE      |         |               |
+---------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+