[MDEV-26121] [Note] InnoDB: Resetting invalid page [page id: space=5, page number=3] type 17855 to 6. Created: 2021-07-09  Updated: 2021-11-16  Resolved: 2021-11-10

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.6, 10.7
Fix Version/s: 10.6.6, 10.7.2

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Thirunarayanan Balathandayuthapani
Resolution: Fixed Votes: 0
Labels: not-10.4, not-10.5, regression, rr-profile-analyzed

Issue Links:
Problem/Incident
is caused by MDEV-515 innodb bulk insert Closed
is caused by MDEV-24818 Concurrent use of InnoDB table is imp... Closed

 Description   

SET sql_mode='',foreign_key_checks=0,unique_checks=0;
SET GLOBAL innodb_checksum_algorithm=CRC32;
SET SESSION AUTOCOMMIT=OFF;
CREATE TABLE t (c INT) ENGINE=InnoDB;
INSERT INTO t (c) VALUES (0);

Leads to (error log):

10.7.0 57f14eab20ae2733eb341f3d293515a10a40bc48 (Debug)

2021-07-09 19:47:31 4 [Note] InnoDB: Resetting invalid page [page id: space=5, page number=3] type 17855 to 6.

Happens on debug+optimized. 10.6/7 Only.



 Comments   
Comment by Roel Van de Paar [ 2021-08-21 ]

SET sql_mode= '';
SET unique_checks=0;
SET GLOBAL innodb_checksum_algorithm=strict_CRC32;
CREATE TABLE t (c DOUBLE KEY,c2 BINARY (1),c3 TIMESTAMP);
SET foreign_key_checks=0;
INSERT INTO t VALUES ('','',''),('','','');

Leads to:

10.7.0 52505bf20de0ce77a5c0b0a74af021051987bb0d (Debug)

10.7.0-dbg>INSERT INTO t VALUES ('','',''),('','','');
ERROR 1062 (23000): Duplicate entry '0' for key 'PRIMARY'

And:

10.7.0 52505bf20de0ce77a5c0b0a74af021051987bb0d (Debug)

2021-08-21 10:15:09 4 [Note] InnoDB: Resetting invalid page [page id: space=5, page number=3] type 17855 to 6.

Comment by Marko Mäkelä [ 2021-11-01 ]

I am unable to repeat this. What is the call stack of fil_block_reset_type()? You can add a breakpoint or an abort() to the start of the function.

Comment by Marko Mäkelä [ 2021-11-01 ]

As far as I understand, only a call to fil_block_check_type() with the parameter FIL_PAGE_TYPE_SYS should be able to produce such messages. There are a few such calls on database startup, but only for the InnoDB system tablespace.

Comment by Marko Mäkelä [ 2021-11-04 ]

The stack trace definitely points to MDEV-515. The problem happens on the rollback of client disconnect. It was not obvious to me in the description that the client has to be disconnected. A minimal mtr test case (with explicit ROLLBACK instead of an implicit one on disconnect) would have been much more obvious. I can repeat this with the following change to an existing test case:

diff --git a/mysql-test/suite/innodb/t/insert_into_empty.test b/mysql-test/suite/innodb/t/insert_into_empty.test
index 8b885cb5b4f..e903b819928 100644
--- a/mysql-test/suite/innodb/t/insert_into_empty.test
+++ b/mysql-test/suite/innodb/t/insert_into_empty.test
@@ -193,3 +193,16 @@ CREATE TABLE t (i INT) ENGINE=InnoDB PARTITION BY HASH (i) PARTITIONS 2;
 INSERT INTO t VALUES (0);
 INSERT INTO t VALUES (1),(0),(1);
 DROP TABLE t;
+
+--echo #
+--echo # MDEV-26121 Resetting invalid page [... 3] type 17855 to 6
+--echo #
+SET @save_checksum_algorithm= @@GLOBAL.innodb_checksum_algorithm;
+SET GLOBAL innodb_checksum_algorithm=crc32;
+CREATE TABLE t(i INT) ENGINE=InnoDB;
+BEGIN;
+INSERT INTO t VALUES(0);
+ROLLBACK;
+DROP TABLE t;
+
+--echo # End of 10.6 tests
diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc
index ac70923b446..8d4b8f5226b 100644
--- a/storage/innobase/fsp/fsp0fsp.cc
+++ b/storage/innobase/fsp/fsp0fsp.cc
@@ -785,7 +785,7 @@ Any other pages were written with uninitialized bytes in FIL_PAGE_TYPE.
 ATTRIBUTE_COLD
 void fil_block_reset_type(const buf_block_t& block, ulint type, mtr_t* mtr)
 {
-	ib::info()
+	ib::warn()
 		<< "Resetting invalid page " << block.page.id() << " type "
 		<< fil_page_get_type(block.frame) << " to " << type << ".";
 	mtr->write<2>(block, block.frame + FIL_PAGE_TYPE, type);

innodb.insert_into_empty 'debug,innodb'  [ fail ]  Found warnings/errors in server log file!
        Test ended at 2021-11-04 10:00:56
line
2021-11-04 10:00:56 4 [Warning] InnoDB: Resetting invalid page [page id: space=17, page number=3] type 17855 to 6.

I think that the message indeed can be promoted to a warning.

Also the test case variant with a duplicate key error during a multi-row INSERT is executing rollback and issuing the message there.

Comment by Thirunarayanan Balathandayuthapani [ 2021-11-06 ]

In dict_index_t::clear(), InnoDB frees all the page except root page.
root page leaf segment has reset and does reinitialize again.

mtr.memset(root_block, PAGE_HEADER + PAGE_BTR_SEG_LEAF,
               FSEG_HEADER_SIZE, 0);
    if (fseg_create(table->space, PAGE_HEADER + PAGE_BTR_SEG_LEAF, &mtr, false,
                    root_block))

But in fseg_create(), we do have the assumption that only {{FIL_PAGE_TYPE_TRX_SYS or FIL_PAGE_TYPE_TRX_SYS}}page should
be re-created for non-full-crc32 format. IIUC, this assumption is wrong in case of rollback of bulk insert operation.

Generated at Thu Feb 08 09:42:54 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.