@@ -526,6 +526,14 @@ buf_page_is_checksum_valid_crc32(
526
526
{
527
527
ib_uint32_t crc32 = buf_calc_page_crc32 (read_buf);
528
528
529
+ #ifdef UNIV_DEBUG_LEVEL2
530
+ if (!(checksum_field1 == crc32 && checksum_field2 == crc32)) {
531
+ ib_logf (IB_LOG_LEVEL_INFO,
532
+ " Page checksum crc32 not valid field1 %lu field2 %lu crc32 %lu." ,
533
+ checksum_field1, checksum_field2, crc32);
534
+ }
535
+ #endif
536
+
529
537
return (checksum_field1 == crc32 && checksum_field2 == crc32);
530
538
}
531
539
@@ -553,6 +561,13 @@ buf_page_is_checksum_valid_innodb(
553
561
554
562
if (checksum_field2 != mach_read_from_4 (read_buf + FIL_PAGE_LSN)
555
563
&& checksum_field2 != buf_calc_page_old_checksum (read_buf)) {
564
+ #ifdef UNIV_DEBUG_LEVEL2
565
+ ib_logf (IB_LOG_LEVEL_INFO,
566
+ " Page checksum innodb not valid field1 %lu field2 %lu crc32 %lu lsn %lu." ,
567
+ checksum_field1, checksum_field2, buf_calc_page_old_checksum (read_buf),
568
+ mach_read_from_4 (read_buf + FIL_PAGE_LSN)
569
+ );
570
+ #endif
556
571
return (false );
557
572
}
558
573
@@ -563,6 +578,13 @@ buf_page_is_checksum_valid_innodb(
563
578
564
579
if (checksum_field1 != 0
565
580
&& checksum_field1 != buf_calc_page_new_checksum (read_buf)) {
581
+ #ifdef UNIV_DEBUG_LEVEL2
582
+ ib_logf (IB_LOG_LEVEL_INFO,
583
+ " Page checksum innodb not valid field1 %lu field2 %lu crc32 %lu lsn %lu." ,
584
+ checksum_field1, checksum_field2, buf_calc_page_old_checksum (read_buf),
585
+ mach_read_from_4 (read_buf + FIL_PAGE_LSN)
586
+ );
587
+ #endif
566
588
return (false );
567
589
}
568
590
@@ -581,6 +603,16 @@ buf_page_is_checksum_valid_none(
581
603
ulint checksum_field1,
582
604
ulint checksum_field2)
583
605
{
606
+ #ifdef UNIV_DEBUG_LEVEL2
607
+ if (!(checksum_field1 == checksum_field2 || checksum_field1 == BUF_NO_CHECKSUM_MAGIC)) {
608
+ ib_logf (IB_LOG_LEVEL_INFO,
609
+ " Page checksum none not valid field1 %lu field2 %lu crc32 %lu lsn %lu." ,
610
+ checksum_field1, checksum_field2, buf_calc_page_old_checksum (read_buf),
611
+ mach_read_from_4 (read_buf + FIL_PAGE_LSN)
612
+ );
613
+ }
614
+ #endif
615
+
584
616
return (checksum_field1 == checksum_field2
585
617
&& checksum_field1 == BUF_NO_CHECKSUM_MAGIC);
586
618
}
@@ -598,9 +630,21 @@ buf_page_is_corrupted(
598
630
ulint zip_size) /* !< in: size of compressed page;
599
631
0 for uncompressed pages */
600
632
{
601
- ulint page_encrypted = fil_page_is_encrypted (read_buf);
602
633
ulint checksum_field1;
603
634
ulint checksum_field2;
635
+ ulint space_id = mach_read_from_4 (
636
+ read_buf + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
637
+ fil_space_crypt_t * crypt_data = fil_space_get_crypt_data (space_id);
638
+ bool page_encrypted = false ;
639
+
640
+ /* Page is encrypted if encryption information is found from
641
+ tablespace and page contains used key_version. This is true
642
+ also for pages first compressed and then encrypted. */
643
+ if (crypt_data &&
644
+ crypt_data->type != CRYPT_SCHEME_UNENCRYPTED &&
645
+ fil_page_is_encrypted (read_buf)) {
646
+ page_encrypted = true ;
647
+ }
604
648
605
649
if (!page_encrypted && !zip_size
606
650
&& memcmp (read_buf + FIL_PAGE_LSN + 4 ,
@@ -610,6 +654,11 @@ buf_page_is_corrupted(
610
654
/* Stored log sequence numbers at the start and the end
611
655
of page do not match */
612
656
657
+ ib_logf (IB_LOG_LEVEL_INFO,
658
+ " Log sequence number at the start %lu and the end %lu do not match." ,
659
+ mach_read_from_4 (read_buf + FIL_PAGE_LSN + 4 ),
660
+ mach_read_from_4 (read_buf + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM + 4 ));
661
+
613
662
return (TRUE );
614
663
}
615
664
@@ -676,6 +725,9 @@ buf_page_is_corrupted(
676
725
/* make sure that the page is really empty */
677
726
for (ulint i = 0 ; i < UNIV_PAGE_SIZE; i++) {
678
727
if (read_buf[i] != 0 ) {
728
+ ib_logf (IB_LOG_LEVEL_INFO,
729
+ " Checksum fields zero but page is not empty." );
730
+
679
731
return (TRUE );
680
732
}
681
733
}
@@ -686,7 +738,7 @@ buf_page_is_corrupted(
686
738
DBUG_EXECUTE_IF (" buf_page_is_corrupt_failure" , return (TRUE ); );
687
739
688
740
ulint page_no = mach_read_from_4 (read_buf + FIL_PAGE_OFFSET);
689
- ulint space_id = mach_read_from_4 (read_buf + FIL_PAGE_SPACE_ID);
741
+
690
742
const srv_checksum_algorithm_t curr_algo =
691
743
static_cast <srv_checksum_algorithm_t >(srv_checksum_algorithm);
692
744
@@ -4531,7 +4583,7 @@ buf_page_io_complete(
4531
4583
if (io_type == BUF_IO_READ) {
4532
4584
ulint read_page_no;
4533
4585
ulint read_space_id;
4534
- byte* frame;
4586
+ byte* frame = NULL ;
4535
4587
4536
4588
if (!buf_page_decrypt_after_read (bpage)) {
4537
4589
/* encryption error! */
@@ -4540,7 +4592,8 @@ buf_page_io_complete(
4540
4592
} else {
4541
4593
frame = ((buf_block_t *) bpage)->frame ;
4542
4594
}
4543
- goto corrupt;
4595
+
4596
+ goto database_corrupted;
4544
4597
}
4545
4598
4546
4599
if (buf_page_get_zip_size (bpage)) {
@@ -4551,7 +4604,7 @@ buf_page_io_complete(
4551
4604
FALSE )) {
4552
4605
4553
4606
buf_pool->n_pend_unzip --;
4554
- goto corrupt ;
4607
+ goto database_corrupted ;
4555
4608
}
4556
4609
buf_pool->n_pend_unzip --;
4557
4610
} else {
@@ -4614,7 +4667,7 @@ buf_page_io_complete(
4614
4667
}
4615
4668
goto page_not_corrupt;
4616
4669
;);
4617
- corrupt :
4670
+ database_corrupted :
4618
4671
bool corrupted = buf_page_check_corrupt (bpage);
4619
4672
4620
4673
if (corrupted) {
@@ -6177,6 +6230,19 @@ buf_page_decrypt_after_read(
6177
6230
bool page_compressed_encrypted = fil_page_is_compressed_encrypted (dst_frame);
6178
6231
buf_pool_t * buf_pool = buf_pool_from_bpage (bpage);
6179
6232
bool success = true ;
6233
+ ulint space_id = mach_read_from_4 (
6234
+ dst_frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
6235
+ fil_space_crypt_t * crypt_data = fil_space_get_crypt_data (space_id);
6236
+
6237
+ /* Page is encrypted if encryption information is found from
6238
+ tablespace and page contains used key_version. This is true
6239
+ also for pages first compressed and then encrypted. */
6240
+ if (!crypt_data ||
6241
+ (crypt_data &&
6242
+ crypt_data->type == CRYPT_SCHEME_UNENCRYPTED &&
6243
+ key_version != 0 )) {
6244
+ key_version = 0 ;
6245
+ }
6180
6246
6181
6247
/* If page is encrypted read post-encryption checksum */
6182
6248
if (!page_compressed_encrypted && key_version != 0 ) {
0 commit comments