Skip to content

Commit 33ff186

Browse files
committed
MDEV-27835 innochecksum -S crashes for encrypted .ibd tablespace
As main() invokes parse_page() when -S or -D are set, it can be a case when parse_page() is invoked when -D filename is not set, that is why any attempt to write to page dump file must be done only if the file name is set with -D. The bug is caused by 2ef7a5a (MDEV-13443).
1 parent 303448b commit 33ff186

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

extra/innochecksum.cc

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ parse_page(
886886

887887
is_leaf = (!*(const uint16*) (page + (PAGE_HEADER + PAGE_LEVEL)));
888888

889-
if (page_type_dump) {
889+
if (file) {
890890
fprintf(file, "#::" UINT32PF "\t\t|\t\tIndex page\t\t\t|"
891891
"\tindex id=%llu,", cur_page_num, id);
892892

@@ -939,7 +939,7 @@ parse_page(
939939
index.total_data_bytes += data_bytes;
940940
index.pages_in_size_range[size_range_id] ++;
941941
}
942-
} else {
942+
} else if (file) {
943943
fprintf(file, "#::" UINT32PF "\t\t|\t\tEncrypted Index page\t\t\t|"
944944
"\tkey_version " UINT32PF ",%s\n", cur_page_num, key_version, str);
945945
}
@@ -950,20 +950,20 @@ parse_page(
950950
page_type.n_fil_page_undo_log++;
951951
undo_page_type = mach_read_from_2(page +
952952
TRX_UNDO_PAGE_HDR + TRX_UNDO_PAGE_TYPE);
953-
if (page_type_dump) {
953+
if (file) {
954954
fprintf(file, "#::" UINT32PF "\t\t|\t\tUndo log page\t\t\t|",
955955
cur_page_num);
956956
}
957957
if (undo_page_type == TRX_UNDO_INSERT) {
958958
page_type.n_undo_insert++;
959-
if (page_type_dump) {
959+
if (file) {
960960
fprintf(file, "\t%s",
961961
"Insert Undo log page");
962962
}
963963

964964
} else if (undo_page_type == TRX_UNDO_UPDATE) {
965965
page_type.n_undo_update++;
966-
if (page_type_dump) {
966+
if (file) {
967967
fprintf(file, "\t%s",
968968
"Update undo log page");
969969
}
@@ -974,31 +974,31 @@ parse_page(
974974
switch (undo_page_type) {
975975
case TRX_UNDO_ACTIVE:
976976
page_type.n_undo_state_active++;
977-
if (page_type_dump) {
977+
if (file) {
978978
fprintf(file, ", %s", "Undo log of "
979979
"an active transaction");
980980
}
981981
break;
982982

983983
case TRX_UNDO_CACHED:
984984
page_type.n_undo_state_cached++;
985-
if (page_type_dump) {
985+
if (file) {
986986
fprintf(file, ", %s", "Page is "
987987
"cached for quick reuse");
988988
}
989989
break;
990990

991991
case TRX_UNDO_TO_FREE:
992992
page_type.n_undo_state_to_free++;
993-
if (page_type_dump) {
993+
if (file) {
994994
fprintf(file, ", %s", "Insert undo "
995995
"segment that can be freed");
996996
}
997997
break;
998998

999999
case TRX_UNDO_TO_PURGE:
10001000
page_type.n_undo_state_to_purge++;
1001-
if (page_type_dump) {
1001+
if (file) {
10021002
fprintf(file, ", %s", "Will be "
10031003
"freed in purge when all undo"
10041004
"data in it is removed");
@@ -1007,7 +1007,7 @@ parse_page(
10071007

10081008
case TRX_UNDO_PREPARED:
10091009
page_type.n_undo_state_prepared++;
1010-
if (page_type_dump) {
1010+
if (file) {
10111011
fprintf(file, ", %s", "Undo log of "
10121012
"an prepared transaction");
10131013
}
@@ -1017,110 +1017,110 @@ parse_page(
10171017
page_type.n_undo_state_other++;
10181018
break;
10191019
}
1020-
if(page_type_dump) {
1020+
if(file) {
10211021
fprintf(file, ", %s\n", str);
10221022
}
10231023
break;
10241024

10251025
case FIL_PAGE_INODE:
10261026
page_type.n_fil_page_inode++;
1027-
if (page_type_dump) {
1027+
if (file) {
10281028
fprintf(file, "#::" UINT32PF "\t\t|\t\tInode page\t\t\t|"
10291029
"\t%s\n",cur_page_num, str);
10301030
}
10311031
break;
10321032

10331033
case FIL_PAGE_IBUF_FREE_LIST:
10341034
page_type.n_fil_page_ibuf_free_list++;
1035-
if (page_type_dump) {
1035+
if (file) {
10361036
fprintf(file, "#::" UINT32PF "\t\t|\t\tInsert buffer free list"
10371037
" page\t|\t%s\n", cur_page_num, str);
10381038
}
10391039
break;
10401040

10411041
case FIL_PAGE_TYPE_ALLOCATED:
10421042
page_type.n_fil_page_type_allocated++;
1043-
if (page_type_dump) {
1043+
if (file) {
10441044
fprintf(file, "#::" UINT32PF "\t\t|\t\tFreshly allocated "
10451045
"page\t\t|\t%s\n", cur_page_num, str);
10461046
}
10471047
break;
10481048

10491049
case FIL_PAGE_IBUF_BITMAP:
10501050
page_type.n_fil_page_ibuf_bitmap++;
1051-
if (page_type_dump) {
1051+
if (file) {
10521052
fprintf(file, "#::" UINT32PF "\t\t|\t\tInsert Buffer "
10531053
"Bitmap\t\t|\t%s\n", cur_page_num, str);
10541054
}
10551055
break;
10561056

10571057
case FIL_PAGE_TYPE_SYS:
10581058
page_type.n_fil_page_type_sys++;
1059-
if (page_type_dump) {
1059+
if (file) {
10601060
fprintf(file, "#::" UINT32PF "\t\t|\t\tSystem page\t\t\t|"
10611061
"\t%s\n", cur_page_num, str);
10621062
}
10631063
break;
10641064

10651065
case FIL_PAGE_TYPE_TRX_SYS:
10661066
page_type.n_fil_page_type_trx_sys++;
1067-
if (page_type_dump) {
1067+
if (file) {
10681068
fprintf(file, "#::" UINT32PF "\t\t|\t\tTransaction system "
10691069
"page\t\t|\t%s\n", cur_page_num, str);
10701070
}
10711071
break;
10721072

10731073
case FIL_PAGE_TYPE_FSP_HDR:
10741074
page_type.n_fil_page_type_fsp_hdr++;
1075-
if (page_type_dump) {
1075+
if (file) {
10761076
fprintf(file, "#::" UINT32PF "\t\t|\t\tFile Space "
10771077
"Header\t\t|\t%s\n", cur_page_num, str);
10781078
}
10791079
break;
10801080

10811081
case FIL_PAGE_TYPE_XDES:
10821082
page_type.n_fil_page_type_xdes++;
1083-
if (page_type_dump) {
1083+
if (file) {
10841084
fprintf(file, "#::" UINT32PF "\t\t|\t\tExtent descriptor "
10851085
"page\t\t|\t%s\n", cur_page_num, str);
10861086
}
10871087
break;
10881088

10891089
case FIL_PAGE_TYPE_BLOB:
10901090
page_type.n_fil_page_type_blob++;
1091-
if (page_type_dump) {
1091+
if (file) {
10921092
fprintf(file, "#::" UINT32PF "\t\t|\t\tBLOB page\t\t\t|\t%s\n",
10931093
cur_page_num, str);
10941094
}
10951095
break;
10961096

10971097
case FIL_PAGE_TYPE_ZBLOB:
10981098
page_type.n_fil_page_type_zblob++;
1099-
if (page_type_dump) {
1099+
if (file) {
11001100
fprintf(file, "#::" UINT32PF "\t\t|\t\tCompressed BLOB "
11011101
"page\t\t|\t%s\n", cur_page_num, str);
11021102
}
11031103
break;
11041104

11051105
case FIL_PAGE_TYPE_ZBLOB2:
11061106
page_type.n_fil_page_type_zblob2++;
1107-
if (page_type_dump) {
1107+
if (file) {
11081108
fprintf(file, "#::" UINT32PF "\t\t|\t\tSubsequent Compressed "
11091109
"BLOB page\t|\t%s\n", cur_page_num, str);
11101110
}
11111111
break;
11121112

11131113
case FIL_PAGE_PAGE_COMPRESSED:
11141114
page_type.n_fil_page_type_page_compressed++;
1115-
if (page_type_dump) {
1115+
if (file) {
11161116
fprintf(file, "#::" UINT32PF "\t\t|\t\tPage compressed "
11171117
"page\t|\t%s\n", cur_page_num, str);
11181118
}
11191119
break;
11201120

11211121
case FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED:
11221122
page_type.n_fil_page_type_page_compressed_encrypted++;
1123-
if (page_type_dump) {
1123+
if (file) {
11241124
fprintf(file, "#::" UINT32PF "\t\t|\t\tPage compressed encrypted "
11251125
"page\t|\t%s\n", cur_page_num, str);
11261126
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CREATE TABLE t6 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) ENGINE=InnoDB;
1414
# to redo apply the pages of t1.ibd at the time of recovery.
1515
# We want SQL to initiate the first access to t1.ibd.
1616
# Wait until disconnected.
17-
# Run innochecksum on t1
17+
# Run innochecksum on t1, check -S does not cause crash for encrypted file
1818
# Run innochecksum on t2
1919
# Run innochecksum on t3
2020
# Run innochecksum on t4

mysql-test/suite/encryption/t/innochecksum.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ shutdown_server;
6868
--echo # Wait until disconnected.
6969
--source include/wait_until_disconnected.inc
7070

71-
--echo # Run innochecksum on t1
7271
-- disable_result_log
73-
--exec $INNOCHECKSUM $t1_IBD
72+
--echo # Run innochecksum on t1, check -S does not cause crash for encrypted file
73+
--exec $INNOCHECKSUM -S $t1_IBD
7474

7575
--echo # Run innochecksum on t2
7676

0 commit comments

Comments
 (0)