[MDEV-32833] InnoDB wrong error message Created: 2023-11-18  Updated: 2023-11-29  Resolved: 2023-11-29

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB, Tests
Affects Version/s: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0, 11.1, 11.2, 11.3
Fix Version/s: 10.4.33, 10.5.24, 10.6.17, 10.11.7, 11.0.5, 11.1.4, 11.2.3, 11.3.2

Type: Bug Priority: Major
Reporter: Kristian Nielsen Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: None


 Description   

This is seen as a random test failure of innodb.innodb-page_compression_tables in Buildbot when run immediately after innodb.foreign-keys:

./mtr --mem innodb.foreign-keys innodb.innodb-page_compression_tables --no-reorder
 
innodb.innodb-page_compression_tables 'innodb' w28 [ fail ]
        Test ended at 2023-10-26 18:55:52
 
CURRENT_TEST: innodb.innodb-page_compression_tables
--- /home/buildbot/amd64-ubuntu-2204-debug-ps/build/mysql-test/suite/innodb/r/innodb-page_compression_tables.result	2023-10-26 18:43:16.000000000 +0000
+++ /home/buildbot/amd64-ubuntu-2204-debug-ps/build/mysql-test/suite/innodb/r/innodb-page_compression_tables.reject	2023-10-26 18:55:50.424016588 +0000
@@ -8,7 +8,7 @@
 Level	Code	Message
 Warning	140	InnoDB: PAGE_COMPRESSED table can't have ROW_TYPE=COMPRESSED
 Error	1005	Can't create table `test`.`innodb_compressed` (errno: 140 "Wrong create options")
-Warning	1030	Got error 140 "Wrong create options" from storage engine InnoDB
+Warning	1296	Got error 140 '`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`)' from InnoDB
 show create table innodb_compact;
 Table	Create Table
 innodb_compact	CREATE TABLE `innodb_compact` (
@@ -27,7 +27,7 @@
 Level	Code	Message
 Warning	140	InnoDB: PAGE_COMPRESSED table can't have ROW_TYPE=REDUNDANT
 Error	1005	Can't create table `test`.`innodb_redundant` (errno: 140 "Wrong create options")
-Warning	1030	Got error 140 "Wrong create options" from storage engine InnoDB
+Warning	1296	Got error 140 '`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f2`) REFERENCES `t1` (`f1`)' from InnoDB
 create table innodb_redundant(c1 bigint not null, b char(200)) engine=innodb row_format=redundant;
 show create table innodb_redundant;
 Table	Create Table
 
mysqltest: Result length mismatch

A simpler testcase shows the problem:

--source include/have_innodb.inc
 
CREATE TABLE t1(f1 INT NOT NULL PRIMARY KEY, f2 INT NOT NULL)ENGINE=InnoDB;
CREATE TABLE t2(f1 VARCHAR(100), f2 INT NOT NULL, INDEX(f2))ENGINE=InnoDB;
ALTER TABLE t2 ADD FOREIGN KEY(f2) REFERENCES t1(f1);
--error ER_NO_REFERENCED_ROW_2
INSERT INTO t2 VALUES('G', 3);
 
--error 1005
create table innodb_compressed(c1 bigint not null, b char(200)) engine=innodb row_format=compressed page_compressed=1;
show warnings;
 
DROP TABLE t2, t1;

The incorrect warning in the SHOW WARNINGS after the CREATE TABLE comes from trx->detailed_error. This is set by the failing INSERT, and errorneously does not get cleared before the error is thrown from CREATE TABLE. Thus, the old message is wrongly shown as part of the SHOW WARNINGS.

I'm not sure where the best place would be to clear the trx->detailed_error, so assigning to you Marko in case you know.

The bug probably isn't very critical from a user point of view, but it would be really good to get the random test failure fixed. So if we cannot get the underlying bug fixed quickly, I suggest to leave this bug open but fix the test case to not fail randomly (which is simple, just run a successful SELECT or something to clear the trx->detailed_error).



 Comments   
Comment by Marko Mäkelä [ 2023-11-29 ]

The trx_t::detailed_error was originally introduced in a fix of MySQL Bug #3443. The apparent intention was to make this string empty at the start of every statement. Because ha_innobase::start_stmt() will not be invoked for DDL statements, the previous error string would not be cleared.

I think that the simplest fix of this is to clear the trx_t::detailed_error string in trx_t::commit_in_memory().

Generated at Thu Feb 08 10:34:22 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.