Skip to content

Commit 9608773

Browse files
committed
MDEV-4750 follow-up: Reduce disabling innodb_stats_persistent
This essentially reverts commit 4e89ec6 and only disables InnoDB persistent statistics for tests where it is desirable. By design, InnoDB persistent statistics will not be updated except by ANALYZE TABLE or by STATS_AUTO_RECALC. The internal transactions that update persistent InnoDB statistics in background tasks (with innodb_stats_auto_recalc=ON) may cause nondeterministic query plans or interfere with some tests that deal with other InnoDB internals, such as the purge of transaction history.
1 parent 45a05fd commit 9608773

File tree

131 files changed

+2275
-1862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+2275
-1862
lines changed

mysql-test/include/default_mysqld.cnf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright (c) 2007, 2013, Oracle and/or its affiliates
2-
# Copyright (c) 2010, 2019, MariaDB Corporation
2+
# Copyright (c) 2010, 2021, MariaDB Corporation
33
#
44
# This program is free software; you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
@@ -54,7 +54,6 @@ loose-innodb_write_io_threads= 2
5454
loose-innodb_read_io_threads= 2
5555
loose-innodb_log_buffer_size= 1M
5656
loose-innodb_log_file_size= 10M
57-
loose-innodb-stats-persistent= OFF
5857

5958
slave-net-timeout=120
6059

mysql-test/main/bug39022.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SH
2828
connection thread1;
2929
# should not crash
3030
SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SHARE MODE;
31-
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
31+
Got one of the listed errors
3232
connection thread2;
3333
d
3434
disconnect thread2;

mysql-test/main/bug39022.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SH
4040
connection thread1;
4141

4242
--echo # should not crash
43-
--error ER_LOCK_DEADLOCK
43+
--error ER_LOCK_DEADLOCK,ER_LOCK_WAIT_TIMEOUT
4444
SELECT d FROM t2,t1 WHERE d=(SELECT MAX(a) FROM t1 WHERE t1.a > t2.d) LOCK IN SHARE MODE; #crashes
4545

4646
connection thread2;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--skip-innodb-stats-persistent

mysql-test/main/create_or_replace.result

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
drop table if exists t1,t2,t3;
21
CREATE TABLE t2 (a int);
32
INSERT INTO t2 VALUES(1),(2),(3);
43
#
@@ -259,7 +258,8 @@ Note 1051 Unknown table 'test.t1,mysqltest2.t2'
259258
create table test.t1 (i int) engine=myisam;
260259
create table mysqltest2.t2 like test.t1;
261260
lock table test.t1 write, mysqltest2.t2 write;
262-
select * from information_schema.metadata_lock_info;
261+
select * from information_schema.metadata_lock_info
262+
where table_name not like 'innodb_%_stats';
263263
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
264264
# MDL_BACKUP_DDL NULL Backup lock
265265
# MDL_BACKUP_DML NULL Backup lock
@@ -272,7 +272,8 @@ ERROR 42000: A table must have at least 1 column
272272
show tables;
273273
Tables_in_test
274274
t2
275-
select * from information_schema.metadata_lock_info;
275+
select * from information_schema.metadata_lock_info
276+
where table_name not like 'innodb_%_stats';
276277
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
277278
# MDL_BACKUP_DDL NULL Backup lock
278279
# MDL_BACKUP_DML NULL Backup lock
@@ -281,14 +282,16 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
281282
# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2
282283
create or replace table mysqltest2.t2;
283284
ERROR 42000: A table must have at least 1 column
284-
select * from information_schema.metadata_lock_info;
285+
select * from information_schema.metadata_lock_info
286+
where table_name not like 'innodb_%_stats';
285287
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
286288
create table t1 (i int);
287289
drop table t1;
288290
create table test.t1 (i int);
289291
create table mysqltest2.t2 like test.t1;
290292
lock table test.t1 write, mysqltest2.t2 write;
291-
select * from information_schema.metadata_lock_info;
293+
select * from information_schema.metadata_lock_info
294+
where table_name not like 'innodb_%_stats';
292295
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
293296
# MDL_BACKUP_DDL NULL Backup lock
294297
# MDL_BACKUP_DML NULL Backup lock
@@ -301,7 +304,8 @@ ERROR 42S21: Duplicate column name 'a'
301304
show tables;
302305
Tables_in_test
303306
t2
304-
select * from information_schema.metadata_lock_info;
307+
select * from information_schema.metadata_lock_info
308+
where table_name not like 'innodb_%_stats';
305309
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
306310
# MDL_BACKUP_DDL NULL Backup lock
307311
# MDL_BACKUP_DML NULL Backup lock
@@ -310,14 +314,16 @@ THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
310314
# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock mysqltest2 t2
311315
create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a';
312316
ERROR 42S21: Duplicate column name 'a'
313-
select * from information_schema.metadata_lock_info;
317+
select * from information_schema.metadata_lock_info
318+
where table_name not like 'innodb_%_stats';
314319
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
315320
create table t1 (i int);
316321
drop table t1;
317322
create table test.t1 (i int) engine=innodb;
318323
create table mysqltest2.t2 like test.t1;
319324
lock table test.t1 write, mysqltest2.t2 write;
320-
select * from information_schema.metadata_lock_info;
325+
select * from information_schema.metadata_lock_info
326+
where table_name not like 'innodb_%_stats';
321327
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
322328
# MDL_BACKUP_DDL NULL Backup lock
323329
# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2
@@ -329,7 +335,8 @@ drop table test.t1,mysqltest2.t2;
329335
create table test.t1 (i int) engine=aria transactional=1 checksum=1;
330336
create table mysqltest2.t2 like test.t1;
331337
lock table test.t1 write, mysqltest2.t2 write;
332-
select * from information_schema.metadata_lock_info;
338+
select * from information_schema.metadata_lock_info
339+
where table_name not like 'innodb_%_stats';
333340
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
334341
# MDL_BACKUP_DDL NULL Backup lock
335342
# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock mysqltest2
@@ -424,31 +431,35 @@ drop view t1;
424431
#
425432
create table t1 (a int);
426433
lock table t1 write, t2 read;
427-
select * from information_schema.metadata_lock_info;
434+
select * from information_schema.metadata_lock_info
435+
where table_name not like 'innodb_%_stats';
428436
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
429437
# MDL_BACKUP_DDL NULL Backup lock
430438
# MDL_BACKUP_DML NULL Backup lock
431439
# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test
432440
# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1
433441
# MDL_SHARED_READ NULL Table metadata lock test t2
434442
create or replace table t1 (i int);
435-
select * from information_schema.metadata_lock_info;
443+
select * from information_schema.metadata_lock_info
444+
where table_name not like 'innodb_%_stats';
436445
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
437446
# MDL_BACKUP_DDL NULL Backup lock
438447
# MDL_BACKUP_DML NULL Backup lock
439448
# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test
440449
# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1
441450
# MDL_SHARED_READ NULL Table metadata lock test t2
442451
create or replace table t1 like t2;
443-
select * from information_schema.metadata_lock_info;
452+
select * from information_schema.metadata_lock_info
453+
where table_name not like 'innodb_%_stats';
444454
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
445455
# MDL_BACKUP_DDL NULL Backup lock
446456
# MDL_BACKUP_DML NULL Backup lock
447457
# MDL_INTENTION_EXCLUSIVE NULL Schema metadata lock test
448458
# MDL_SHARED_NO_READ_WRITE NULL Table metadata lock test t1
449459
# MDL_SHARED_READ NULL Table metadata lock test t2
450460
create or replace table t1 select 1 as f1;
451-
select * from information_schema.metadata_lock_info;
461+
select * from information_schema.metadata_lock_info
462+
where table_name not like 'innodb_%_stats';
452463
THREAD_ID LOCK_MODE LOCK_DURATION LOCK_TYPE TABLE_SCHEMA TABLE_NAME
453464
# MDL_BACKUP_DDL NULL Backup lock
454465
# MDL_BACKUP_DML NULL Backup lock

mysql-test/main/create_or_replace.test

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
--source include/have_innodb.inc
66
--source include/have_metadata_lock_info.inc
7-
--disable_warnings
8-
drop table if exists t1,t2,t3;
9-
--enable_warnings
107

118
#
129
# Create help table
@@ -215,18 +212,21 @@ create table mysqltest2.t2 like test.t1;
215212
lock table test.t1 write, mysqltest2.t2 write;
216213
--replace_column 1 #
217214
--sorted_result
218-
select * from information_schema.metadata_lock_info;
215+
select * from information_schema.metadata_lock_info
216+
where table_name not like 'innodb_%_stats';
219217
--error ER_TABLE_MUST_HAVE_COLUMNS
220218
create or replace table test.t1;
221219
show tables;
222220
--replace_column 1 #
223221
--sorted_result
224-
select * from information_schema.metadata_lock_info;
222+
select * from information_schema.metadata_lock_info
223+
where table_name not like 'innodb_%_stats';
225224
--error ER_TABLE_MUST_HAVE_COLUMNS
226225
create or replace table mysqltest2.t2;
227226
--replace_column 1 #
228227
--sorted_result
229-
select * from information_schema.metadata_lock_info;
228+
select * from information_schema.metadata_lock_info
229+
where table_name not like 'innodb_%_stats';
230230
create table t1 (i int);
231231
drop table t1;
232232

@@ -235,18 +235,21 @@ create table mysqltest2.t2 like test.t1;
235235
lock table test.t1 write, mysqltest2.t2 write;
236236
--replace_column 1 #
237237
--sorted_result
238-
select * from information_schema.metadata_lock_info;
238+
select * from information_schema.metadata_lock_info
239+
where table_name not like 'innodb_%_stats';
239240
--error ER_DUP_FIELDNAME
240241
create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a';
241242
show tables;
242243
--replace_column 1 #
243244
--sorted_result
244-
select * from information_schema.metadata_lock_info;
245+
select * from information_schema.metadata_lock_info
246+
where table_name not like 'innodb_%_stats';
245247
--error ER_DUP_FIELDNAME
246248
create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a';
247249
--replace_column 1 #
248250
--sorted_result
249-
select * from information_schema.metadata_lock_info;
251+
select * from information_schema.metadata_lock_info
252+
where table_name not like 'innodb_%_stats';
250253
create table t1 (i int);
251254
drop table t1;
252255

@@ -255,7 +258,8 @@ create table mysqltest2.t2 like test.t1;
255258
lock table test.t1 write, mysqltest2.t2 write;
256259
--replace_column 1 #
257260
--sorted_result
258-
select * from information_schema.metadata_lock_info;
261+
select * from information_schema.metadata_lock_info
262+
where table_name not like 'innodb_%_stats';
259263
unlock tables;
260264
drop table test.t1,mysqltest2.t2;
261265

@@ -264,7 +268,8 @@ create table mysqltest2.t2 like test.t1;
264268
lock table test.t1 write, mysqltest2.t2 write;
265269
--replace_column 1 #
266270
--sorted_result
267-
select * from information_schema.metadata_lock_info;
271+
select * from information_schema.metadata_lock_info
272+
where table_name not like 'innodb_%_stats';
268273
unlock tables;
269274
drop table t1;
270275

@@ -344,19 +349,24 @@ create table t1 (a int);
344349
lock table t1 write, t2 read;
345350
--replace_column 1 #
346351
--sorted_result
347-
select * from information_schema.metadata_lock_info;
352+
select * from information_schema.metadata_lock_info
353+
where table_name not like 'innodb_%_stats';
354+
348355
create or replace table t1 (i int);
349356
--replace_column 1 #
350357
--sorted_result
351-
select * from information_schema.metadata_lock_info;
358+
select * from information_schema.metadata_lock_info
359+
where table_name not like 'innodb_%_stats';
352360
create or replace table t1 like t2;
353361
--replace_column 1 #
354362
--sorted_result
355-
select * from information_schema.metadata_lock_info;
363+
select * from information_schema.metadata_lock_info
364+
where table_name not like 'innodb_%_stats';
356365
create or replace table t1 select 1 as f1;
357366
--replace_column 1 #
358367
--sorted_result
359-
select * from information_schema.metadata_lock_info;
368+
select * from information_schema.metadata_lock_info
369+
where table_name not like 'innodb_%_stats';
360370
drop table t1;
361371
unlock tables;
362372

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
--default-storage-engine=MyISAM
2+
--innodb-stats-persistent=OFF

mysql-test/main/derived_split_innodb.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
SET @save_innodb_stats_persistent=@@GLOBAL.innodb_stats_persistent;
2+
SET GLOBAL innodb_stats_persistent=0;
13
#
24
# MDEV-16917: do not use splitting for derived with join cache
35
#
@@ -241,3 +243,4 @@ set optimizer_switch='split_materialized=default';
241243
set use_stat_tables=default;
242244
set optimizer_use_condition_selectivity=default;
243245
# End of 10.3 tests
246+
SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent;

mysql-test/main/derived_split_innodb.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
--source include/default_optimizer_switch.inc
33
--source include/have_sequence.inc
44

5+
SET @save_innodb_stats_persistent=@@GLOBAL.innodb_stats_persistent;
6+
SET GLOBAL innodb_stats_persistent=0;
7+
58
--echo #
69
--echo # MDEV-16917: do not use splitting for derived with join cache
710
--echo #
@@ -193,3 +196,5 @@ set use_stat_tables=default;
193196
set optimizer_use_condition_selectivity=default;
194197

195198
--echo # End of 10.3 tests
199+
200+
SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent;

mysql-test/main/endspace.result

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ nothing
162162
teststring
163163
teststring
164164
drop table t1;
165-
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) engine=innodb;
165+
create table t1 (text1 varchar(32) not NULL, KEY key1 (text1)) engine=innodb
166+
stats_persistent=0;
166167
insert into t1 values ('teststring'), ('nothing'), ('teststring\t');
167168
check table t1;
168169
Table Op Msg_type Msg_text

0 commit comments

Comments
 (0)