Bug #84467 ALTERing KEY_BLOCK_SIZE keeps the old kbs in KEYs.
Submitted: 11 Jan 2017 8:22 Modified: 25 Jul 6:20
Reporter: Jean-François Gagné Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.7.17-log OS:Any
Assigned to: CPU Architecture:Any

[11 Jan 2017 8:22] Jean-François Gagné
Description:
Hi,

This is probably related to bug #70534.

When changing KEY_BLOCK_SIZE (from 8 to 4 and 4 to 2 in "How to repeat" below), the 1st alter pushes the old kbs in KEYs and the 2nd keeps the old kbs in KEYs.

I would expect nothing to be added to KEYs.

Thanks,

JFG

How to repeat:
> select version();
+------------+
| version()  |
+------------+
| 5.7.17-log |
+------------+
1 row in set (0.00 sec)

> show create table test\G
*************************** 1. row ***************************
       Table: test
Create Table: CREATE TABLE `test` (
  `id` bigint(20) NOT NULL,
  `portal_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `portal_id` (`portal_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8
1 row in set (0.00 sec)

> alter table test KEY_BLOCK_SIZE=4;
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0

> show create table test\G
*************************** 1. row ***************************
       Table: test
Create Table: CREATE TABLE `test` (
  `id` bigint(20) NOT NULL,
  `portal_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`) KEY_BLOCK_SIZE=8,
  UNIQUE KEY `portal_id` (`portal_id`) KEY_BLOCK_SIZE=8
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4
1 row in set (0.00 sec)

> alter table test KEY_BLOCK_SIZE=2;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

> show create table test\G
*************************** 1. row ***************************
       Table: test
Create Table: CREATE TABLE `test` (
  `id` bigint(20) NOT NULL,
  `portal_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`) KEY_BLOCK_SIZE=8,
  UNIQUE KEY `portal_id` (`portal_id`) KEY_BLOCK_SIZE=8
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=2
1 row in set (0.00 sec)

Suggested fix:
Do not push KEY_BLOCK_SIZE in KEYs on ALTER table.
Provide  way of fixing affected table (ideally a meta-data change only).
Add this fix to mysql_upgrade (only if meta-data change).
[11 Jan 2017 9:15] Umesh Shastry
Hello Jean,

Thank you for the report and test case.

Thanks,
Umesh
[14 Jul 2017 9:46] Jean-François Gagné
Hi,

Bug #70534 was closed as "Won't fix".  As this bug is related to this "Won't fix" bug, I would like to know if this bug is still being worked on or if it will be closed too.

Many thanks,

JFG
[25 Oct 2017 15:26] Sinisa Milivojevic
This is a duplicate of the bug:

https://bugs.mysql.com/bug.php?id=88220
[25 Jul 6:20] Jean-François Gagné
Hi Sinisa, I am replying late to your 25 Oct 2017 comment...

I am not sure it is a duplicate.  Bug#70534 and Bug#88220 are about removing compression, and this one is about changing the compression level.

They might all be fixed at the same time, but I am not sure they are duplicate.

Cheers, JFG