Skip to content

Commit b3939a3

Browse files
committed
MDEV-12720 recovery fails with "Generic error" for ROW_FORMAT=compressed
This bug was introduced in the fix of MDEV-12123, which invoked page_zip_write_header() in the wrong way. page_zip_write_header(): Assert that the length is not zero, to be compatible with page_zip_parse_write_header(). btr_root_raise_and_insert(): Update the uncompressed page and then invoke page_zip_write_header() with the correct length.
1 parent d0ce870 commit b3939a3

File tree

4 files changed

+48
-8
lines changed

4 files changed

+48
-8
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# MDEV-12720 recovery fails with "Generic error"
3+
# for ROW_FORMAT=compressed
4+
#
5+
CREATE TABLE a(i INT PRIMARY KEY AUTO_INCREMENT, s VARCHAR(255)) ENGINE=InnoDB
6+
ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
7+
BEGIN;
8+
insert into a(i) select null;
9+
insert into a select null, uuid() from a a, a b, a c;
10+
insert into a select null, uuid() from a a, a b, a c;
11+
insert into a select null, uuid() from a a, a b, a c;
12+
SET GLOBAL innodb_flush_log_at_trx_commit=1;
13+
COMMIT;
14+
SELECT COUNT(*) from a;
15+
COUNT(*)
16+
1010
17+
DROP TABLE a;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--source include/have_innodb.inc
2+
--source include/have_innodb_max_16k.inc
3+
--source include/not_embedded.inc
4+
5+
--echo #
6+
--echo # MDEV-12720 recovery fails with "Generic error"
7+
--echo # for ROW_FORMAT=compressed
8+
--echo #
9+
CREATE TABLE a(i INT PRIMARY KEY AUTO_INCREMENT, s VARCHAR(255)) ENGINE=InnoDB
10+
ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1;
11+
12+
BEGIN;
13+
insert into a(i) select null;
14+
insert into a select null, uuid() from a a, a b, a c;
15+
insert into a select null, uuid() from a a, a b, a c;
16+
insert into a select null, uuid() from a a, a b, a c;
17+
SET GLOBAL innodb_flush_log_at_trx_commit=1;
18+
COMMIT;
19+
20+
--let $shutdown_timeout=0
21+
--source include/restart_mysqld.inc
22+
23+
SELECT COUNT(*) from a;
24+
DROP TABLE a;

storage/innobase/btr/btr0btr.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,10 +1991,9 @@ btr_root_raise_and_insert(
19911991
longer is a leaf page. (Older versions of InnoDB did
19921992
set PAGE_MAX_TRX_ID on all secondary index pages.) */
19931993
if (root_page_zip) {
1994-
page_zip_write_header(
1995-
root_page_zip,
1996-
PAGE_HEADER + PAGE_MAX_TRX_ID
1997-
+ root, 0, mtr);
1994+
byte* p = PAGE_HEADER + PAGE_MAX_TRX_ID + root;
1995+
memset(p, 0, 8);
1996+
page_zip_write_header(root_page_zip, p, 8, mtr);
19981997
} else {
19991998
mlog_write_ull(PAGE_HEADER + PAGE_MAX_TRX_ID
20001999
+ root, 0, mtr);
@@ -2004,10 +2003,9 @@ btr_root_raise_and_insert(
20042003
root page; on other clustered index pages, we want to reserve
20052004
the field PAGE_MAX_TRX_ID for future use. */
20062005
if (new_page_zip) {
2007-
page_zip_write_header(
2008-
new_page_zip,
2009-
PAGE_HEADER + PAGE_MAX_TRX_ID
2010-
+ new_page, 0, mtr);
2006+
byte* p = PAGE_HEADER + PAGE_MAX_TRX_ID + new_page;
2007+
memset(p, 0, 8);
2008+
page_zip_write_header(new_page_zip, p, 8, mtr);
20112009
} else {
20122010
mlog_write_ull(PAGE_HEADER + PAGE_MAX_TRX_ID
20132011
+ new_page, 0, mtr);

storage/innobase/page/page0zip.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4634,6 +4634,7 @@ page_zip_write_header_log(
46344634
#if PAGE_DATA > 255
46354635
# error "PAGE_DATA > 255"
46364636
#endif
4637+
ut_ad(length > 0);
46374638
ut_ad(length < 256);
46384639

46394640
/* If no logging is requested, we may return now */

0 commit comments

Comments
 (0)