Description:
When the database is being backed up, it happens to encounter the truncate of the undo tablespace, which will cause an exception
My program can get the correct result by running the query " SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME LIKE '%undo%'; ", but it will report an error when running the query " SELECT FILE_ID, tablespace_name, file_name from information_schema.files where file_name like '%undo%'; ".And an error will be reported in the error log [InnoDB] trying to access missing tablespace 423280320.
root@localhost : (none) 11:50:19> SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES WHERE NAME LIKE '%undo%';
+------------+-----------------+------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+------------+--------+
| SPACE | NAME | FLAG | ROW_FORMAT | PAGE_SIZE | ZIP_PAGE_SIZE | SPACE_TYPE | FS_BLOCK_SIZE | FILE_SIZE | ALLOCATED_SIZE | SERVER_VERSION | SPACE_VERSION | ENCRYPTION | STATE |
+------------+-----------------+------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+------------+--------+
| 4294966390 | innodb_undo_001 | 0 | Undo | 16384 | 0 | Undo | 0 | 0 | 0 | 8.0.19 | 1 | N | active |
| 4294966262 | innodb_undo_002 | 0 | Undo | 16384 | 0 | Undo | 0 | 0 | 0 | 8.0.19 | 1 | N | active |
+------------+-----------------+------+------------+-----------+---------------+------------+---------------+-----------+----------------+----------------+---------------+------------+--------+
2 rows in set (0.02 sec)
root@localhost : (none) 11:50:27> SELECT FILE_ID, tablespace_name, file_name from information_schema.files where file_name like '%undo%';
+---------+-----------------+-----------------------------------+
| FILE_ID | TABLESPACE_NAME | FILE_NAME |
+---------+-----------------+-----------------------------------+
| NULL | innodb_undo_001 | /var/lib/mysql/data/undo/undo_001 |
| NULL | innodb_undo_002 | /var/lib/mysql/data/undo/undo_002 |
+---------+-----------------+-----------------------------------+
2 rows in set, 2 warnings (0.01 sec)
Warning (Code 1812): Tablespace is missing for table innodb_undo_001.
Warning (Code 1812): Tablespace is missing for table innodb_undo_002.
error.logļ¼
2021-03-30T11:50:58.507146+08:00 8 [Warning] [MY-012111] [InnoDB] Trying to access missing tablespace 4294966390
2021-03-30T11:50:58.507391+08:00 8 [Warning] [MY-012111] [InnoDB] Trying to access missing tablespace 4294966262
How to repeat:
When MySQL 8.0.19 uses xtrabackup to back up, it occasionally reports an error " Cannot recover a truncated undo tablespace in read-only mode ".
At this time, MySQL query information_schema.file will cause the above error