Skip to content

Commit

Permalink
Do not use os_file_read() directly for reading first page of the
Browse files Browse the repository at this point in the history
tablespace. Instead use fil_read() with syncronous setting.
Fix test failures and mask tablespace number as it could
change in concurrent mtr runs.
  • Loading branch information
Jan Lindström committed Sep 22, 2016
1 parent 2bedc39 commit 1d55cfc
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 40 deletions.
4 changes: 2 additions & 2 deletions mysql-test/suite/encryption/r/innodb-bad-key-change.result
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/suite/encryption/r/innodb_lotoftables.result
Expand Up @@ -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(*)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion mysql-test/suite/encryption/t/innodb-bad-key-change.test
Expand Up @@ -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
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/suite/innodb/r/innodb_monitor.result
Expand Up @@ -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
Expand Down
Expand Up @@ -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)
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down
30 changes: 13 additions & 17 deletions storage/innobase/fil/fil0fil.cc
Expand Up @@ -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);
Expand Down Expand Up @@ -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",
Expand All @@ -7287,8 +7285,6 @@ fil_space_get_crypt_data(
ut_ad(space->page_0_crypt_read);
}

mutex_exit(&fil_system->mutex);

return(crypt_data);
}

Expand Down
30 changes: 13 additions & 17 deletions storage/xtradb/fil/fil0fil.cc
Expand Up @@ -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);
Expand Down Expand Up @@ -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",
Expand All @@ -7385,8 +7383,6 @@ fil_space_get_crypt_data(
ut_ad(space->page_0_crypt_read);
}

mutex_exit(&fil_system->mutex);

return(crypt_data);
}

Expand Down

0 comments on commit 1d55cfc

Please sign in to comment.