diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2018-10-24 16:01:18 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2018-10-25 13:04:41 +0300 |
commit | 2549f982891f4598768f10f2aa549861ea7152d1 (patch) | |
tree | 870a7c6dbb3fbcd1fb092c181fe9325536d1c230 | |
parent | 5dd3b52f950d688bbe9ea2e8cd10b5206198a096 (diff) | |
download | mariadb-git-2549f982891f4598768f10f2aa549861ea7152d1.tar.gz |
MDEV-17532 Performance_schema reports wrong directory for the temporary files of ALTER TABLE…ALGORITHM=INPLACE
row_merge_file_create_low(): Pass the directory of the temporary file
to the PSI_FILE_CALL.
-rw-r--r-- | mysql-test/suite/innodb/r/alter_inplace_perfschema.result | 15 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/alter_inplace_perfschema.opt | 2 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/alter_inplace_perfschema.test | 40 | ||||
-rw-r--r-- | storage/innobase/row/row0merge.cc | 11 | ||||
-rw-r--r-- | storage/xtradb/row/row0merge.cc | 11 |
5 files changed, 77 insertions, 2 deletions
diff --git a/mysql-test/suite/innodb/r/alter_inplace_perfschema.result b/mysql-test/suite/innodb/r/alter_inplace_perfschema.result new file mode 100644 index 00000000000..38c8ca2f553 --- /dev/null +++ b/mysql-test/suite/innodb/r/alter_inplace_perfschema.result @@ -0,0 +1,15 @@ +update performance_schema.setup_instruments set enabled='yes'; +update performance_schema.setup_consumers set enabled='yes'; +CREATE TABLE t1 (a serial, b varchar(255)) ENGINE=InnoDB; +BEGIN; +COMMIT; +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL go WAIT_FOR gone'; +ALTER TABLE t1 ADD INDEX(b), ALGORITHM=INPLACE; +SET DEBUG_SYNC = 'now WAIT_FOR go'; +SELECT DISTINCT object_name FROM performance_schema.events_waits_history_long +WHERE event_name LIKE '%wait%io%file%innodb%innodb_temp_file%'; +object_name +tmp/Innodb Merge Temp File +SET DEBUG_SYNC = 'now SIGNAL gone'; +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/alter_inplace_perfschema.opt b/mysql-test/suite/innodb/t/alter_inplace_perfschema.opt new file mode 100644 index 00000000000..f56125521fc --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_inplace_perfschema.opt @@ -0,0 +1,2 @@ +--innodb-sort-buffer-size=64k +--tmpdir=$MYSQLTEST_VARDIR/tmp diff --git a/mysql-test/suite/innodb/t/alter_inplace_perfschema.test b/mysql-test/suite/innodb/t/alter_inplace_perfschema.test new file mode 100644 index 00000000000..5f1e1f3491d --- /dev/null +++ b/mysql-test/suite/innodb/t/alter_inplace_perfschema.test @@ -0,0 +1,40 @@ +--source include/have_innodb.inc +--source include/have_perfschema.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc +--source include/not_embedded.inc + +connect (ddl, localhost, root,,); +update performance_schema.setup_instruments set enabled='yes'; +update performance_schema.setup_consumers set enabled='yes'; +CREATE TABLE t1 (a serial, b varchar(255)) ENGINE=InnoDB; + +BEGIN; +let $n=10; +--disable_query_log +while ($n) { +dec $n; +INSERT INTO t1 SELECT NULL, REPEAT('b',255); +} +--enable_query_log +COMMIT; + +SET DEBUG_SYNC = 'row_log_apply_before SIGNAL go WAIT_FOR gone'; +send ALTER TABLE t1 ADD INDEX(b), ALGORITHM=INPLACE; + +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR go'; +--replace_regex /.*[\\\/]tmp/tmp/ +SELECT DISTINCT object_name FROM performance_schema.events_waits_history_long +WHERE event_name LIKE '%wait%io%file%innodb%innodb_temp_file%'; + +#--exec lsof -p `pidof mysqld` +SET DEBUG_SYNC = 'now SIGNAL gone'; + +connection ddl; +reap; +disconnect ddl; + +connection default; +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 4090e388610..ec9b8f79e49 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -3139,9 +3139,17 @@ row_merge_file_create_low( performance schema */ struct PSI_file_locker* locker = NULL; PSI_file_locker_state state; + if (!path) { + path = mysql_tmpdir; + } + static const char label[] = "/Innodb Merge Temp File"; + char* name = static_cast<char*>( + ut_malloc(strlen(path) + sizeof label)); + strcpy(name, path); + strcat(name, label); locker = PSI_FILE_CALL(get_thread_file_name_locker)( &state, innodb_file_temp_key, PSI_FILE_OPEN, - "Innodb Merge Temp File", &locker); + path ? name : label, &locker); if (locker != NULL) { PSI_FILE_CALL(start_file_open_wait)(locker, __FILE__, @@ -3154,6 +3162,7 @@ row_merge_file_create_low( PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)( locker, fd); } + ut_free(name); #endif if (fd < 0) { diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc index e15b87b8ed5..603deb4b27e 100644 --- a/storage/xtradb/row/row0merge.cc +++ b/storage/xtradb/row/row0merge.cc @@ -3143,9 +3143,17 @@ row_merge_file_create_low( performance schema */ struct PSI_file_locker* locker = NULL; PSI_file_locker_state state; + if (!path) { + path = mysql_tmpdir; + } + static const char label[] = "/Innodb Merge Temp File"; + char* name = static_cast<char*>( + ut_malloc(strlen(path) + sizeof label)); + strcpy(name, path); + strcat(name, label); locker = PSI_FILE_CALL(get_thread_file_name_locker)( &state, innodb_file_temp_key, PSI_FILE_OPEN, - "Innodb Merge Temp File", &locker); + path ? name : label, &locker); if (locker != NULL) { PSI_FILE_CALL(start_file_open_wait)(locker, __FILE__, @@ -3158,6 +3166,7 @@ row_merge_file_create_low( PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)( locker, fd); } + ut_free(name); #endif if (fd < 0) { |