Bug #101266 Compression changes in 5.7.32 break backwards compatibility
Submitted: 22 Oct 2020 0:40 Modified: 28 Jan 18:33
Reporter: Marcelo Altmann (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:5.7.32 OS:Any
Assigned to: CPU Architecture:Any

[22 Oct 2020 0:40] Marcelo Altmann
Description:
Changes introduced at https://github.com/mysql/mysql-server/commit/08a0123072f484b59488680a545281066b0d0f4f add a new compression version (v2). 

This breaks backward compatibility and once you have created a compressed page on 5.7.32 you cannot downgrade (minor version) without a crash.

When loading bp at startup:
(gdb) bt
#0  0x00007ffff64b570f in raise () from /lib64/libc.so.6
#1  0x00007ffff649fb25 in abort () from /lib64/libc.so.6
#2  0x00000000007f1abe in ut_dbg_assertion_failed (expr=0x17f9770 "req_type.is_dblwr_recover() || err == DB_SUCCESS", file=<optimized out>, line=5826)
    at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/ut/ut0dbg.cc:75
#3  0x00000000013a1c48 in fil_io (type=..., sync=true, page_id=..., page_size=..., byte_offset=140736473315840, len=16384, buf=0x7fffe03d8000, message=0x7fffdfd078b0)
    at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/fil/fil0fil.cc:5826
#4  0x00000000013584f6 in buf_read_page_low (err=0x7fffc37fbc9c, sync=true, type=192, mode=<optimized out>, page_id=..., page_size=..., unzip=false)
    at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/buf/buf0rea.cc:203
#5  0x0000000001358d6b in buf_read_page_background (page_id=..., page_size=..., sync=<optimized out>) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/buf/buf0rea.cc:491
#6  0x0000000001347b33 in buf_load () at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/buf/buf0dump.cc:689
#7  0x0000000001349155 in buf_dump_thread (arg=<optimized out>) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/buf/buf0dump.cc:787
#8  0x00007ffff7bbc2de in start_thread () from /lib64/libpthread.so.0
#9  0x00007ffff6579e83 in clone () from /lib64/libc.so.6

When executing a query against the table:
(gdb) bt
#0  0x00007ffff64b570f in raise () from /lib64/libc.so.6
#1  0x00007ffff649fb25 in abort () from /lib64/libc.so.6
#2  0x00000000007f1abe in ut_dbg_assertion_failed (expr=0x17f9770 "req_type.is_dblwr_recover() || err == DB_SUCCESS", file=<optimized out>, line=5826)
    at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/ut/ut0dbg.cc:75
#3  0x00000000013a1c48 in fil_io (type=..., sync=true, page_id=..., page_size=..., byte_offset=140736819486528, len=16384, buf=0x7fffe0360000, message=0x7fffdfd04ac0)
    at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/fil/fil0fil.cc:5826
#4  0x00000000013584f6 in buf_read_page_low (err=0x7fffd821e33c, sync=true, type=0, mode=<optimized out>, page_id=..., page_size=..., unzip=false)
    at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/buf/buf0rea.cc:203
#5  0x0000000001358f70 in buf_read_page (page_id=..., page_size=...) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/buf/buf0rea.cc:455
#6  0x000000000133b0e1 in buf_page_get_gen (page_id=..., page_size=..., rw_latch=1, guess=<optimized out>, mode=10, file=0x17d5010 "/export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/include/btr0pcur.ic",
    line=571, mtr=0x7fffd821f250, dirty_with_no_latch=false) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/buf/buf0buf.cc:4207
#7  0x000000000131c14b in btr_cur_open_at_index_side_func (from_left=true, index=0x7fffa4024058, latch_mode=1, cursor=0x7fffa4020498, level=0,
    file=0x17d5010 "/export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/include/btr0pcur.ic", line=571, mtr=0x7fffd821f250)
    at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/btr/btr0cur.cc:2285
#8  0x000000000127cbc6 in btr_pcur_open_at_index_side (from_left=<optimized out>, index=<optimized out>, pcur=0x7fffa4020498, init_pcur=<optimized out>, mtr=<optimized out>, level=0, latch_mode=1)
    at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/include/btr0pcur.ic:571
#9  0x0000000001288743 in row_search_mvcc (buf=0x7fffa40123f8 "\377", mode=PAGE_CUR_G, prebuilt=0x7fffa4020288, match_mode=0, direction=0)
    at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/row/row0sel.cc:5204
#10 0x00000000011955c9 in ha_innobase::index_read (this=0x7fffa4012100, buf=0x7fffa40123f8 "\377", key_ptr=<optimized out>, key_len=0, find_flag=<optimized out>)
    at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/handler/ha_innodb.cc:8766
#11 0x0000000001185be9 in ha_innobase::index_first (this=0x7fffa4012100, buf=0x7fffa40123f8 "\377") at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/handler/ha_innodb.cc:9183
#12 0x0000000001195278 in ha_innobase::rnd_next (this=0x7fffa4012100, buf=0x7fffa40123f8 "\377") at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/handler/ha_innodb.cc:9281
#13 0x00000000008501e6 in handler::ha_rnd_next (this=0x7fffa4012100, buf=0x7fffa40123f8 "\377") at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/sql/handler.cc:2962
#14 0x0000000000cb7b6c in rr_sequential (info=0x7fffa4007448) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/sql/records.cc:517
#15 0x0000000000d25a4a in sub_select (join=0x7fffa4006d18, qep_tab=0x7fffa40073f8, end_of_records=<optimized out>) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/sql/sql_executor.cc:1284
#16 0x0000000000d24f7a in do_select (join=0x7fffa4006d18) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/sql/sql_executor.cc:957
#17 JOIN::exec (this=0x7fffa4006d18) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/sql/sql_executor.cc:206
#18 0x0000000000d902a0 in handle_query (thd=0x7fffa4000d80, lex=0x7fffa4002ef0, result=0x7fffa4006b38, added_options=1, removed_options=0) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/sql/sql_select.cc:191
#19 0x0000000000d50683 in execute_sqlcom_select (thd=0x7fffa4000d80, all_tables=<optimized out>) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/sql/sql_parse.cc:5155
#20 0x0000000000d5413a in mysql_execute_command (thd=0x7fffa4000d80, first_level=true) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/sql/sql_parse.cc:2826
#21 0x0000000000d55c85 in mysql_parse (thd=0x7fffa4000d80, parser_state=<optimized out>) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/sql/sql_parse.cc:5584
#22 0x0000000000d5726e in dispatch_command (thd=0x7fffa4000d80, com_data=0x7fffd8221dc0, command=COM_QUERY) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/sql/sql_parse.cc:1491
#23 0x0000000000d57f84 in do_command (thd=0x7fffa4000d80) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/sql/sql_parse.cc:1032
#24 0x0000000000e2b2ac in handle_connection (arg=<optimized out>) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/sql/conn_handler/connection_handler_per_thread.cc:313
#25 0x0000000001103f14 in pfs_spawn_thread (arg=0x2adf660) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/perfschema/pfs.cc:2197
#26 0x00007ffff7bbc2de in start_thread () from /lib64/libpthread.so.0
#27 0x00007ffff6579e83 in clone () from /lib64/libc.so.6

How to repeat:
 - Start a 5.7.32 server
 - Create a compressed table:
CREATE TABLE t1 (c1 INT) COMPRESSION="zlib";
INSERT INTO t1 VALUES(1);
 - Stop MySQL and start the same datadir on 5.7.31
[22 Oct 2020 5:52] MySQL Verification Team
Hello Marcelo,

Thank you for the report and feedback.
Verified as described.

Thanks,
Umesh
[22 Oct 2020 5:54] MySQL Verification Team
- 5.7.32
rm -rf 101266/
bin/mysqld --initialize-insecure --basedir=$PWD --datadir=$PWD/101266 --log-error-verbosity=3
bin/mysqld --no-defaults --basedir=$PWD --datadir=$PWD/101266 --core-file --socket=/tmp/mysql_ushastry.sock --port=3333 --log-error=$PWD/101266/log.err --log-error-verbosity=3 --secure-file-priv="" --skip-name-resolve --performance-schema=ON 2>&1 &

 bin/mysql -uroot -S /tmp/mysql_ushastry.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.32 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database test;
Query OK, 1 row affected (0.00 sec)

mysql> use test
Database changed
mysql> CREATE TABLE t1 (c1 INT) COMPRESSION="zlib";
Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO t1 VALUES(1);
Query OK, 1 row affected (0.01 sec)

mysql> shutdown;
Query OK, 0 rows affected (0.00 sec)

mysql> \q
Bye

cd ../mysql-5.7.31

bin/mysqld --no-defaults --basedir=$PWD --datadir=/export/umesh/server/binaries/GABuilds/mysql-5.7.32/101266 --core-file --socket=/tmp/mysql_ushastry.sock --port=3333 --log-error=/export/umesh/server/binaries/GABuilds/mysql-5.7.32/101266/log.err --log-error-verbosity=3 --secure-file-priv="" --skip-name-resolve --performance-schema=ON 2>&1 &

[1]+  Aborted                 (core dumped) bin/mysqld --no-defaults --basedir=$PWD --datadir=/export/umesh/server/binaries/GABuilds/mysql-5.7.32/101266 --core-file --socket=/tmp/mysql_ushastry.sock --port=3333 --log-error=/export/umesh/server/binaries/GABuilds/mysql-5.7.32/101266/log.err --log-error-verbosity=3 --secure-file-priv="" --skip-name-resolve --performance-schema=ON 2>&1

(gdb) bt
#0  0x00007fcdb66b9771 in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000802a33 in handle_fatal_signal (sig=6) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/sql/signal_handler.cc:227
#2  <signal handler called>
#3  0x00007fcdb50b25d7 in raise () from /lib64/libc.so.6
#4  0x00007fcdb50b3cc8 in abort () from /lib64/libc.so.6
#5  0x00000000007f1abe in ut_dbg_assertion_failed (expr=0x17f9770 "req_type.is_dblwr_recover() || err == DB_SUCCESS", file=<optimized out>, line=5826)
    at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/ut/ut0dbg.cc:75
#6  0x00000000013a1c48 in fil_io (type=..., sync=true, page_id=..., page_size=..., byte_offset=140520783329824, len=16384, buf=0x7fcda30cc000, message=0x7fcda29ce988)
    at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/fil/fil0fil.cc:5826
#7  0x00000000013584f6 in buf_read_page_low (err=0x7fcd8b5fbcbc, sync=true, type=192, mode=<optimized out>, page_id=..., page_size=..., unzip=false)
    at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/buf/buf0rea.cc:203
#8  0x0000000001358d6b in buf_read_page_background (page_id=..., page_size=..., sync=<optimized out>) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/buf/buf0rea.cc:491
#9  0x0000000001347b33 in buf_load () at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/buf/buf0dump.cc:689
#10 0x0000000001349155 in buf_dump_thread (arg=<optimized out>) at /export/home/pb2/build/sb_0-39489236-1591101761.33/mysql-5.7.31/storage/innobase/buf/buf0dump.cc:787
#11 0x00007fcdb66b4df5 in start_thread () from /lib64/libpthread.so.0
#12 0x00007fcdb517360d in clone () from /lib64/libc.so.6
(gdb)
[28 Jan 18:33] Daniel Price
Posted by developer:
 
The workaround was added to:
https://dev.mysql.com/doc/refman/5.7/en/downgrading-to-previous-series.html#downgrade-inno...
The addition should appear online soon.

Thank you for the bug report.
[28 Jan 18:36] Daniel Price
Posted by developer:
 
"A new compression version used by the InnoDB page compression feature was
added in MySQL 5.7.32. The new compression version is not compatible with
earlier MySQL releases. Creating a page compressed table in MySQL 5.7.32
or higher and accessing the table after downgrading to a release earlier
than MySQL 5.7.32 causes a failure. As a workaround, uncompress such
tables before downgrading. To uncompress a table, run ALTER TABLE tbl_name
COMPRESSION='None' and OPTIMIZE TABLE."