From 5a8a8fc9538861f699805db4baddecdb87af5052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 17 Aug 2023 10:31:55 +0300 Subject: [PATCH] MDEV-31928 Assertion xid ... < 128 failed in trx_undo_write_xid() trx_undo_write_xid(): Correct an off-by-one error in a debug assertion. --- mysql-test/suite/innodb/r/innodb-xa.result | 27 +++++++++++++++++ mysql-test/suite/innodb/t/innodb-xa.test | 35 +++++++++++++++++++++- storage/innobase/trx/trx0undo.cc | 2 +- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-xa.result b/mysql-test/suite/innodb/r/innodb-xa.result index 6eae842b14c..6651bd5090d 100644 --- a/mysql-test/suite/innodb/r/innodb-xa.result +++ b/mysql-test/suite/innodb/r/innodb-xa.result @@ -15,3 +15,30 @@ xa prepare 'xid2'; release savepoint `sv1`; xa commit 'xid2'; drop table t1; +# +# MDEV-31928 Assertion xid ... < 128 failed in trx_undo_write_xid() +# +CREATE TABLE t (a INT PRIMARY KEY) ENGINE=INNODB; +XA START 'gtrid_67890123456789012345678901234567890123456789012345678901234','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1234567890' at line 1 +XA START 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_67890123456789012345678901234567890123456789012345678901234',1234567890; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1234567890' at line 1 +XA START 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; +INSERT INTO t VALUES(1); +XA END 'gtrid_67890123456789012345678901234567890123456789012345678901234','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1234567890' at line 1 +XA END 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_67890123456789012345678901234567890123456789012345678901234',1234567890; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1234567890' at line 1 +XA END 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; +XA PREPARE 'gtrid_67890123456789012345678901234567890123456789012345678901234','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1234567890' at line 1 +XA PREPARE 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_67890123456789012345678901234567890123456789012345678901234',1234567890; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1234567890' at line 1 +XA PREPARE 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; +XA COMMIT 'gtrid_67890123456789012345678901234567890123456789012345678901234','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1234567890' at line 1 +XA COMMIT 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_67890123456789012345678901234567890123456789012345678901234',1234567890; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1234567890' at line 1 +XA COMMIT 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; +DROP TABLE t; +# End of 10.4 tests diff --git a/mysql-test/suite/innodb/t/innodb-xa.test b/mysql-test/suite/innodb/t/innodb-xa.test index d94cd75aa14..9eb5848b04d 100644 --- a/mysql-test/suite/innodb/t/innodb-xa.test +++ b/mysql-test/suite/innodb/t/innodb-xa.test @@ -1,6 +1,6 @@ --source include/have_innodb.inc ---disable_abort_on_error +--error ER_XAER_NOTA xa rollback 'xid2'; drop table if exists t1; create table t1(a int)engine=innodb; @@ -9,9 +9,42 @@ xa start 'xid2'; insert into `t1` values (1); savepoint `sv1`; xa end 'xid2'; +--error ER_XAER_RMFAIL start transaction; xa prepare 'xid2'; release savepoint `sv1`; xa commit 'xid2'; drop table t1; +-- echo # +-- echo # MDEV-31928 Assertion xid ... < 128 failed in trx_undo_write_xid() +-- echo # + +CREATE TABLE t (a INT PRIMARY KEY) ENGINE=INNODB; +--error ER_PARSE_ERROR +XA START 'gtrid_67890123456789012345678901234567890123456789012345678901234','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; +--error ER_PARSE_ERROR +XA START 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_67890123456789012345678901234567890123456789012345678901234',1234567890; +XA START 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; + +INSERT INTO t VALUES(1); + +--error ER_PARSE_ERROR +XA END 'gtrid_67890123456789012345678901234567890123456789012345678901234','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; +--error ER_PARSE_ERROR +XA END 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_67890123456789012345678901234567890123456789012345678901234',1234567890; +XA END 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; +--error ER_PARSE_ERROR +XA PREPARE 'gtrid_67890123456789012345678901234567890123456789012345678901234','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; +--error ER_PARSE_ERROR +XA PREPARE 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_67890123456789012345678901234567890123456789012345678901234',1234567890; +XA PREPARE 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; +--error ER_PARSE_ERROR +XA COMMIT 'gtrid_67890123456789012345678901234567890123456789012345678901234','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; +--error ER_PARSE_ERROR +XA COMMIT 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_67890123456789012345678901234567890123456789012345678901234',1234567890; +XA COMMIT 'gtrid_6789012345678901234567890123456789012345678901234567890123','bqual_6789012345678901234567890123456789012345678901234567890123',1234567890; + +DROP TABLE t; + +-- echo # End of 10.4 tests diff --git a/storage/innobase/trx/trx0undo.cc b/storage/innobase/trx/trx0undo.cc index 8768b934dba..917f662eaa5 100644 --- a/storage/innobase/trx/trx0undo.cc +++ b/storage/innobase/trx/trx0undo.cc @@ -665,7 +665,7 @@ trx_undo_write_xid( { DBUG_ASSERT(xid->gtrid_length >= 0); DBUG_ASSERT(xid->bqual_length >= 0); - DBUG_ASSERT(xid->gtrid_length + xid->bqual_length < XIDDATASIZE); + DBUG_ASSERT(xid->gtrid_length + xid->bqual_length <= XIDDATASIZE); mlog_write_ulint(log_hdr + TRX_UNDO_XA_FORMAT, static_cast(xid->formatID),