[MDEV-23199] page_compression flag is missing for full_crc32 tablespace Created: 2020-07-17  Updated: 2020-10-21  Resolved: 2020-09-10

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.4.4, 10.5.0
Fix Version/s: 10.4.16, 10.5.7

Type: Bug Priority: Major
Reporter: Thirunarayanan Balathandayuthapani Assignee: Thirunarayanan Balathandayuthapani
Resolution: Fixed Votes: 0
Labels: rr-profile-analyzed

Issue Links:
Problem/Incident
is caused by MDEV-12026 Support encrypted SPATIAL INDEX Closed
Relates
relates to MDEV-16328 ALTER TABLE…page_compression_level sh... Closed
relates to MDEV-18644 Support FULL_CRC32 for compressed pages. Closed
relates to MDEV-23986 [ERROR] [FATAL] InnoDB: Page ... nam... Closed

 Description   

The page compression flag wasn't set during recovery. So while opening the table, it leads to wrong page corruption.

Stack trace is

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00001f3a412ca8b1 in __GI_abort () at abort.c:79
#2  0x00005650b748a0a3 in ib::fatal::~fatal (this=0x7ffffcd5e690, __in_chrg=<optimized out>) at /home/mleich/bb-10.5-thiru/storage/innobase/ut/ut0ut.cc:580
#3  0x00005650b74f5321 in fil_page_type_validate (space=0x1d3d614522f8, page=0x4a4654826000 "")
    at /home/mleich/bb-10.5-thiru/storage/innobase/include/fil0fil.ic:131
#4  0x00005650b74f69d5 in buf_page_decrypt_after_read (bpage=0x4a465396eb00, node=...) at /home/mleich/bb-10.5-thiru/storage/innobase/buf/buf0buf.cc:497
#5  0x00005650b7500720 in buf_page_read_complete (bpage=0x4a465396eb00, node=...) at /home/mleich/bb-10.5-thiru/storage/innobase/buf/buf0buf.cc:4226
#6  0x00005650b752abae in buf_read_page_low (err=0x7ffffcd5ee74, sync=true, mode=132, page_id=..., zip_size=0, unzip=false, ignore=false)
    at /home/mleich/bb-10.5-thiru/storage/innobase/buf/buf0rea.cc:364
#7  0x00005650b752b0a7 in buf_read_page (page_id=..., zip_size=0) at /home/mleich/bb-10.5-thiru/storage/innobase/buf/buf0rea.cc:480
#8  0x00005650b74fca3a in buf_page_get_low (page_id=..., zip_size=0, rw_latch=1, guess=0x0, mode=10, 
    file=0x5650b7cd0780 "/home/mleich/bb-10.5-thiru/storage/innobase/dict/dict0load.cc", line=2996, mtr=0x7ffffcd5f650, err=0x0, allow_ibuf_merge=false)
    at /home/mleich/bb-10.5-thiru/storage/innobase/buf/buf0buf.cc:3174
#9  0x00005650b74fe001 in buf_page_get_gen (page_id=..., zip_size=0, rw_latch=1, guess=0x0, mode=10, 
    file=0x5650b7cd0780 "/home/mleich/bb-10.5-thiru/storage/innobase/dict/dict0load.cc", line=2996, mtr=0x7ffffcd5f650, err=0x0, allow_ibuf_merge=false)
    at /home/mleich/bb-10.5-thiru/storage/innobase/buf/buf0buf.cc:3645
#10 0x00005650b7563a49 in dict_load_table_one (name=..., ignore_err=DICT_ERR_IGNORE_RECOVER_LOCK, fk_tables=std::deque with 0 elements)
    at /home/mleich/bb-10.5-thiru/storage/innobase/dict/dict0load.cc:2994
#11 0x00005650b7562831 in dict_load_table (name=0x394950f7aae8 "test/t6", ignore_err=DICT_ERR_IGNORE_RECOVER_LOCK)
    at /home/mleich/bb-10.5-thiru/storage/innobase/dict/dict0load.cc:2745
#12 0x00005650b7564539 in dict_load_table_on_id (table_id=25, ignore_err=DICT_ERR_IGNORE_RECOVER_LOCK)
    at /home/mleich/bb-10.5-thiru/storage/innobase/dict/dict0load.cc:3182
#13 0x00005650b7543d4c in dict_table_open_on_id_low (table_id=25, ignore_err=DICT_ERR_IGNORE_RECOVER_LOCK, cached_only=false)
    at /home/mleich/bb-10.5-thiru/storage/innobase/dict/dict0dict.cc:222
#14 0x00005650b7545648 in dict_table_open_on_id (table_id=25, dict_locked=false, table_op=DICT_TABLE_OP_LOAD_TABLESPACE, thd=0x0, mdl=0x0)
    at /home/mleich/bb-10.5-thiru/storage/innobase/dict/dict0dict.cc:953
#15 0x00005650b74723d6 in trx_resurrect_table_locks (trx=0x1d3d60f7e588, undo=0x252b1ac4fd28)
    at /home/mleich/bb-10.5-thiru/storage/innobase/trx/trx0trx.cc:629
#16 0x00005650b7472ab8 in trx_resurrect (undo=0x252b1ac4fd28, rseg=0x252b1ac4fa78, start_time=1594728365, start_time_micro=522294300743, 
    rows_to_undo=0x7ffffcd60bc8, is_old_insert=false) at /home/mleich/bb-10.5-thiru/storage/innobase/trx/trx0trx.cc:725
#17 0x00005650b7472dbc in trx_lists_init_at_db_start () at /home/mleich/bb-10.5-thiru/storage/innobase/trx/trx0trx.cc:786
#18 0x00005650b7421f80 in srv_start (create_new_db=false) at /home/mleich/bb-10.5-thiru/storage/innobase/srv/srv0start.cc:1556
#19 0x00005650b71ed546 in innodb_init (p=0x5650bab367e8) at /home/mleich/bb-10.5-thiru/storage/innobase/handler/ha_innodb.cc:4001
#20 0x00005650b6d91b57 in ha_initialize_handlerton (plugin=0x5650baa6cd70) at /home/mleich/bb-10.5-thiru/sql/handler.cc:645
#21 0x00005650b6a545fc in plugin_initialize (tmp_root=0x7ffffcd61960, plugin=0x5650baa6cd70, argc=0x5650b86a9e00 <remaining_argc>, argv=0x5650baa2c5f0, 
    options_only=false) at /home/mleich/bb-10.5-thiru/sql/sql_plugin.cc:1459
#22 0x00005650b6a553f0 in plugin_init (argc=0x5650b86a9e00 <remaining_argc>, argv=0x5650baa2c5f0, flags=0)
    at /home/mleich/bb-10.5-thiru/sql/sql_plugin.cc:1751
#23 0x00005650b68f4f09 in init_server_components () at /home/mleich/bb-10.5-thiru/sql/mysqld.cc:4909
#24 0x00005650b68f612b in mysqld_main (argc=45, argv=0x5650baa2c5f0) at /home/mleich/bb-10.5-thiru/sql/mysqld.cc:5492
---Type <return> to continue, or q <return> to quit---
#25 0x00005650b68eb2da in main (argc=44, argv=0x7ffffcd63298) at /home/mleich/bb-10.5-thiru/sql/main.cc:25

ALTER TABLE t1 PAGE_COMPRESSED=1; doesn't do table rebuild. It does write FSP_FLAG in commit_cache_norebuild().

During recovery:
1) InnoDB encounters FILE_CREATE redo log and opens the tablespace with old FSP_FLAG value.
2) Only parsing of redo log has been finished. Now InnoDB tries to load dict_load_table() and tries to compare it with table->flags. If it is not equal then InnoDB should set the tablespace flag by reading page0. But the read of page0 is avoided because of the following code in fsp_flags_try_adjust()

    if (space->full_crc32() || fil_space_t::full_crc32(flags)) {
                return;
     }

3) InnoDb tries to open the table by reading page3 from disk. Page3 has page_compression flag enabled in its page. So it leads to failure of page type validation.

Fix should involve allowing page0 to read when there is a mismatch of full crc32 flags. During that check, use page_compression algorithm.



 Comments   
Comment by Marko Mäkelä [ 2020-07-17 ]

Thank you, thiru! MDEV-16328 in MariaDB 10.3.10 introduced the possibility to enable PAGE_COMPRESSED without rebuilding the table. If you think that this only affects the full_crc32 format, then a simple fix would be to revise alter_options_need_rebuild() so that changing PAGE_COMPRESSED in the full_crc32 format will be refused. We could file a follow-up bug to restore that functionality and to adjust the crash recovery code. (But I would not prioritize that bug, because I think that PAGE_COMPRESSED has very limited practical use.)

Comment by Thirunarayanan Balathandayuthapani [ 2020-07-17 ]

Patch is in bb-10.4-thiru

Comment by Marko Mäkelä [ 2020-07-28 ]

I would like to see a fix that does not modify the function fsp_flags_try_adjust(), which only exists for the purpose of upgrading from buggy MariaDB 10.1 versions (MDEV-11623).

Comment by Marko Mäkelä [ 2020-09-02 ]

I am happy with the logic behind the changes, but I think that we should spend a little more effort to clean up some old code that was originally introduced in 10.1.

Generated at Thu Feb 08 09:20:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.