Skip to content

MDEV-37138 innochecksum misinterprets doublewrite buffer pages #4160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 10.6
Choose a base branch
from

Conversation

Thirunarayanan
Copy link
Member

  • The Jira issue number for this PR is: MDEV-37138

Description

  • Innochecksum misinterprets the doublewrite buffer pages as index pages. This leads the user to think there could be stale table exist in system tablespace.

  • To avoid this confusion, innochecksum wired the skipping of doublewrite buffer pages to option -r while doing page dumping or printing the summary of the tablespace

Release Notes

innochecksum tool now skips doublewrite buffer page during -r or --skip-freed-pages option

How can this PR be tested?

--source include/have_innodb.inc
--source include/have_sequence.inc

let MYSQLD_DATADIR=`select @@datadir`;
create table t1 (f1 int primary key, f2 char(200)) engine=innodb        stats_persistent=0;
insert into t1 select seq, repeat('a', 200) from seq_1_to_16384;
SET GLOBAL innodb_max_dirty_pages_pct_lwm=0,                            innodb_max_dirty_pages_pct=0;
let $wait_condition =
SELECT variable_value = 0
FROM information_schema.global_status
WHERE variable_name = 'INNODB_BUFFER_POOL_PAGES_DIRTY';
--source include/wait_condition.inc

let $shutdown_timeout=0;
--source include/shutdown_mysqld.inc
--echo # Run the innochecksum to display undo log pages
let $resultlog=$MYSQLTEST_VARDIR/tmp/result.log;

exec $INNOCHECKSUM -S -r $MYSQLD_DATADIR/ibdata1 > $resultlog;
let $restart_parameters=;
--source include/start_mysqld.inc
select * from information_schema.innodb_sys_tables;
select * from information_schema.innodb_sys_indexes;
drop table t1;

Without patch:

File::/home/thiru/source_file/server/10.6/bld_new-debug/mysql-test/var/mysqld.1/data//ibdata1
================PAGE TYPE SUMMARY==============                                 
#PAGE_COUNT     PAGE_TYPE                                                       
===============================================                                 
     137        Index page                                                      
       0        Undo log page                                                   
       2        Inode page                                                      
       0        Insert buffer free list page                                    
     448        Freshly allocated page                                          
       1        Insert buffer bitmap                                            
     163        System page                                                     
       1        Transaction system page                                         
       2        File Space Header                                               
       0        Extent descriptor page                                          
       0        BLOB page                                                       
       0        Compressed BLOB page                                            
       0        Page compressed page                                            
       0        Page compressed encrypted page                                  
       0        Other type of page     
 
===============================================                                 
Additional information:                                                         
Undo page type: 0                                                               
Undo page state: 0 active, 0 cached, 0 to_purge, 0 prepared, 0 other            
index_id        #pages          #leaf_pages     #recs_per_page  #bytes_per_page 
1               1               1               7               546             
2               1               1               32              2111            
3               1               1               12              882             
4               1               1               20              897             
5               1               1               7               231             
11              1               1               0               0               
12              1               1               0               0               
13              1               1               0               0               
14              1               1               0               0               
15              1               1               0               0               
23              126             126             67              15096           
-4294967296             1               1               0               0   

With patch:

File::/home/thiru/source_file/server/10.6/bld_new-debug/mysql-test/var/mysqld.1/data//ibdata1
================PAGE TYPE SUMMARY==============                                 
#PAGE_COUNT     PAGE_TYPE                                                       
===============================================                                 
      11        Index page                                                      
       0        Undo log page                                                   
       2        Inode page                                                      
       0        Insert buffer free list page                                    
     448        Freshly allocated page                                          
       1        Insert buffer bitmap                                            
     162        System page                                                     
       1        Transaction system page                                         
       1        File Space Header                                               
       0        Extent descriptor page                                          
       0        BLOB page                                                       
       0        Compressed BLOB page                                            
       0        Page compressed page                                            
       0        Page compressed encrypted page                                  
       0        Other type of page                                              
                                                                                
===============================================       
 Additional information:                                                         
Undo page type: 0                                                               
Undo page state: 0 active, 0 cached, 0 to_purge, 0 prepared, 0 other            
index_id        #pages          #leaf_pages     #recs_per_page  #bytes_per_page 
1               1               1               7               546             
2               1               1               32              2111            
3               1               1               12              882             
4               1               1               20              897             
5               1               1               7               231             
11              1               1               0               0               
12              1               1               0               0               
13              1               1               0               0               
14              1               1               0               0               
15              1               1               0               0               
-4294967296             1               1               0               0 

Basing the PR against the correct MariaDB version

  • This is a new feature or a refactoring, and the PR is based against the main branch.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

- Innochecksum misinterprets the doublewrite buffer pages
as index pages. This leads the user to think there could be
stale table exist in system tablespace.

- To avoid this confusion, innochecksum wired the skipping
of doublewrite buffer pages to option -r while doing
page dumping or printing the summary of the tablespace
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@dr-m dr-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we need more test coverage of this code.

I was wondering whether and how this would work on the non-first file of a multi-file tablespace. I started by testing 10.6 without this change, and the following change:

diff --git a/mysql-test/suite/innodb/t/doublewrite_debug.test b/mysql-test/suite/innodb/t/doublewrite_debug.test
index e31cf34dbc1..1c4368f3265 100644
--- a/mysql-test/suite/innodb/t/doublewrite_debug.test
+++ b/mysql-test/suite/innodb/t/doublewrite_debug.test
@@ -160,17 +160,10 @@ AND support IN ('YES', 'DEFAULT', 'ENABLED');
 
 --let $ibp=--innodb-log-group-home-dir=$bugdir --innodb-data-home-dir=$bugdir
 --let $ibp=$ibp --innodb-undo-tablespaces=0
---let $ibp=$ibp --innodb-data-file-path=ibdata1:1M;ibdata2:1M:autoextend
+--let $ibp=$ibp --innodb-data-file-path=ibdata1:6M;ibdata2:1M:autoextend
 
 --let $restart_parameters= $ibp
 --source include/restart_mysqld.inc
 eval $check_no_innodb;
 --let SEARCH_PATTERN= \[ERROR\] InnoDB: Cannot create doublewrite buffer
 --source include/search_pattern_in_file.inc
---let $restart_parameters=
---source include/restart_mysqld.inc
-
---remove_file $bugdir/ibdata1
---remove_file $bugdir/ibdata2
---remove_file $bugdir/ib_logfile0
---rmdir $bugdir

I executed the following in the out-of-source build directory:

mysql-test/mtr innodb.doublewrite_debug
extra/innochecksum mysql-test/var/tmp/doublewrite/ibdata2

The latter command would crash due to an invalid physical_page_size:

#0  0x00007ffff7a9962d in __internal_syscall_cancel (a1=0x3, a2=0x7ffff7f56000, a3=0xfea000, a4=a4@entry=0x0, a5=a5@entry=0x0, a6=a6@entry=0x0, nr=0x0) at ./nptl/cancellation.c:37
#1  0x00007ffff7a996ad in __syscall_cancel (a1=<optimized out>, a2=<optimized out>, a3=<optimized out>, a4=a4@entry=0x0, a5=a5@entry=0x0, a6=a6@entry=0x0, nr=0x0) at ./nptl/cancellation.c:75
#2  0x00007ffff7b0dea6 in __GI___libc_read (fd=<optimized out>, buf=<optimized out>, nbytes=<optimized out>) at ../sysdeps/unix/sysv/linux/read.c:26
#3  0x00007ffff7a95939 in __GI__IO_file_xsgetn (fp=0x55555593e5d0, data=<optimized out>, n=0xfffc00) at ./libio/libioP.h:1041
#4  0x00007ffff7a88e69 in __GI__IO_fread (buf=0x7ffff7f40400, size=0x1, count=0xfffc00, fp=0x55555593e5d0) at ./libio/iofread.c:38
#5  0x000055555557a5be in read_file (buf=0x7ffff7f40400 '\377' <repeats 200 times>..., partial_page_read=0x1, physical_page_size=0xfffc00, fil_in=0x55555593e5d0) at /mariadb/10.6/extra/innochecksum.cc:411
#6  0x000055555557cdaf in main (argc=0x1, argv=0x7fffffffe5d0) at /mariadb/10.6/extra/innochecksum.cc:1602

Some other observations that I made:

  • parse_page() is missing a static attribute
  • Apparently, main() may invoke rewrite_checksum() on doublewrite buffer pages, which is something that does not seem to ever make any sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants