Skip to content

Commit

Permalink
MDEV-24848 Assertion rlen<llen failed when applying MEMSET
Browse files Browse the repository at this point in the history
btr_cur_upd_rec_in_place(): Prefer WRITE to MEMSET for a single-byte
operation.

log_phys_t::apply(): Relax the assertion to allow a single-byte MEMSET,
even though it is 1 byte longer than a WRITE record.
  • Loading branch information
dr-m committed Feb 17, 2021
1 parent fc5e03f commit d82386b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
14 changes: 14 additions & 0 deletions mysql-test/suite/mariabackup/row_format_redundant.result
@@ -0,0 +1,14 @@
CREATE TABLE t1 (pk INT PRIMARY KEY, a YEAR UNSIGNED) ENGINE=InnoDB
ROW_FORMAT=REDUNDANT;
INSERT INTO t1 VALUES (1,2021),(2,21),(3,0);
UPDATE t1 SET a = NULL;
# shutdown server
# remove datadir
# xtrabackup move back
# restart
SELECT * FROM t1;
pk a
1 NULL
2 NULL
3 NULL
DROP TABLE t1;
17 changes: 17 additions & 0 deletions mysql-test/suite/mariabackup/row_format_redundant.test
@@ -0,0 +1,17 @@
--source include/have_innodb.inc

--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup

CREATE TABLE t1 (pk INT PRIMARY KEY, a YEAR UNSIGNED) ENGINE=InnoDB
ROW_FORMAT=REDUNDANT;
INSERT INTO t1 VALUES (1,2021),(2,21),(3,0);
UPDATE t1 SET a = NULL;

exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir;
exec $XTRABACKUP --prepare --verbose --target-dir=$targetdir;
--source include/restart_and_restore.inc

rmdir $targetdir;

SELECT * FROM t1;
DROP TABLE t1;
13 changes: 11 additions & 2 deletions storage/innobase/btr/btr0cur.cc
Expand Up @@ -3,7 +3,7 @@
Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2015, 2020, MariaDB Corporation.
Copyright (c) 2015, 2021, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
Expand Down Expand Up @@ -4149,7 +4149,16 @@ void btr_cur_upd_rec_in_place(rec_t *rec, const dict_index_t *index,
}

ut_ad(!index->table->not_redundant());
if (ulint size = rec_get_nth_field_size(rec, n)) {
switch (ulint size = rec_get_nth_field_size(rec, n)) {
case 0:
break;
case 1:
mtr->write<1,mtr_t::MAYBE_NOP>(
*block,
rec_get_field_start_offs(rec, n) + rec,
0U);
break;
default:
mtr->memset(
block,
page_offset(rec_get_field_start_offs(
Expand Down
6 changes: 3 additions & 3 deletions storage/innobase/log/log0recv.cc
Expand Up @@ -2,7 +2,7 @@
Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2020, MariaDB Corporation.
Copyright (c) 2013, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -490,7 +490,7 @@ struct log_phys_t : public log_rec_t
llen= len;
if ((b & 0x70) == MEMSET)
{
ut_ad(rlen < llen);
ut_ad(rlen <= llen);
if (UNIV_UNLIKELY(rlen != 1))
{
size_t s;
Expand All @@ -499,7 +499,7 @@ struct log_phys_t : public log_rec_t
memcpy(frame + last_offset + s, l, llen - s);
}
else
memset(frame + last_offset, *l, llen);
memset(frame + last_offset, *l, llen);
goto next_after_applying_write;
}
const size_t slen= mlog_decode_varint_length(*l);
Expand Down

0 comments on commit d82386b

Please sign in to comment.