[Commits] 1d55cfc: Do not use os_file_read() directly for reading first page of the

Jan Lindström jan.lindstrom at mariadb.com
Thu Sep 22 21:47:36 EEST 2016


revision-id: 1d55cfce10fc78c386f4444b20a21c664a81a297 (mariadb-10.1.17-18-g1d55cfc)
parent(s): 2bedc3978b90bf5abe1029df393c63ced1849bed
committer: Jan Lindström
timestamp: 2016-09-22 21:47:27 +0300
message:

Do not use os_file_read() directly for reading first page of the
tablespace. Instead use fil_read() with syncronous setting.
Fix test failures and mask tablespace number as it could
change in concurrent mtr runs.

---
 .../encryption/r/innodb-bad-key-change.result      |  4 +--
 .../suite/encryption/r/innodb_lotoftables.result   |  6 ++---
 .../suite/encryption/t/innodb-bad-key-change.test  |  3 ++-
 mysql-test/suite/innodb/r/innodb_monitor.result    |  1 +
 .../innodb/r/innodb_skip_innodb_is_tables.result   |  1 +
 .../r/innodb_monitor_reset_all_basic.result        |  1 +
 .../sys_vars/r/innodb_monitor_reset_basic.result   |  1 +
 storage/innobase/fil/fil0fil.cc                    | 30 ++++++++++------------
 storage/xtradb/fil/fil0fil.cc                      | 30 ++++++++++------------
 9 files changed, 37 insertions(+), 40 deletions(-)

diff --git a/mysql-test/suite/encryption/r/innodb-bad-key-change.result b/mysql-test/suite/encryption/r/innodb-bad-key-change.result
index ec8dee8..0d73aa5 100644
--- a/mysql-test/suite/encryption/r/innodb-bad-key-change.result
+++ b/mysql-test/suite/encryption/r/innodb-bad-key-change.result
@@ -36,7 +36,7 @@ SELECT * FROM t1;
 ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
 SHOW WARNINGS;
 Level	Code	Message
-Warning	192	Table test/t1 in tablespace 6 is encrypted but encryption service or used key_id is not available.  Can't continue reading table.
+Warning	192	Table test/t1 in tablespace  is encrypted but encryption service or used key_id is not available.  Can't continue reading table.
 Warning	192	Table test/t1 is encrypted but encryption service or used key_id is not available.  Can't continue reading table.
 Error	1296	Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
 DROP TABLE t1;
@@ -52,7 +52,7 @@ SELECT * FROM t2;
 ERROR HY000: Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
 SHOW WARNINGS;
 Level	Code	Message
-Warning	192	 is encrypted but encryption service or used key_id is not available.  Can't continue reading table.
+Warning	192	Table test/t2 in tablespace  is encrypted but encryption service or used key_id is not available.  Can't continue reading table.
 Warning	192	Table test/t2 is encrypted but encryption service or used key_id is not available.  Can't continue reading table.
 Error	1296	Got error 192 'Table encrypted but decryption failed. This could be because correct encryption management plugin is not loaded, used encryption key is not available or encryption method does not match.' from InnoDB
 SELECT * FROM t2 where id = 1;
diff --git a/mysql-test/suite/encryption/r/innodb_lotoftables.result b/mysql-test/suite/encryption/r/innodb_lotoftables.result
index 5e3eaef..34f2684 100644
--- a/mysql-test/suite/encryption/r/innodb_lotoftables.result
+++ b/mysql-test/suite/encryption/r/innodb_lotoftables.result
@@ -11,13 +11,13 @@ create database innodb_encrypted_1;
 use innodb_encrypted_1;
 show status like 'innodb_pages0_read%';
 Variable_name	Value
-Innodb_pages0_read	1
+Innodb_pages0_read	3
 set autocommit=0;
 set autocommit=1;
 commit work;
 show status like 'innodb_pages0_read%';
 Variable_name	Value
-Innodb_pages0_read	1
+Innodb_pages0_read	3
 # should be 100
 SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%';
 COUNT(*)
@@ -127,7 +127,7 @@ Variable_name	Value
 Innodb_pages0_read	203
 show status like 'innodb_pages0_read%';
 Variable_name	Value
-Innodb_pages0_read	203
+Innodb_pages0_read	303
 SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
 COUNT(*)
 100
diff --git a/mysql-test/suite/encryption/t/innodb-bad-key-change.test b/mysql-test/suite/encryption/t/innodb-bad-key-change.test
index 9180fb1..bc5e3b4 100644
--- a/mysql-test/suite/encryption/t/innodb-bad-key-change.test
+++ b/mysql-test/suite/encryption/t/innodb-bad-key-change.test
@@ -54,6 +54,7 @@ SELECT * FROM t1;
 
 --error ER_GET_ERRMSG
 SELECT * FROM t1;
+--replace_regex /tablespace [0-9]*/tablespace /
 SHOW WARNINGS;
 
 -- let $restart_parameters=--file-key-management-filename=$MYSQL_TEST_DIR/std_data/keysbad3.txt
@@ -79,7 +80,7 @@ INSERT INTO t2 VALUES ('foobar',1,2);
 
 --error ER_GET_ERRMSG
 SELECT * FROM t2;
---replace_regex /.*tablespace [0-9]*//
+--replace_regex /tablespace [0-9]*/tablespace /
 SHOW WARNINGS;
 --error ER_GET_ERRMSG
 SELECT * FROM t2 where id = 1;
diff --git a/mysql-test/suite/innodb/r/innodb_monitor.result b/mysql-test/suite/innodb/r/innodb_monitor.result
index 8c58034..33acfbd 100644
--- a/mysql-test/suite/innodb/r/innodb_monitor.result
+++ b/mysql-test/suite/innodb/r/innodb_monitor.result
@@ -40,6 +40,7 @@ buffer_pages_written	disabled
 buffer_index_pages_written	disabled
 buffer_non_index_pages_written	disabled
 buffer_pages_read	disabled
+buffer_pages0_read	disabled
 buffer_index_sec_rec_cluster_reads	disabled
 buffer_index_sec_rec_cluster_reads_avoided	disabled
 buffer_data_reads	disabled
diff --git a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
index 3280726..7568dc9 100644
--- a/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
+++ b/mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result
@@ -75,6 +75,7 @@ buffer_pages_written	buffer	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NUL
 buffer_index_pages_written	buffer	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	status_counter	Number of index pages written (innodb_index_pages_written)
 buffer_non_index_pages_written	buffer	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	status_counter	Number of non index pages written (innodb_non_index_pages_written)
 buffer_pages_read	buffer	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	status_counter	Number of pages read (innodb_pages_read)
+buffer_pages0_read	buffer	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	status_counter	Number of page 0 read (innodb_pages0_read)
 buffer_index_sec_rec_cluster_reads	buffer	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	status_counter	Number of secondary record reads triggered cluster read
 buffer_index_sec_rec_cluster_reads_avoided	buffer	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	status_counter	Number of secondary record reads avoided triggering cluster read
 buffer_data_reads	buffer	0	NULL	NULL	NULL	0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	disabled	status_counter	Amount of data read in bytes (innodb_data_reads)
diff --git a/mysql-test/suite/sys_vars/r/innodb_monitor_reset_all_basic.result b/mysql-test/suite/sys_vars/r/innodb_monitor_reset_all_basic.result
index 6c7051d..f7a02ed 100644
--- a/mysql-test/suite/sys_vars/r/innodb_monitor_reset_all_basic.result
+++ b/mysql-test/suite/sys_vars/r/innodb_monitor_reset_all_basic.result
@@ -40,6 +40,7 @@ buffer_pages_written	disabled
 buffer_index_pages_written	disabled
 buffer_non_index_pages_written	disabled
 buffer_pages_read	disabled
+buffer_pages0_read	disabled
 buffer_index_sec_rec_cluster_reads	disabled
 buffer_index_sec_rec_cluster_reads_avoided	disabled
 buffer_data_reads	disabled
diff --git a/mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result b/mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result
index 6c7051d..f7a02ed 100644
--- a/mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result
+++ b/mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result
@@ -40,6 +40,7 @@ buffer_pages_written	disabled
 buffer_index_pages_written	disabled
 buffer_non_index_pages_written	disabled
 buffer_pages_read	disabled
+buffer_pages0_read	disabled
 buffer_index_sec_rec_cluster_reads	disabled
 buffer_index_sec_rec_cluster_reads_avoided	disabled
 buffer_data_reads	disabled
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 43aecf4..d73539c 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -669,6 +669,7 @@ fil_node_open_file(
 		page = static_cast<byte*>(ut_align(buf2, UNIV_PAGE_SIZE));
 
 		success = os_file_read(node->handle, page, 0, UNIV_PAGE_SIZE);
+		srv_stats.page0_read.add(1);
 
 		space_id = fsp_header_get_space_id(page);
 		flags = fsp_header_get_flags(page);
@@ -7244,30 +7245,27 @@ fil_space_get_crypt_data(
 
 	space = fil_space_get_by_id(id);
 
+	mutex_exit(&fil_system->mutex);
+
 	if (space != NULL) {
 		/* If we have not yet read the page0
 		of this tablespace we will do it now. */
 		if (!space->crypt_data && !space->page_0_crypt_read) {
-			ulint flags;
-			ulint space_id;
-			lsn_t min_flushed_lsn;
-			lsn_t max_flushed_lsn;
+			ulint space_id = space->id;
 			fil_node_t*	node;
 
 			ut_a(space->crypt_data == NULL);
 			node = UT_LIST_GET_FIRST(space->chain);
 
-			fil_node_prepare_for_io(node, fil_system, space);
-
-			const char* msg = fil_read_first_page(node->handle,
-				false,
-				&flags,
-				&space_id,
-				&min_flushed_lsn,
-				&max_flushed_lsn,
-				&space->crypt_data);
-
-			fil_node_complete_io(node, fil_system, OS_FILE_READ);
+			byte *buf = static_cast<byte*>(ut_malloc(2 * UNIV_PAGE_SIZE));
+			byte *page = static_cast<byte*>(ut_align(buf, UNIV_PAGE_SIZE));
+			fil_read(true, space_id, 0, 0, 0, UNIV_PAGE_SIZE, page,
+				NULL, NULL);
+			ulint flags = fsp_header_get_flags(page);
+			ulint offset = fsp_header_get_crypt_offset(
+				fsp_flags_get_zip_size(flags), NULL);
+			space->crypt_data = fil_space_read_crypt_data(space_id, page, offset);
+			ut_free(buf);
 
 			ib_logf(IB_LOG_LEVEL_INFO,
 				"Read page 0 from tablespace for space %lu name %s key_id %u encryption %d handle %d\n",
@@ -7287,8 +7285,6 @@ fil_space_get_crypt_data(
 		ut_ad(space->page_0_crypt_read);
 	}
 
-	mutex_exit(&fil_system->mutex);
-
 	return(crypt_data);
 }
 
diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc
index 1db342d..1dbc333 100644
--- a/storage/xtradb/fil/fil0fil.cc
+++ b/storage/xtradb/fil/fil0fil.cc
@@ -672,6 +672,7 @@ fil_node_open_file(
 		page = static_cast<byte*>(ut_align(buf2, UNIV_PAGE_SIZE));
 
 		success = os_file_read(node->handle, page, 0, UNIV_PAGE_SIZE);
+		srv_stats.page0_read.add(1);
 
 		space_id = fsp_header_get_space_id(page);
 		flags = fsp_header_get_flags(page);
@@ -7342,30 +7343,27 @@ fil_space_get_crypt_data(
 
 	space = fil_space_get_by_id(id);
 
+	mutex_exit(&fil_system->mutex);
+
 	if (space != NULL) {
 		/* If we have not yet read the page0
 		of this tablespace we will do it now. */
 		if (!space->crypt_data && !space->page_0_crypt_read) {
-			ulint flags;
-			ulint space_id;
-			lsn_t min_flushed_lsn;
-			lsn_t max_flushed_lsn;
+			ulint space_id = space->id;
 			fil_node_t*	node;
 
 			ut_a(space->crypt_data == NULL);
 			node = UT_LIST_GET_FIRST(space->chain);
 
-			fil_node_prepare_for_io(node, fil_system, space);
-
-			const char* msg = fil_read_first_page(node->handle,
-				false,
-				&flags,
-				&space_id,
-				&min_flushed_lsn,
-				&max_flushed_lsn,
-				&space->crypt_data);
-
-			fil_node_complete_io(node, fil_system, OS_FILE_READ);
+			byte *buf = static_cast<byte*>(ut_malloc(2 * UNIV_PAGE_SIZE));
+			byte *page = static_cast<byte*>(ut_align(buf, UNIV_PAGE_SIZE));
+			fil_read(true, space_id, 0, 0, 0, UNIV_PAGE_SIZE, page,
+				NULL, NULL);
+			ulint flags = fsp_header_get_flags(page);
+			ulint offset = fsp_header_get_crypt_offset(
+				fsp_flags_get_zip_size(flags), NULL);
+			space->crypt_data = fil_space_read_crypt_data(space_id, page, offset);
+			ut_free(buf);
 
 			ib_logf(IB_LOG_LEVEL_INFO,
 				"Read page 0 from tablespace for space %lu name %s key_id %u encryption %d handle %d\n",
@@ -7385,8 +7383,6 @@ fil_space_get_crypt_data(
 		ut_ad(space->page_0_crypt_read);
 	}
 
-	mutex_exit(&fil_system->mutex);
-
 	return(crypt_data);
 }
 


More information about the commits mailing list