Skip to content

Commit 1d55cfc

Browse files
author
Jan Lindström
committed
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.
1 parent 2bedc39 commit 1d55cfc

File tree

9 files changed

+37
-40
lines changed

9 files changed

+37
-40
lines changed

mysql-test/suite/encryption/r/innodb-bad-key-change.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ SELECT * FROM t1;
3636
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
3737
SHOW WARNINGS;
3838
Level Code Message
39-
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.
39+
Warning 192 Table test/t1 in tablespace is encrypted but encryption service or used key_id is not available. Can't continue reading table.
4040
Warning 192 Table test/t1 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
4141
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
4242
DROP TABLE t1;
@@ -52,7 +52,7 @@ SELECT * FROM t2;
5252
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
5353
SHOW WARNINGS;
5454
Level Code Message
55-
Warning 192 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
55+
Warning 192 Table test/t2 in tablespace is encrypted but encryption service or used key_id is not available. Can't continue reading table.
5656
Warning 192 Table test/t2 is encrypted but encryption service or used key_id is not available. Can't continue reading table.
5757
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
5858
SELECT * FROM t2 where id = 1;

mysql-test/suite/encryption/r/innodb_lotoftables.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ create database innodb_encrypted_1;
1111
use innodb_encrypted_1;
1212
show status like 'innodb_pages0_read%';
1313
Variable_name Value
14-
Innodb_pages0_read 1
14+
Innodb_pages0_read 3
1515
set autocommit=0;
1616
set autocommit=1;
1717
commit work;
1818
show status like 'innodb_pages0_read%';
1919
Variable_name Value
20-
Innodb_pages0_read 1
20+
Innodb_pages0_read 3
2121
# should be 100
2222
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE NAME LIKE 'innodb_encrypted%';
2323
COUNT(*)
@@ -127,7 +127,7 @@ Variable_name Value
127127
Innodb_pages0_read 203
128128
show status like 'innodb_pages0_read%';
129129
Variable_name Value
130-
Innodb_pages0_read 203
130+
Innodb_pages0_read 303
131131
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND NAME LIKE 'innodb_encrypted%';
132132
COUNT(*)
133133
100

mysql-test/suite/encryption/t/innodb-bad-key-change.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ SELECT * FROM t1;
5454

5555
--error ER_GET_ERRMSG
5656
SELECT * FROM t1;
57+
--replace_regex /tablespace [0-9]*/tablespace /
5758
SHOW WARNINGS;
5859

5960
-- 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);
7980

8081
--error ER_GET_ERRMSG
8182
SELECT * FROM t2;
82-
--replace_regex /.*tablespace [0-9]*//
83+
--replace_regex /tablespace [0-9]*/tablespace /
8384
SHOW WARNINGS;
8485
--error ER_GET_ERRMSG
8586
SELECT * FROM t2 where id = 1;

mysql-test/suite/innodb/r/innodb_monitor.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ buffer_pages_written disabled
4040
buffer_index_pages_written disabled
4141
buffer_non_index_pages_written disabled
4242
buffer_pages_read disabled
43+
buffer_pages0_read disabled
4344
buffer_index_sec_rec_cluster_reads disabled
4445
buffer_index_sec_rec_cluster_reads_avoided disabled
4546
buffer_data_reads disabled

mysql-test/suite/innodb/r/innodb_skip_innodb_is_tables.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ buffer_pages_written buffer 0 NULL NULL NULL 0 NULL NULL NULL NULL NULL NULL NUL
7575
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)
7676
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)
7777
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)
78+
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)
7879
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
7980
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
8081
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)

mysql-test/suite/sys_vars/r/innodb_monitor_reset_all_basic.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ buffer_pages_written disabled
4040
buffer_index_pages_written disabled
4141
buffer_non_index_pages_written disabled
4242
buffer_pages_read disabled
43+
buffer_pages0_read disabled
4344
buffer_index_sec_rec_cluster_reads disabled
4445
buffer_index_sec_rec_cluster_reads_avoided disabled
4546
buffer_data_reads disabled

mysql-test/suite/sys_vars/r/innodb_monitor_reset_basic.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ buffer_pages_written disabled
4040
buffer_index_pages_written disabled
4141
buffer_non_index_pages_written disabled
4242
buffer_pages_read disabled
43+
buffer_pages0_read disabled
4344
buffer_index_sec_rec_cluster_reads disabled
4445
buffer_index_sec_rec_cluster_reads_avoided disabled
4546
buffer_data_reads disabled

storage/innobase/fil/fil0fil.cc

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ fil_node_open_file(
669669
page = static_cast<byte*>(ut_align(buf2, UNIV_PAGE_SIZE));
670670

671671
success = os_file_read(node->handle, page, 0, UNIV_PAGE_SIZE);
672+
srv_stats.page0_read.add(1);
672673

673674
space_id = fsp_header_get_space_id(page);
674675
flags = fsp_header_get_flags(page);
@@ -7244,30 +7245,27 @@ fil_space_get_crypt_data(
72447245

72457246
space = fil_space_get_by_id(id);
72467247

7248+
mutex_exit(&fil_system->mutex);
7249+
72477250
if (space != NULL) {
72487251
/* If we have not yet read the page0
72497252
of this tablespace we will do it now. */
72507253
if (!space->crypt_data && !space->page_0_crypt_read) {
7251-
ulint flags;
7252-
ulint space_id;
7253-
lsn_t min_flushed_lsn;
7254-
lsn_t max_flushed_lsn;
7254+
ulint space_id = space->id;
72557255
fil_node_t* node;
72567256

72577257
ut_a(space->crypt_data == NULL);
72587258
node = UT_LIST_GET_FIRST(space->chain);
72597259

7260-
fil_node_prepare_for_io(node, fil_system, space);
7261-
7262-
const char* msg = fil_read_first_page(node->handle,
7263-
false,
7264-
&flags,
7265-
&space_id,
7266-
&min_flushed_lsn,
7267-
&max_flushed_lsn,
7268-
&space->crypt_data);
7269-
7270-
fil_node_complete_io(node, fil_system, OS_FILE_READ);
7260+
byte *buf = static_cast<byte*>(ut_malloc(2 * UNIV_PAGE_SIZE));
7261+
byte *page = static_cast<byte*>(ut_align(buf, UNIV_PAGE_SIZE));
7262+
fil_read(true, space_id, 0, 0, 0, UNIV_PAGE_SIZE, page,
7263+
NULL, NULL);
7264+
ulint flags = fsp_header_get_flags(page);
7265+
ulint offset = fsp_header_get_crypt_offset(
7266+
fsp_flags_get_zip_size(flags), NULL);
7267+
space->crypt_data = fil_space_read_crypt_data(space_id, page, offset);
7268+
ut_free(buf);
72717269

72727270
ib_logf(IB_LOG_LEVEL_INFO,
72737271
"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(
72877285
ut_ad(space->page_0_crypt_read);
72887286
}
72897287

7290-
mutex_exit(&fil_system->mutex);
7291-
72927288
return(crypt_data);
72937289
}
72947290

storage/xtradb/fil/fil0fil.cc

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ fil_node_open_file(
672672
page = static_cast<byte*>(ut_align(buf2, UNIV_PAGE_SIZE));
673673

674674
success = os_file_read(node->handle, page, 0, UNIV_PAGE_SIZE);
675+
srv_stats.page0_read.add(1);
675676

676677
space_id = fsp_header_get_space_id(page);
677678
flags = fsp_header_get_flags(page);
@@ -7342,30 +7343,27 @@ fil_space_get_crypt_data(
73427343

73437344
space = fil_space_get_by_id(id);
73447345

7346+
mutex_exit(&fil_system->mutex);
7347+
73457348
if (space != NULL) {
73467349
/* If we have not yet read the page0
73477350
of this tablespace we will do it now. */
73487351
if (!space->crypt_data && !space->page_0_crypt_read) {
7349-
ulint flags;
7350-
ulint space_id;
7351-
lsn_t min_flushed_lsn;
7352-
lsn_t max_flushed_lsn;
7352+
ulint space_id = space->id;
73537353
fil_node_t* node;
73547354

73557355
ut_a(space->crypt_data == NULL);
73567356
node = UT_LIST_GET_FIRST(space->chain);
73577357

7358-
fil_node_prepare_for_io(node, fil_system, space);
7359-
7360-
const char* msg = fil_read_first_page(node->handle,
7361-
false,
7362-
&flags,
7363-
&space_id,
7364-
&min_flushed_lsn,
7365-
&max_flushed_lsn,
7366-
&space->crypt_data);
7367-
7368-
fil_node_complete_io(node, fil_system, OS_FILE_READ);
7358+
byte *buf = static_cast<byte*>(ut_malloc(2 * UNIV_PAGE_SIZE));
7359+
byte *page = static_cast<byte*>(ut_align(buf, UNIV_PAGE_SIZE));
7360+
fil_read(true, space_id, 0, 0, 0, UNIV_PAGE_SIZE, page,
7361+
NULL, NULL);
7362+
ulint flags = fsp_header_get_flags(page);
7363+
ulint offset = fsp_header_get_crypt_offset(
7364+
fsp_flags_get_zip_size(flags), NULL);
7365+
space->crypt_data = fil_space_read_crypt_data(space_id, page, offset);
7366+
ut_free(buf);
73697367

73707368
ib_logf(IB_LOG_LEVEL_INFO,
73717369
"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(
73857383
ut_ad(space->page_0_crypt_read);
73867384
}
73877385

7388-
mutex_exit(&fil_system->mutex);
7389-
73907386
return(crypt_data);
73917387
}
73927388

0 commit comments

Comments
 (0)