@@ -68,6 +68,11 @@ Created 11/5/1995 Heikki Tuuri
68
68
#include " lzo/lzo1x.h"
69
69
#endif
70
70
71
+ /* Enable this for checksum error messages. */
72
+ // #ifdef UNIV_DEBUG
73
+ // #define UNIV_DEBUG_LEVEL2 1
74
+ // #endif
75
+
71
76
/*
72
77
IMPLEMENTATION OF THE BUFFER POOL
73
78
=================================
@@ -533,7 +538,7 @@ buf_page_is_checksum_valid_crc32(
533
538
if (!(checksum_field1 == crc32 && checksum_field2 == crc32)) {
534
539
ib_logf (IB_LOG_LEVEL_INFO,
535
540
" Page checksum crc32 not valid field1 %lu field2 %lu crc32 %lu." ,
536
- checksum_field1, checksum_field2, crc32);
541
+ checksum_field1, checksum_field2, (ulint) crc32);
537
542
}
538
543
#endif
539
544
@@ -584,7 +589,7 @@ buf_page_is_checksum_valid_innodb(
584
589
#ifdef UNIV_DEBUG_LEVEL2
585
590
ib_logf (IB_LOG_LEVEL_INFO,
586
591
" Page checksum innodb not valid field1 %lu field2 %lu crc32 %lu lsn %lu." ,
587
- checksum_field1, checksum_field2, buf_calc_page_old_checksum (read_buf),
592
+ checksum_field1, checksum_field2, buf_calc_page_new_checksum (read_buf),
588
593
mach_read_from_4 (read_buf + FIL_PAGE_LSN)
589
594
);
590
595
#endif
@@ -610,7 +615,7 @@ buf_page_is_checksum_valid_none(
610
615
if (!(checksum_field1 == checksum_field2 || checksum_field1 == BUF_NO_CHECKSUM_MAGIC)) {
611
616
ib_logf (IB_LOG_LEVEL_INFO,
612
617
" Page checksum none not valid field1 %lu field2 %lu crc32 %lu lsn %lu." ,
613
- checksum_field1, checksum_field2, buf_calc_page_old_checksum (read_buf) ,
618
+ checksum_field1, checksum_field2, BUF_NO_CHECKSUM_MAGIC ,
614
619
mach_read_from_4 (read_buf + FIL_PAGE_LSN)
615
620
);
616
621
}
@@ -707,6 +712,7 @@ buf_page_is_corrupted(
707
712
if (zip_size) {
708
713
return (!page_zip_verify_checksum (read_buf, zip_size));
709
714
}
715
+
710
716
if (page_encrypted) {
711
717
return (FALSE );
712
718
}
@@ -1970,6 +1976,11 @@ buf_pool_watch_set(
1970
1976
buf_pool->watch[]. However, it is not in the critical code path
1971
1977
as this function will be called only by the purge thread. */
1972
1978
1979
+ /* Enable this for checksum error messages. Currently on by
1980
+ default on UNIV_DEBUG for encryption bugs. */
1981
+ #ifdef UNIV_DEBUG
1982
+ #define UNIV_DEBUG_LEVEL2 1
1983
+ #endif
1973
1984
1974
1985
/* To obey latching order first release the hash_lock. */
1975
1986
rw_lock_x_unlock (hash_lock);
@@ -4490,7 +4501,7 @@ buf_page_check_corrupt(
4490
4501
((buf_block_t *) bpage)->frame ;
4491
4502
bool page_compressed = bpage->page_encrypted ;
4492
4503
ulint stored_checksum = bpage->stored_checksum ;
4493
- ulint calculated_checksum = bpage->stored_checksum ;
4504
+ ulint calculated_checksum = bpage->calculated_checksum ;
4494
4505
bool page_compressed_encrypted = bpage->page_compressed ;
4495
4506
ulint space_id = mach_read_from_4 (
4496
4507
dst_frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
@@ -4596,6 +4607,10 @@ buf_page_io_complete(
4596
4607
frame = ((buf_block_t *) bpage)->frame ;
4597
4608
}
4598
4609
4610
+ ib_logf (IB_LOG_LEVEL_INFO,
4611
+ " Page %u in tablespace %u encryption error key_version %u." ,
4612
+ bpage->offset , bpage->space , bpage->key_version );
4613
+
4599
4614
goto database_corrupted;
4600
4615
}
4601
4616
@@ -4607,6 +4622,11 @@ buf_page_io_complete(
4607
4622
FALSE )) {
4608
4623
4609
4624
buf_pool->n_pend_unzip --;
4625
+
4626
+ ib_logf (IB_LOG_LEVEL_INFO,
4627
+ " Page %u in tablespace %u zip_decompress failure." ,
4628
+ bpage->offset , bpage->space );
4629
+
4610
4630
goto database_corrupted;
4611
4631
}
4612
4632
buf_pool->n_pend_unzip --;
@@ -6245,7 +6265,23 @@ buf_page_decrypt_after_read(
6245
6265
(crypt_data &&
6246
6266
crypt_data->type == CRYPT_SCHEME_UNENCRYPTED &&
6247
6267
key_version != 0 )) {
6248
- key_version = 0 ;
6268
+ byte* frame = NULL ;
6269
+
6270
+ if (buf_page_get_zip_size (bpage)) {
6271
+ frame = bpage->zip .data ;
6272
+ } else {
6273
+ frame = ((buf_block_t *) bpage)->frame ;
6274
+ }
6275
+
6276
+ /* If page is not corrupted at this point, page can't be
6277
+ encrypted, thus set key_version to 0. If page is corrupted,
6278
+ we assume at this point that it is encrypted as page
6279
+ contained key_version != 0. Note that page could still be
6280
+ really corrupted. This we will find out after decrypt by
6281
+ checking page checksums. */
6282
+ if (!buf_page_is_corrupted (false , frame, buf_page_get_zip_size (bpage))) {
6283
+ key_version = 0 ;
6284
+ }
6249
6285
}
6250
6286
6251
6287
/* If page is encrypted read post-encryption checksum */
0 commit comments