Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-37412

Corrupted page during recovery aborts the server

    XMLWordPrintable

Details

    • Can result in hang or crash
    • InnoDB could crash during the crash recovery of a corrupted database.
    • Q4/2025 Server Maintenance

    Description

      InnoDB recovery encountered corrupted page during recovery and tries to evict
      the page from buffer pool. While evicting the page, InnoDB expects the page
      lock to be held. But we don't satisfy the expectation and it lead to crash.

      Patch to repeat the scenario: (Basically it simulates the corruption during recovery)

      diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log
      0recv.cc
      index 004dc65c752..782015b8f5d 100644
      --- a/storage/innobase/log/log0recv.cc
      +++ b/storage/innobase/log/log0recv.cc
      @@ -3042,6 +3042,8 @@ static buf_block_t *recv_recover_page(buf_block_t 
      *block, mtr_t &mtr,
       
                      log_phys_t::apply_status a= l->apply(*block, recs.last_o
      ffset);
       
      +               DBUG_EXECUTE_IF("recv_corrupt",
      +                               a= log_phys_t::APPLIED_CORRUPTED;);
                      switch (a) {
                      case log_phys_t::APPLIED_NO:
                              ut_ad(!mtr.has_modifications());
      

      Test case to repeat the scenario:

      --source include/have_innodb.inc
      CREATE TABLE t (a INT AUTO_INCREMENT, PRIMARY KEY(a)) ENGINE=InnoDB;
      INSERT INTO t VALUES(1), (2), (3), (4);
      SELECT * FROM t;
      DROP TABLE t;
       
      --write_file $MYSQL_TMP_DIR/load.data
      1
      EOF
       
      CREATE TABLE t (id INT AUTO_INCREMENT, PRIMARY KEY(id)) ENGINE=InnoDB;
      SET FOREIGN_KEY_CHECKS=0, UNIQUE_CHECKS=0;
      BEGIN;
      eval LOAD DATA LOCAL INFILE '$MYSQL_TMP_DIR/load.data' INTO TABLE t;
      let $restart_parameters=--debug_dbug=+d,recv_corrupt;
      --let $shutdown_timeout=0   
      --source include/restart_mysqld.inc
       
      DROP TABLE t; 
      --remove_file $MYSQL_TMP_DIR/load.data
      
      

      crash is

      Thread 1 received signal SIGSEGV, Segmentation fault.
      0x00005d461ba0de4f in std::__atomic_base<unsigned int>::fetch_sub (__m=std::memory_order_release, __i=1, this=0x9c)
          at /usr/include/c++/13/bits/atomic_base.h:645
      645	      { return __atomic_fetch_sub(&_M_i, __i, int(__m)); }
      (rr) where
      #0  0x00005d461ba0de4f in std::__atomic_base<unsigned int>::fetch_sub (__m=std::memory_order_release, __i=1, this=0x9c)
          at /usr/include/c++/13/bits/atomic_base.h:645
      #1  fil_space_t::release (this=0x0) at /home/thiru/source_code/10.6/storage/innobase/include/fil0fil.h:585
      #2  0x00005d461bb038a1 in recv_recover_page (block=0x76cf7d4001a0, mtr=..., recs=..., space=0x0, init=0x5d4632f097c0)
          at /home/thiru/source_code/10.6/storage/innobase/log/log0recv.cc:3125
      #3  0x00005d461bb1bc98 in recv_sys_t::recover_low (this=0x5d461cd5e740 <recv_sys>, p={...}, mtr=..., b=0x76cf7d4001a0, init=...)
          at /home/thiru/source_code/10.6/storage/innobase/log/log0recv.cc:3572
      #4  0x00005d461baf96e8 in recv_sys_t::recover_deferred (this=0x5d461cd5e740 <recv_sys>, p={...}, name="./test/t.ibd", 
          free_block=@0x7ffe87b3e838: 0x76cf7d4001a0) at /home/thiru/source_code/10.6/storage/innobase/log/log0recv.cc:1117
      #5  0x00005d461baf84d3 in reinit_all (this=0x5d461d7cdcc0 <deferred_spaces>) at /home/thiru/source_code/10.6/storage/innobase/log/log0recv.cc:786
      #6  0x00005d461bb0bed5 in recv_recovery_from_checkpoint_start (flush_lsn=52363)
          at /home/thiru/source_code/10.6/storage/innobase/log/log0recv.cc:4774
      #7  0x00005d461bc9e56c in srv_start (create_new_db=false) at /home/thiru/source_code/10.6/storage/innobase/srv/srv0start.cc:1516
      #8  0x00005d461b9e0cb6 in innodb_init (p=0x5d4632def818) at /home/thiru/source_code/10.6/storage/innobase/handler/ha_innodb.cc:4340
      #9  0x00005d461b515687 in ha_initialize_handlerton (plugin_=0x5d4632d289d0) at /home/thiru/source_code/10.6/sql/handler.cc:664
      #10 0x00005d461b151512 in plugin_do_initialize (plugin=0x5d4632d289d0, state=@0x7ffe87b3f328: 4)
          at /home/thiru/source_code/10.6/sql/sql_plugin.cc:1456
      #11 0x00005d461b1518b9 in plugin_initialize (tmp_root=0x7ffe87b3f8a0, plugin=0x5d4632d289d0, argc=0x5d461cf3d7a8 <remaining_argc>, 
          argv=0x5d4632bf8f60, options_only=false) at /home/thiru/source_code/10.6/sql/sql_plugin.cc:1510
      #12 0x00005d461b1526b5 in plugin_init (argc=0x5d461cf3d7a8 <remaining_argc>, argv=0x5d4632bf8f60, flags=0)
          at /home/thiru/source_code/10.6/sql/sql_plugin.cc:1766
      #13 0x00005d461afc39f6 in init_server_components () at /home/thiru/source_code/10.6/sql/mysqld.cc:5119
      #14 0x00005d461afc4f64 in mysqld_main (argc=161, argv=0x5d4632bf8f60) at /home/thiru/source_code/10.6/sql/mysqld.cc:5762
      #15 0x00005d461afb8c9d in main (argc=29, argv=0x7ffe87b41df8) at /home/thiru/source_code/10.6/sql/main.cc:34
      
      

      Attachments

        Issue Links

          Activity

            People

              marko Marko Mäkelä
              thiru Thirunarayanan Balathandayuthapani
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.