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

Possible corruption of page_compressed tables, or when scrubbing is enabled

    XMLWordPrintable

Details

    Description

      The assertion that was added in MDEV-22931 proves that in some cases, a mini-transaction may allocate a page that had just been freed. The MDEV-8139 code changes are not prepared to deal with that. We have not completely analyzed the impact of this yet, but it is possible that a corrupted page may be written.

      Here is a stack trace after MDEV-22931 added the assertion:

      10.5 572e53d8ccf68ec04722d9868ed50db0276d6d54

      mysqld: /home/elenst/src/10.5/storage/innobase/include/mtr0log.h:514: void mtr_t::init(buf_block_t*): Assertion `!m_freed_pages' failed.
      #7  0x00007fdecf9170d2 in __assert_fail () from /lib64/libc.so.6
      #8  0x000055fd8ae67e03 in mtr_t::init (this=0x7fdecc1f2ee0, b=0x7fdeac140bd0) at /home/elenst/src/10.5/storage/innobase/include/mtr0log.h:514
      #9  0x000055fd8b0e5e3d in fsp_init_file_page (space=0x7fdd7419e168, block=0x7fdeac140bd0, mtr=0x7fdecc1f2ee0) at /home/elenst/src/10.5/storage/innobase/include/fsp0fsp.h:585
      #10 0x000055fd8b0dede9 in fsp_page_create (space=0x7fdd7419e168, offset=85, rw_latch=RW_X_LATCH, mtr=0x7fdecc1f2ee0) at /home/elenst/src/10.5/storage/innobase/fsp/fsp0fsp.cc:1083
      #11 0x000055fd8b0df36b in fsp_alloc_free_page (space=0x7fdd7419e168, hint=85, rw_latch=RW_X_LATCH, mtr=0x7fdecc1f2ee0, init_mtr=0x7fdecc1f2ee0) at /home/elenst/src/10.5/storage/innobase/fsp/fsp0fsp.cc:1197
      #12 0x000055fd8b0e2afa in fseg_alloc_free_page_low (space=0x7fdd7419e168, seg_inode=0x7fdeaf2c4332 "", iblock=0x7fdeac1195b8, hint=85, direction=111 'o', rw_latch=RW_X_LATCH, has_done_reservation=true, mtr=0x7fdecc1f2ee0, init_mtr=0x7fdecc1f2ee0) at /home/elenst/src/10.5/storage/innobase/fsp/fsp0fsp.cc:2124
      #13 0x000055fd8b0e342e in fseg_alloc_free_page_general (seg_header=0x7fdeaf2b8054 "", hint=85, direction=111 'o', has_done_reservation=true, mtr=0x7fdecc1f2ee0, init_mtr=0x7fdecc1f2ee0) at /home/elenst/src/10.5/storage/innobase/fsp/fsp0fsp.cc:2260
      #14 0x000055fd8afc9e2a in btr_page_alloc_low (index=0x7fdd74073448, hint_page_no=85, file_direction=111 'o', level=1, mtr=0x7fdecc1f2ee0, init_mtr=0x7fdecc1f2ee0) at /home/elenst/src/10.5/storage/innobase/btr/btr0btr.cc:538
      #15 0x000055fd8afc9ea0 in btr_page_alloc (index=0x7fdd74073448, hint_page_no=85, file_direction=111 'o', level=1, mtr=0x7fdecc1f2ee0, init_mtr=0x7fdecc1f2ee0) at /home/elenst/src/10.5/storage/innobase/btr/btr0btr.cc:570
      #16 0x000055fd8afd3884 in btr_page_split_and_insert (flags=7, cursor=0x7fdecc1f1bf0, offsets=0x7fdecc1f1be8, heap=0x7fdecc1f1be0, tuple=0x7fdd740ddc40, n_ext=0, mtr=0x7fdecc1f2ee0) at /home/elenst/src/10.5/storage/innobase/btr/btr0btr.cc:2841
      #17 0x000055fd8afff604 in btr_cur_pessimistic_insert (flags=7, cursor=0x7fdecc1f1bf0, offsets=0x7fdecc1f1be8, heap=0x7fdecc1f1be0, entry=0x7fdd740ddc40, rec=0x7fdecc1f1bd8, big_rec=0x7fdecc1f1bd0, n_ext=0, thr=0x0, mtr=0x7fdecc1f2ee0) at /home/elenst/src/10.5/storage/innobase/btr/btr0cur.cc:3727
      #18 0x000055fd8afd1dd1 in btr_insert_on_non_leaf_level_func (flags=3, index=0x7fdd74073448, level=1, tuple=0x7fdd740ddc40, file=0x55fd8b7ae628 "/home/elenst/src/10.5/storage/innobase/btr/btr0btr.cc", line=2702, mtr=0x7fdecc1f2ee0) at /home/elenst/src/10.5/storage/innobase/btr/btr0btr.cc:2415
      #19 0x000055fd8afd3069 in btr_insert_into_right_sibling (flags=3, cursor=0x7fdecc1f2be0, offsets=0x7fdecc1f2b88, heap=0x7fdd740ddb18, tuple=0x7fdd740f7f18, n_ext=0, mtr=0x7fdecc1f2ee0) at /home/elenst/src/10.5/storage/innobase/btr/btr0btr.cc:2702
      #20 0x000055fd8afd3674 in btr_page_split_and_insert (flags=3, cursor=0x7fdecc1f2be0, offsets=0x7fdecc1f2b88, heap=0x7fdecc1f2b60, tuple=0x7fdd740f7f18, n_ext=0, mtr=0x7fdecc1f2ee0) at /home/elenst/src/10.5/storage/innobase/btr/btr0btr.cc:2795
      #21 0x000055fd8afff604 in btr_cur_pessimistic_insert (flags=3, cursor=0x7fdecc1f2be0, offsets=0x7fdecc1f2b88, heap=0x7fdecc1f2b60, entry=0x7fdd740f7f18, rec=0x7fdecc1f2b90, big_rec=0x7fdecc1f2b98, n_ext=0, thr=0x7fdd7407fc50, mtr=0x7fdecc1f2ee0) at /home/elenst/src/10.5/storage/innobase/btr/btr0cur.cc:3727
      #22 0x000055fd8aeb8c22 in row_ins_sec_index_entry_low (flags=3, mode=33, index=0x7fdd74073448, offsets_heap=0x7fdd740ddb18, heap=0x7fdd740b3e38, entry=0x7fdd740f7f18, trx_id=0, thr=0x7fdd7407fc50) at /home/elenst/src/10.5/storage/innobase/row/row0ins.cc:3091
      #23 0x000055fd8aeb93f8 in row_ins_sec_index_entry (index=0x7fdd74073448, entry=0x7fdd740f7f18, thr=0x7fdd7407fc50, check_foreign=true) at /home/elenst/src/10.5/storage/innobase/row/row0ins.cc:3282
      #24 0x000055fd8aeb955f in row_ins_index_entry (index=0x7fdd74073448, entry=0x7fdd740f7f18, thr=0x7fdd7407fc50) at /home/elenst/src/10.5/storage/innobase/row/row0ins.cc:3313
      #25 0x000055fd8aeb9e74 in row_ins_index_entry_step (node=0x7fdd7407f8c8, thr=0x7fdd7407fc50) at /home/elenst/src/10.5/storage/innobase/row/row0ins.cc:3480
      #26 0x000055fd8aeba30f in row_ins (node=0x7fdd7407f8c8, thr=0x7fdd7407fc50) at /home/elenst/src/10.5/storage/innobase/row/row0ins.cc:3617
      #27 0x000055fd8aebaaea in row_ins_step (thr=0x7fdd7407fc50) at /home/elenst/src/10.5/storage/innobase/row/row0ins.cc:3756
      #28 0x000055fd8aedf0ac in row_insert_for_mysql (mysql_rec=0x7fdd74190888 "ejzlhrfrg", ' ' <repeats 51 times>, "r", ' ' <repeats 119 times>, prebuilt=0x7fdd7407f288, ins_mode=ROW_INS_NORMAL) at /home/elenst/src/10.5/storage/innobase/row/row0mysql.cc:1461
      #29 0x000055fd8ad305dc in ha_innobase::write_row (this=0x7fdd74074a50, record=0x7fdd74190888 "ejzlhrfrg", ' ' <repeats 51 times>, "r", ' ' <repeats 119 times>) at /home/elenst/src/10.5/storage/innobase/handler/ha_innodb.cc:7728
      #30 0x000055fd8a8f1b3a in handler::ha_write_row (this=0x7fdd74074a50, buf=0x7fdd74190888 "ejzlhrfrg", ' ' <repeats 51 times>, "r", ' ' <repeats 119 times>) at /home/elenst/src/10.5/sql/handler.cc:7140
      #31 0x000055fd8a684c3b in copy_data_between_tables (thd=0x7fdd74000b18, from=0x7fdd741111a8, to=0x7fdd740b6658, create=..., ignore=false, order_num=0, order=0x0, copied=0x7fdecc1f4d38, deleted=0x7fdecc1f4d40, keys_onoff=Alter_info::LEAVE_AS_IS, alter_ctx=0x7fdecc1f67c0) at /home/elenst/src/10.5/sql/sql_table.cc:11361
      #32 0x000055fd8a68291e in mysql_alter_table (thd=0x7fdd74000b18, new_db=0x7fdd740053d8, new_name=0x7fdd740057e0, create_info=0x7fdecc1f73c0, table_list=0x7fdd74012578, alter_info=0x7fdecc1f72f0, order_num=0, order=0x0, ignore=false, if_exists=false) at /home/elenst/src/10.5/sql/sql_table.cc:10744
      #33 0x000055fd8a728f3c in Sql_cmd_alter_table::execute (this=0x7fdd74012d68, thd=0x7fdd74000b18) at /home/elenst/src/10.5/sql/sql_alter.cc:538
      #34 0x000055fd8a586599 in mysql_execute_command (thd=0x7fdd74000b18) at /home/elenst/src/10.5/sql/sql_parse.cc:5951
      

      An investigation of the core dump showed that we are initializing page 85 in the .ibd file, and exactly that page had been marked as free earlier in the tablespace. It seems possible that we could wrongly skip the page write in this case.

      Note: the stack trace (of ALTER TABLE…ALGORITHM=COPY) is only one of numerous possibilities of this to occur.

      Note: The corruption (as well as this fix) should only affect page_compressed tables or the operation when innodb_background_scrub_data_uncompressed is enabled.

      Attachments

        1. mfreed1.test
          128 kB
          Elena Stepanova

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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