Skip to content

Commit c76873f

Browse files
Thirunarayanandr-m
authored andcommitted
MDEV-20688 Recovery crashes after unnecessarily reading a corrupted page
The test encryption.innodb-redo-badkey was accidentally disabled until commit 23657a2 enabled it recently. Once it was enabled, it started failing randomly. recv_recover_corrupt_page(): Do not assume that any redo log exists for the page. A page may be unnecessarily read by read-ahead. When noting the corruption, reset recv_addr->state to RECV_PROCESSED, so that even if the same page is re-read again, we will only decrement recv_sys->n_addrs once.
1 parent d874cde commit c76873f

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

mysql-test/suite/encryption/r/innodb-redo-badkey.result

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
call mtr.add_suppression("Plugin 'file_key_management'");
22
call mtr.add_suppression("Plugin 'InnoDB' init function returned error.");
3-
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file .*test/t[1-4]\\.ibd cannot be decrypted");
3+
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file '.*test/t[1-4]\\.ibd' cannot be decrypted");
44
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
5-
call mtr.add_suppression("InnoDB: Unable to decompress .*.test.t1\\.ibd\\[page id: space=[1-9][0-9]*, page number=[0-9]+\\]");
6-
call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t1 page \\[page id: space=[1-9][0-9]*, page number=[0-9]*\\]");
5+
call mtr.add_suppression("InnoDB: Unable to decompress .*.test.t[12]\\.ibd\\[page id: space=[1-9][0-9]*, page number=[0-9]+\\]");
6+
call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t[12] page \\[page id: space=[1-9][0-9]*, page number=[0-9]*\\]");
7+
call mtr.add_suppression("InnoDB: Failed to read file '.*' at offset .*");
78
call mtr.add_suppression("InnoDB: Plugin initialization aborted");
89
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
910
# Restart mysqld --file-key-management-filename=keys2.txt

mysql-test/suite/encryption/t/innodb-redo-badkey.test

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55

66
call mtr.add_suppression("Plugin 'file_key_management'");
77
call mtr.add_suppression("Plugin 'InnoDB' init function returned error.");
8-
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file .*test/t[1-4]\\.ibd cannot be decrypted");
8+
call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file '.*test/t[1-4]\\.ibd' cannot be decrypted");
99
call mtr.add_suppression("failed to read or decrypt \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\]");
10-
call mtr.add_suppression("InnoDB: Unable to decompress .*.test.t1\\.ibd\\[page id: space=[1-9][0-9]*, page number=[0-9]+\\]");
11-
call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t1 page \\[page id: space=[1-9][0-9]*, page number=[0-9]*\\]");
10+
call mtr.add_suppression("InnoDB: Unable to decompress .*.test.t[12]\\.ibd\\[page id: space=[1-9][0-9]*, page number=[0-9]+\\]");
11+
call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed file read of tablespace test/t[12] page \\[page id: space=[1-9][0-9]*, page number=[0-9]*\\]");
12+
call mtr.add_suppression("InnoDB: Failed to read file '.*' at offset .*");
1213
call mtr.add_suppression("InnoDB: Plugin initialization aborted");
1314
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
1415

storage/innobase/log/log0recv.cc

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,18 +2221,20 @@ void recv_recover_corrupt_page(page_id_t page_id)
22212221
mutex_enter(&recv_sys->mutex);
22222222

22232223
if (!recv_sys->apply_log_recs) {
2224-
mutex_exit(&recv_sys->mutex);
2225-
return;
2226-
}
2227-
2228-
recv_addr_t* recv_addr = recv_get_fil_addr_struct(
2229-
page_id.space(), page_id.page_no());
2230-
2231-
ut_ad(recv_addr->state != RECV_WILL_NOT_READ);
2232-
2233-
if (recv_addr->state != RECV_BEING_PROCESSED
2234-
&& recv_addr->state != RECV_PROCESSED) {
2235-
recv_sys->n_addrs--;
2224+
} else if (recv_addr_t* recv_addr = recv_get_fil_addr_struct(
2225+
page_id.space(), page_id.page_no())) {
2226+
switch (recv_addr->state) {
2227+
case RECV_WILL_NOT_READ:
2228+
ut_ad(!"wrong state");
2229+
break;
2230+
case RECV_BEING_PROCESSED:
2231+
case RECV_PROCESSED:
2232+
break;
2233+
default:
2234+
recv_addr->state = RECV_PROCESSED;
2235+
ut_ad(recv_sys->n_addrs);
2236+
recv_sys->n_addrs--;
2237+
}
22362238
}
22372239

22382240
mutex_exit(&recv_sys->mutex);

0 commit comments

Comments
 (0)