1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
|
# This test used to be duplicated in the following:
# sys_vars.innodb_monitor_reset_basic
# sys_vars.innodb_monitor_reset_all_basic
# sys_vars.innodb_monitor_disable_basic
# sys_vars.innodb_monitor_enable_basic
--source include/have_innodb.inc
select name, if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics;
create temporary table orig_innodb_metrics as select name, enabled from information_schema.innodb_metrics;
set global innodb_monitor_disable = All;
select name from information_schema.innodb_metrics where enabled;
# Turn on all monitor counters
set global innodb_monitor_enable = all;
# status should all change to "enabled"
select name from information_schema.innodb_metrics where not enabled;
# Test wrong argument to the global configure option
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_monitor_enable = aaa;
# We require a valid monitor counter/module name. There is no default
# counter name or module. A warning will be printed asking user to
# specify a valid counter name.
#--disable_warnings
#set global innodb_monitor_enable = default;
#--enable_warnings
# Turn off all monitor counters, option name should be case
# insensitive
set global innodb_monitor_disable = All;
# status should all change to "disabled"
select name from information_schema.innodb_metrics where enabled;
# Reset all counter values
set global innodb_monitor_reset_all = all;
# count should all change to 0
select name from information_schema.innodb_metrics where count!=0;
# Test wildcard match, turn on all counters contain string "lock"
set global innodb_monitor_enable = "%lock%";
# All lock related counter should be enabled
select name from information_schema.innodb_metrics
where enabled != (name like "%lock%");
# Disable them
set global innodb_monitor_disable = "%lock%";
# All lock related counter should be disabled
select name, if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name like "%lock%";
# No match for "%lock*"
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_monitor_enable = "%lock*";
# All counters will be turned on with wildcard match string with all "%"
set global innodb_monitor_enable="%%%%%%%%%%%%%%%%%%%%%%%%%%%";
select name from information_schema.innodb_metrics where not enabled;
# Turn off all counters
set global innodb_monitor_disable="%%%%%";
select name from information_schema.innodb_metrics where enabled;
# One more round testing. All counters will be turned on with
# single wildcard character "%"
set global innodb_monitor_enable="%";
select name from information_schema.innodb_metrics where not enabled;
# Turn off all the counters with "%_%"
set global innodb_monitor_disable="%_%";
select name from information_schema.innodb_metrics where enabled;
# Turn on all counters start with "log"
set global innodb_monitor_enable="log%%%%";
select name from information_schema.innodb_metrics
where enabled != (name like "log%");
# Turn on counters "os_data_fsync" with wildcard match "os_%a_fs_ncs", "_"
# is single character wildcard match word
set global innodb_monitor_enable="os_%a_fs_ncs";
# Turn on counters whose name contains "os" and "pending" with
# wildcard match "os%pending%"
set global innodb_monitor_enable="os%pending%";
select name, if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name like "os%";
# Empty string is an invalid option
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_monitor_enable="";
--error ER_WRONG_VALUE_FOR_VAR
set global innodb_monitor_enable="_";
SET global innodb_monitor_disable = module_metadata;
SET global innodb_monitor_reset_all = module_metadata;
# Only turn on "table_open" counter
set global innodb_monitor_enable = metadata_table_handles_opened;
# Create a new table to test "metadata_table_handles_opened" counter
create table monitor_test(col int) engine = innodb;
# This will open the monitor_test table
select * from monitor_test;
# "metadata_table_handles_opened" should increment by 1
select name, max_count, min_count, count,
max_count_reset, min_count_reset, count_reset,
if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name = "metadata_table_handles_opened";
# Reset the counter value while counter is still on (started)
# This will reset value "count_reset" but not
# "count"
set global innodb_monitor_reset = metadata_table_handles_opened;
select name, max_count, min_count, count,
max_count_reset, min_count_reset, count_reset,
if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name = "metadata_table_handles_opened";
# re-create table again to increment "metadata_table_handles_opened" again
drop table monitor_test;
# Create a new table to test "metadata_table_handles_opened" counter
create table monitor_test(col int) engine = innodb;
select * from monitor_test;
# "metadata_table_handles_opened" should increment
select name, max_count, min_count, count,
max_count_reset, min_count_reset, count_reset,
if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name = "metadata_table_handles_opened";
# Cannot reset all monitor value while the counter is on
set global innodb_monitor_reset_all = metadata_table_handles_opened;
select name, max_count, min_count, count,
max_count_reset, min_count_reset, count_reset,
if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name = "metadata_table_handles_opened";
# Turn off the counter "metadata_table_handles_opened"
set global innodb_monitor_disable = metadata_table_handles_opened;
# Reset the counter value while counter is off (disabled)
set global innodb_monitor_reset = metadata_table_handles_opened;
select name, max_count, min_count, count,
max_count_reset, min_count_reset, count_reset,
if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name = "metadata_table_handles_opened";
# re-create table again. Since monitor is off, "metadata_table_handles_opened"
# should not be incremented
drop table monitor_test;
# Create a new table to test "metadata_table_handles_opened" counter
create table monitor_test(col int) engine = innodb;
# "metadata_table_handles_opened" should increment
select * from monitor_test;
select name, max_count, min_count, count,
max_count_reset, min_count_reset, count_reset,
if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name = "metadata_table_handles_opened";
# Reset all the counters, include those counter *_since_start
set global innodb_monitor_reset_all = metadata_table_handles_opened;
select name, max_count, min_count, count,
max_count_reset, min_count_reset, count_reset,
if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name = "metadata_table_handles_opened";
# Turn on "table_open" counter again
set global innodb_monitor_enable = metadata_table_handles_opened;
# Test metadata_table_handles_opened again to see if it is working correctly
# after above round of turning on/off/reset
drop table monitor_test;
# Create a new table to test "metadata_table_handles_opened" counter
create table monitor_test(col int) engine = innodb stats_persistent=0;
select * from monitor_test;
# "metadata_table_handles_opened" should increment
select name, max_count, min_count, count,
max_count_reset, min_count_reset, count_reset,
if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name like "metadata%";
# Reset counters only in "module_metadata" module
set global innodb_monitor_disable = module_metadata;
set global innodb_monitor_reset = module_metadata;
select name, max_count, min_count, count,
max_count_reset, min_count_reset, count_reset,
if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name like "metadata%";
set global innodb_monitor_reset_all = module_metadata;
select name, max_count, min_count, count,
max_count_reset, min_count_reset, count_reset,
if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name like "metadata%";
# Test Transaction Module
set global innodb_monitor_enable = module_trx;
begin;
insert into monitor_test values(9);
commit;
begin;
insert into monitor_test values(9);
rollback;
select name, max_count, min_count, count,
max_count_reset, min_count_reset, count_reset,
if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name='trx_rollbacks';
set global innodb_monitor_disable = module_trx;
drop table monitor_test;
set global innodb_monitor_enable = file_num_open_files;
# Counters are unpredictable
--replace_column 2 # 3 # 4 # 5 # 6 # 7 #
select name, max_count, min_count, count,
max_count_reset, min_count_reset, count_reset,
if(enabled,'enabled','disabled') status
from information_schema.innodb_metrics
where name like "file_num_open_files";
set global innodb_monitor_disable = file_num_open_files;
# Test ICP module counters
set global innodb_monitor_enable = "icp%";
create table monitor_test(a char(3), b int, c char(2),
primary key (a(1), c(1)), key(b)) engine = innodb;
insert into monitor_test values("13", 2, "aa");
--disable_ps2_protocol
select a from monitor_test where b < 1 for update;
# should have icp_attempts = 1 and icp_out_of_range = 1
select name, count from information_schema.innodb_metrics
where name like "icp%";
# should have icp_attempts = 2 and icp_match = 1
select a from monitor_test where b < 3 for update;
select name, count from information_schema.innodb_metrics
where name like "icp%";
--enable_ps2_protocol
drop table monitor_test;
set global innodb_monitor_disable = All;
set global innodb_monitor_reset_all = all;
# Test for bug #13966091
select 1 from `information_schema`.`INNODB_METRICS`
where case (1) when (1) then (AVG_COUNT_RESET) else (1) end;
-- disable_warnings
set global innodb_monitor_enable = default;
set global innodb_monitor_disable = default;
set global innodb_monitor_reset = default;
set global innodb_monitor_reset_all = default;
-- enable_warnings
--echo #
--echo # Bug#22576241 SETTING INNODB_MONITOR_ENABLE TO ALL DOES NOT ENABLE ALL
--echo # MONITORS
--echo #
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=0;
let $innodb_monitor_enable = `SELECT @@innodb_monitor_enable`;
SELECT /*1*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME
LIKE 'buffer_page_written_index_leaf';
SET GLOBAL innodb_monitor_enable='module_buffer_page';
INSERT INTO t1 VALUES (1), (2), (3), (4); FLUSH TABLES t1 FOR EXPORT;
UNLOCK TABLES;
let $wait_condition= select count > 0 from information_schema.innodb_metrics where name like 'buffer_page_written_index_leaf';
source include/wait_condition.inc;
SELECT /*2*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME
LIKE 'buffer_page_written_index_leaf';
SET GLOBAL innodb_monitor_disable='module_buffer_page';
SET GLOBAL innodb_monitor_reset_all='module_buffer_page';
SELECT /*3*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME
LIKE 'buffer_page_written_index_leaf';
SET GLOBAL innodb_monitor_enable='%';
--error ER_WRONG_VALUE_FOR_VAR
SET GLOBAL innodb_monitor_reset_all= '%', innodb_compression_algorithm= foo;
INSERT INTO t1 VALUES (5), (6), (7), (8); FLUSH TABLES t1 FOR EXPORT;
UNLOCK TABLES;
let $wait_condition= select count > 0 from information_schema.innodb_metrics where name like 'buffer_page_written_index_leaf';
source include/wait_condition.inc;
SELECT /*4*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME
LIKE 'buffer_page_written_index_leaf';
SET GLOBAL innodb_monitor_disable='%';
SET GLOBAL innodb_monitor_reset_all='%';
SELECT /*5*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME
LIKE 'buffer_page_written_index_leaf';
SET GLOBAL innodb_monitor_enable='ALL';
INSERT INTO t1 VALUES (9), (10), (11), (12); FLUSH TABLES t1 FOR EXPORT;
UNLOCK TABLES;
SELECT /*6*/ NAME, COUNT > 0 FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME
LIKE 'buffer_page_written_index_leaf';
DROP TABLE t1;
CREATE TABLE fl0 (
id INT NOT NULL PRIMARY KEY
) ENGINE = InnoDB;
CREATE TABLE fl1 (
id INT NOT NULL PRIMARY KEY,
fl0_id INT,
CONSTRAINT `fkl0`
FOREIGN KEY (fl0_id) REFERENCES fl0 (id)
ON DELETE CASCADE
ON UPDATE RESTRICT
) ENGINE = InnoDB;
CREATE TABLE fl2 (
id INT NOT NULL PRIMARY KEY,
fl1_id INT,
CONSTRAINT `fkl1`
FOREIGN KEY (fl1_id) REFERENCES fl1 (id)
ON DELETE CASCADE
ON UPDATE SET NULL
) ENGINE = InnoDB;
INSERT INTO fl0 VALUES (1000);
INSERT INTO fl1 VALUES (500, 1000), (1500, 1000);
INSERT INTO fl2 VALUES (200, 500), (800, 500), (1200, 1500), (1800, 1500);
CREATE TABLE t1(id INT PRIMARY KEY, a INT, b CHAR(1), UNIQUE KEY u(a,b))
ENGINE=InnoDB;
SET @start = (SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME
= 'lock_rec_lock_created');
BEGIN;
INSERT INTO t1 VALUES(1,1,'a'),(2,9999,'b'),(3,10000,'c'),(4,4,'d');
DELETE FROM t1 WHERE a = 9999 AND b='b';
COMMIT;
# After MDEV-30225 is fixed, the above DELETE creates next-key lock during
# secondary index unique search. That's why the result of the following must
# be 1.
SET @end = (SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME
= 'lock_rec_lock_created');
SELECT @end - @start;
--echo # Records must not be S/X-locked if a table is X-locked.
SET @start = @end;
# Tables will not be locked if autocommit is not 0.
# See OPTION_NOT_AUTOCOMMIT in ha_innobase::external_lock().
SET autocommit = 0;
BEGIN;
LOCK TABLE t1 WRITE;
SELECT * FROM t1;
SELECT * FROM t1 WHERE a>=10000;
SELECT * FROM t1 FOR UPDATE;
SELECT * FROM t1 WHERE a>=10000 FOR UPDATE;
UPDATE t1 SET b = 'b' WHERE id = 4;
UPDATE t1 SET b = 'b' WHERE a = 10000;
REPLACE INTO t1 VALUES (4,3,'a');
INSERT INTO t1 VALUES (3,1,'e') ON DUPLICATE KEY UPDATE b = 'b';
INSERT INTO t1 VALUES (5,5,'e');
DELETE FROM t1 WHERE a = 1 AND b='a';
DELETE FROM t1;
COMMIT;
UNLOCK TABLES;
SET @end = (SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'lock_rec_lock_created');
SELECT @end - @start;
--echo # Records must not be S-locked if a table is S-locked.
SET @start = @end;
BEGIN;
LOCK TABLE t1 WRITE;
INSERT INTO t1 VALUES(1,1,'a'),(2,9999,'b'),(3,10000,'c'),(4,4,'d');
DELETE FROM t1 WHERE a = 9999 AND b='b';
COMMIT;
UNLOCK TABLES;
BEGIN;
LOCK TABLE t1 READ;
SELECT * FROM t1 LOCK IN SHARE MODE;
SELECT * FROM t1 WHERE a>=10000 LOCK IN SHARE MODE;
COMMIT;
UNLOCK TABLES;
SET @end = (SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'lock_rec_lock_created');
SELECT @end - @start;
--echo # Records must not be S-locked for foreign keys enforcement
SET @start = @end;
BEGIN;
LOCK TABLE fl0 READ, fl1 READ, fl2 WRITE;
INSERT INTO fl2 VALUES (300, 500), (700, 500), (1300, 1500), (1700, 1500);
SELECT * FROM fl1 LOCK IN SHARE MODE;
COMMIT;
UNLOCK TABLES;
SET @end = (SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'lock_rec_lock_created');
SELECT @end - @start;
--echo # Records must not be X-locked for foreign keys cascade
SET @start = @end;
BEGIN;
LOCK TABLE fl0 READ, fl1 WRITE, fl2 WRITE;
DELETE FROM fl1 WHERE id = 1500;
UPDATE fl1 SET id = 2500 WHERE id = 500;
COMMIT;
UNLOCK TABLES;
SET @end = (SELECT COUNT FROM INFORMATION_SCHEMA.INNODB_METRICS WHERE NAME = 'lock_rec_lock_created');
SELECT @end - @start;
SET autocommit = default;
DROP TABLE t1;
DROP TABLE fl2;
DROP TABLE fl1;
DROP TABLE fl0;
set global innodb_monitor_disable = 'adaptive\\_hash\\_p%';
set global innodb_monitor_disable = 'adaptive\\_hash\\_r%';
set global innodb_monitor_disable = 'buffer\\_LRU\\_batch\\_n%';
set global innodb_monitor_disable = 'buffer\\_LRU\\_batch\\_s%';
set global innodb_monitor_disable = 'buffer\\_LRU\\_g%';
set global innodb_monitor_disable = 'buffer\\_LRU\\_s%';
set global innodb_monitor_disable = 'buffer\\_LRU\\_u%';
set global innodb_monitor_disable = 'buffer\\_f%';
set global innodb_monitor_disable = 'buffer\\_page\\_%';
set global innodb_monitor_disable = 'c%';
set global innodb_monitor_disable = 'ddl%';
set global innodb_monitor_disable = 'icp%';
set global innodb_monitor_disable = 'index\\_p%';
set global innodb_monitor_disable = 'innodb\\_di%';
set global innodb_monitor_disable = 'innodb\\_l%';
set global innodb_monitor_disable = 'innodb\\_m%';
set global innodb_monitor_disable = 'lock\\_re%';
set global innodb_monitor_disable = 'lock\\_ta%';
set global innodb_monitor_disable = 'log%';
set global innodb_monitor_disable = 'm%';
set global innodb_monitor_disable = 'p%';
set global innodb_monitor_disable = 't%';
set global innodb_monitor_enable = 'log\\_w%';
set global innodb_monitor_enable = 'trx_rseg_history_len';
set global innodb_monitor_enable = 'trx_undo_slots_cached';
set global innodb_monitor_enable=default;
set global innodb_monitor_disable=default;
set global innodb_monitor_reset_all=default;
select name, orig.enabled, new.enabled from
orig_innodb_metrics orig join information_schema.innodb_metrics new using(name)
where orig.enabled != new.enabled;
|