Skip to content

Commit d5d7c8b

Browse files
committed
MDEV-30544 Deprecate innodb_defragment and related parameters
There is a little used option innodb_defragment that would make OPTIMIZE TABLE not rebuild the table as usual for InnoDB, but instead cause the index B-trees to be optimized in place. This option uses excessive locking (exclusively locking index trees). It never covered SPATIAL INDEX or FULLTEXT INDEX. Storage space was never reclaimed. Because this option is not particularly useful and causes a maintenance burden (most recently in commit de4030e), it is best to deprecate it, to prepare for its removal.
1 parent 2b13ae1 commit d5d7c8b

16 files changed

+96
-8
lines changed

mysql-test/main/lock_sync-master.opt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
--default-storage-engine=MyISAM
2-
--innodb-defragment=0

mysql-test/suite/innodb/r/defrag_mdl-9155.result

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
set global innodb_defragment=1;
2+
Warnings:
3+
Warning 1287 '@@innodb_defragment' is deprecated and will be removed in a future release
24
create table t1 (a int not null primary key auto_increment, b varchar(256), key second(a, b)) engine=innodb;
35
insert t1 select null, repeat('a', 256) from seq_1_to_100;
46
select count(*) from t1;
@@ -16,3 +18,5 @@ test.t1 optimize status OK
1618
connection con1;
1719
drop table t1;
1820
set global innodb_defragment=default;
21+
Warnings:
22+
Warning 1287 '@@innodb_defragment' is deprecated and will be removed in a future release

mysql-test/suite/innodb/r/innodb_defrag_concurrent.result

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ SET @accuracy= @@GLOBAL.innodb_defragment_stats_accuracy;
33
SET @sp= @@GLOBAL.innodb_stats_persistent;
44
SET GLOBAL innodb_stats_persistent = 0;
55
set global innodb_defragment_stats_accuracy = 80;
6+
Warnings:
7+
Warning 1287 '@@innodb_defragment_stats_accuracy' is deprecated and will be removed in a future release
68
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
79
b VARCHAR(256),
810
c INT,
@@ -18,6 +20,8 @@ connect con3,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK;
1820
connect con4,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK;
1921
connection default;
2022
SET @@global.innodb_defragment_n_pages = 20;
23+
Warnings:
24+
Warning 1287 '@@innodb_defragment_n_pages' is deprecated and will be removed in a future release
2125
CREATE TEMPORARY TABLE tt (a INT, KEY(a)) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
2226
INSERT INTO tt SELECT 0 FROM seq_1_to_180;
2327
INSERT INTO tt SELECT 5 FROM seq_1_to_160;
@@ -98,5 +102,9 @@ count(stat_value) > 0
98102
1
99103
drop table t1;
100104
SET GLOBAL innodb_defragment_n_pages = @n_pages;
105+
Warnings:
106+
Warning 1287 '@@innodb_defragment_n_pages' is deprecated and will be removed in a future release
101107
SET GLOBAL innodb_defragment_stats_accuracy = @accuracy;
108+
Warnings:
109+
Warning 1287 '@@innodb_defragment_stats_accuracy' is deprecated and will be removed in a future release
102110
SET GLOBAL innodb_stats_persistent = @sp;

mysql-test/suite/innodb/r/innodb_defrag_stats.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
SET GLOBAL innodb_defragment_stats_accuracy = 20;
2+
Warnings:
3+
Warning 1287 '@@innodb_defragment_stats_accuracy' is deprecated and will be removed in a future release
24
DELETE FROM mysql.innodb_index_stats;
35
# Create table.
46
CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256),
@@ -77,6 +79,8 @@ t1 SECOND n_leaf_pages_reserved
7779
t1 SECOND n_page_split
7880
t1 SECOND n_pages_freed
7981
set global innodb_defragment_stats_accuracy = 40;
82+
Warnings:
83+
Warning 1287 '@@innodb_defragment_stats_accuracy' is deprecated and will be removed in a future release
8084
INSERT INTO t1 (b) SELECT b from t1;
8185
SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
8286
table_name index_name stat_name
@@ -116,6 +120,8 @@ drop index SECOND on t2;
116120
# MDEV-26636: Statistics must not be written for temporary tables
117121
#
118122
SET GLOBAL innodb_defragment_stats_accuracy = 1;
123+
Warnings:
124+
Warning 1287 '@@innodb_defragment_stats_accuracy' is deprecated and will be removed in a future release
119125
CREATE TEMPORARY TABLE t (a INT PRIMARY KEY, c CHAR(255) NOT NULL)
120126
ENGINE=InnoDB;
121127
INSERT INTO t SELECT seq, '' FROM seq_1_to_100;

mysql-test/suite/innodb/r/innodb_defrag_stats_many_tables.result

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ SET @start_flush_log_at_trx_commit = @@global.innodb_flush_log_at_trx_commit;
55
SET @@global.innodb_flush_log_at_trx_commit=2;
66
SET @start_innodb_defragment_stats_accuracy = @@global.innodb_defragment_stats_accuracy;
77
SET @@global.innodb_defragment_stats_accuracy = 80;
8+
Warnings:
9+
Warning 1287 '@@innodb_defragment_stats_accuracy' is deprecated and will be removed in a future release
810
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), KEY SECOND(a, b)) ENGINE=INNODB;
911
INSERT INTO t1 VALUES(1, REPEAT('A', 256));
1012
INSERT INTO t1 (b) SELECT b from t1;
@@ -34,5 +36,7 @@ sleep(15)
3436
select stat_value > 0 from mysql.innodb_index_stats where table_name like '%t1%' and stat_name = 'n_page_split';
3537
stat_value > 0
3638
SET @@global.innodb_defragment_stats_accuracy = @start_innodb_defragment_stats_accuracy;
39+
Warnings:
40+
Warning 1287 '@@innodb_defragment_stats_accuracy' is deprecated and will be removed in a future release
3741
SET @@global.table_definition_cache = @start_table_definition_cache;
3842
DROP TABLE t1;

mysql-test/suite/innodb/r/innodb_defragment.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
set global innodb_defragment_stats_accuracy = 80;
2+
Warnings:
3+
Warning 1287 '@@innodb_defragment_stats_accuracy' is deprecated and will be removed in a future release
24
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256), KEY SECOND(a, b)) ENGINE=INNODB;
35
optimize table t1;
46
Table Op Msg_type Msg_text
@@ -66,6 +68,8 @@ select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like
6668
count(stat_value) = 0
6769
1
6870
SET @@global.innodb_defragment_n_pages = 3;
71+
Warnings:
72+
Warning 1287 '@@innodb_defragment_n_pages' is deprecated and will be removed in a future release
6973
optimize table t1;
7074
Table Op Msg_type Msg_text
7175
test.t1 optimize status OK
@@ -104,6 +108,8 @@ select count(stat_value) = 0 from mysql.innodb_index_stats where table_name like
104108
count(stat_value) = 0
105109
1
106110
SET @@global.innodb_defragment_n_pages = 10;
111+
Warnings:
112+
Warning 1287 '@@innodb_defragment_n_pages' is deprecated and will be removed in a future release
107113
optimize table t1;
108114
Table Op Msg_type Msg_text
109115
test.t1 optimize status OK

mysql-test/suite/innodb/r/innodb_defragment_small.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
SET @innodb_defragment_orig=@@GLOBAL.innodb_defragment;
22
SET @innodb_optimize_fulltext_orig=@@GLOBAL.innodb_optimize_fulltext_only;
33
SET GLOBAL innodb_defragment = 1;
4+
Warnings:
5+
Warning 1287 '@@innodb_defragment' is deprecated and will be removed in a future release
46
SET GLOBAL innodb_optimize_fulltext_only = 0;
57
#
68
# MDEV-12198 innodb_defragment=1 crashes server on
@@ -27,6 +29,8 @@ OPTIMIZE TABLE t1;
2729
Table Op Msg_type Msg_text
2830
test.t1 optimize status OK
2931
SET GLOBAL innodb_defragment = 0;
32+
Warnings:
33+
Warning 1287 '@@innodb_defragment' is deprecated and will be removed in a future release
3034
OPTIMIZE TABLE t1;
3135
Table Op Msg_type Msg_text
3236
test.t1 optimize status OK
@@ -37,4 +41,6 @@ Table Op Msg_type Msg_text
3741
test.t1 optimize status OK
3842
DROP TABLE t1;
3943
SET GLOBAL innodb_defragment = @innodb_defragment_orig;
44+
Warnings:
45+
Warning 1287 '@@innodb_defragment' is deprecated and will be removed in a future release
4046
SET GLOBAL innodb_optimize_fulltext_only = @innodb_optimize_fulltext_orig;

mysql-test/suite/innodb/r/instant_alter_debug.result

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,14 @@ SET GLOBAL innodb_limit_optimistic_insert_debug = @old_limit;
279279
ALTER TABLE t1 ADD COLUMN b INT, ALGORITHM=INSTANT;
280280
SET @old_defragment = @@innodb_defragment;
281281
SET GLOBAL innodb_defragment = 1;
282+
Warnings:
283+
Warning 1287 '@@innodb_defragment' is deprecated and will be removed in a future release
282284
OPTIMIZE TABLE t1;
283285
Table Op Msg_type Msg_text
284286
test.t1 optimize status OK
285287
SET GLOBAL innodb_defragment = @old_defragment;
288+
Warnings:
289+
Warning 1287 '@@innodb_defragment' is deprecated and will be removed in a future release
286290
ALTER TABLE t1 ADD vb INT AS (b) VIRTUAL;
287291
CHECK TABLE t1;
288292
Table Op Msg_type Msg_text

mysql-test/suite/innodb/t/innodb.opt

Lines changed: 0 additions & 1 deletion
This file was deleted.

mysql-test/suite/sys_vars/r/innodb_defragment_basic.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ SELECT @orig;
33
@orig
44
0
55
SET GLOBAL innodb_defragment = OFF;
6+
Warnings:
7+
Warning 1287 '@@innodb_defragment' is deprecated and will be removed in a future release
68
SELECT @@global.innodb_defragment;
79
@@global.innodb_defragment
810
0
911
SET GLOBAL innodb_defragment = ON;
12+
Warnings:
13+
Warning 1287 '@@innodb_defragment' is deprecated and will be removed in a future release
1014
SELECT @@global.innodb_defragment;
1115
@@global.innodb_defragment
1216
1
@@ -16,3 +20,5 @@ SELECT @@global.innodb_defragment;
1620
@@global.innodb_defragment
1721
1
1822
SET GLOBAL innodb_defragment = @orig;
23+
Warnings:
24+
Warning 1287 '@@innodb_defragment' is deprecated and will be removed in a future release

0 commit comments

Comments
 (0)