[MDEV-32817] 在最近将版本升级到10.11.5后,针对表进行频繁的读写操作不久后,出现index for table xxxx is corrupt,随后此表tablespace xxxxxx corrupted,最后Tablespace is missing for a table,此表已完全不可用 Created: 2023-11-16 Updated: 2024-02-07 |
|
| Status: | Needs Feedback |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 10.11.5 |
| Fix Version/s: | 10.11 |
| Type: | Bug | Priority: | Critical |
| Reporter: | yangtao | Assignee: | Marko Mäkelä |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
|
| Comments |
| Comment by Daniel Black [ 2023-11-16 ] | ||||||||||||||||||||||||
|
google translate:
Linked is potentially related issue under investigation. | ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-11-16 ] | ||||||||||||||||||||||||
|
The text in the image file image-2023-11-16-15-06-13-780.png
Unfortunately, no progress has been made on MDEV-21978, and therefore this function is not declared with the GCC function attribute printf so that such mismatch could be caught at compilation time. If this is a LP64 platform, sizeof(unsigned long)=sizeof(void*) should hold, so the pointer in fact should be 0xffff94095d08. If this were an LLP64 platform (such as Microsoft Windows), then we should have sizeof(unsigned long)=4 and only the least significant 32 bits of the pointer should have been reported. The pointer looks invalid to me. I would expect functions like malloc() to return at least 16-byte aligned memory, but here the pointer is only aligned to 8 bytes. Which operating system (OS) and instruction set architecture (ISA) does this occur on? Has the system memory been tested? Is the bug repeatable when starting up the database on a copy of this data directory in another environment? If the hardware is fine, the cause of this could also be a memory corruption due to a software bug. | ||||||||||||||||||||||||
| Comment by yangtao [ 2023-11-16 ] | ||||||||||||||||||||||||
|
此现象发生在麒麟操作系统,ARM架构。系统内存有一百多G可用;起初版本是10.11.4,多次出现过表索引损坏的现象,后续发现10.11.5版本修复了很多问题,故将版本升级到此版本后,发现了当前现象(index for table is corrupt => table xxxx in tablespace xxxx corrupted => Tablespace is missing),未发现硬件问题 | ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-11-16 ] | ||||||||||||||||||||||||
|
Thank you. The wrong error message is just an "icing on the cake"; we would need to find the cause of the corruption. 10.11.4 suffered from the bug If you are using FOREIGN KEY constraints, the recently released 10.11.6 would include a fix of Would it be possible to make a logical dump (mariadb-dump or mysqldump) and load it to a newly created MariaDB Server 10.11.6 instance? This would include some corruption bug fixes, such as By starting the server from the scratch, we could be sure that there is no pre-existing corruption in the data files. For example, if the undo logs or the transaction system metadata are in some way corrupted, that could cause trouble. Likewise, there could be some old garbage in the change buffer, even if it was disabled by default for new data already in | ||||||||||||||||||||||||
| Comment by yangtao [ 2023-11-20 ] | ||||||||||||||||||||||||
|
我们再一次复现出index corrupted的问题: 通过日志再次发现同时间点出现的日志: 这次与上次异常打印的日志的时间点都差不多,两次异常相同的操作有:1、当时时间点对此表有大量的读写操作,2、当时时间点有执行过mysqldump进行备份。 | ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-11-20 ] | ||||||||||||||||||||||||
|
The use of mysqldump (or mariadb-dump) could cause a lot of data to be loaded from the file system to the InnoDB buffer pool. If you were using a version that was affected by the race condition bug Unfortunately, it looks like the table really is corrupted. What would the following statement report?
It could be a good idea to execute that for all tables. There is also a separate mariadb-check or mysqlcheck utility for running such commands; see If you do not have a backup of a corrupted table, you could try to dump its contents in multiple parts:
Replace pk with the name of the PRIMARY KEY column, and XXXX with something larger than the latest primary key value that was reported in the previous SELECT. | ||||||||||||||||||||||||
| Comment by yangtao [ 2023-11-20 ] | ||||||||||||||||||||||||
|
执行CHECK TABLE tgom_operation_log EXTENDED后结果如下:
------------------------
------------------------ | ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-11-20 ] | ||||||||||||||||||||||||
|
Is there any more output from the CHECK TABLE statement in the server error log? It is hard to say for sure if this error has been fixed, because we do not know what exactly caused this corruption in the first place. A number of bugs that affect crash recovery and backup have been fixed between 10.11.4 and 10.11.6. A good candidate would be I would suggest to upgrade the server to 10.11.6 and restore everything from a logical dump (create a new data directory). If the corruption still occurs, we would need more details to analyze the root cause. | ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-11-20 ] | ||||||||||||||||||||||||
|
This is a long shot, but MDEV-29832 and MDEV-29610 hint that this could also be a Linux kernel bug. In | ||||||||||||||||||||||||
| Comment by yangtao [ 2023-11-20 ] | ||||||||||||||||||||||||
|
但是我在你给的链接中看到一个关联的 MDEV-32170 看到一个评论:将10.11降级到10.3或10.5就可以完全解决损坏问题,是真的吗 | ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-11-20 ] | ||||||||||||||||||||||||
|
If there is a Linux kernel bug that would explain this corruption, that would likely be in the io_uring interface for which MariaDB implemented support in | ||||||||||||||||||||||||
| Comment by yangtao [ 2023-11-21 ] | ||||||||||||||||||||||||
|
我们编译服务器的时候没有指定,似乎默认就是用libaio | ||||||||||||||||||||||||
| Comment by yangtao [ 2023-11-21 ] | ||||||||||||||||||||||||
|
我们在系统日志中发现我们服务所在盘经常打印VFS: Open an exclusive opened block device for write xxxx ,不知道此是否会有影响呢 | ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-11-21 ] | ||||||||||||||||||||||||
|
Thank you for the update. By default, the MariaDB build scripts use whatever is available. If there is libaio-dev but not liburing-dev installed in the build environment, then the older interface will be used. Because your build used libaio, we can rule out a possible kernel bug that would affect io_uring on ARM. What is your storage layer like? Which file system(s) is the data stored on? Is there any LVM or software RAID? NFS? NAS? You might want to check if reverting to buffered I/O (innodb_flush_method=fsync) would stop the corruption from occurring. The default was changed in danblack, since you are much more familiar with the Linux kernel than me, can you comment on that VFS error message? | ||||||||||||||||||||||||
| Comment by Daniel Black [ 2023-11-22 ] | ||||||||||||||||||||||||
|
Notably this commit isn't in the current Linus kernel. Per the message it is from two open write handles on the same block device. Are you using innodb block devices directly? Any idea what else could be running? A LVM resize is a possibility. Per the commit message it, need not be the cause, but knowing which are the things opening the block device would be good to know. Storage information previously asked for would be quite useful. Which kernel version? | ||||||||||||||||||||||||
| Comment by yangtao [ 2023-11-22 ] | ||||||||||||||||||||||||
|
你好,最近我们在尝试复现,看看此现象出现的必要条件,最新一次在10.11.5版本上又复现, 目前也在相同的方法在10.11.6版本尝试是否能复现~ | ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-11-22 ] | ||||||||||||||||||||||||
|
1406921854@qq.com, thank you, and good luck with narrowing this down. Currently I would suspect a bug in the kernel version that you are using, but we will see how it turns out. | ||||||||||||||||||||||||
| Comment by yangtao [ 2023-11-22 ] | ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-11-22 ] | ||||||||||||||||||||||||
|
The 18446744073709551615 in screenshot-2.png | ||||||||||||||||||||||||
| Comment by yangtao [ 2023-11-23 ] | ||||||||||||||||||||||||
|
目前我们将版本降级到10.3.39版本,以相同的方法复现,运行了接近1天,未曾复现此问题 | ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-11-23 ] | ||||||||||||||||||||||||
|
Thank you. Is the problem reproducible in 10.11.6 you configure innodb_flush_method=fsync? The recent new default O_DIRECT ( | ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-12-05 ] | ||||||||||||||||||||||||
|
If you run MariaDB Server 10.3.39 with innodb_flush_method=O_DIRECT, will you experience similar corruption? The Linux kernel bug that was behind | ||||||||||||||||||||||||
| Comment by yangtao [ 2023-12-05 ] | ||||||||||||||||||||||||
|
当前我们一直用的是10.3.39版本 innodb_flush_method=fsync;验证了多次,未曾复现当前问题 | ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2024-01-09 ] | ||||||||||||||||||||||||
|
Would MariaDB Server 10.3.39 start to corrupt data when you set the parameter innodb_flush_method=O_DIRECT? Would MariaDB Server 10.11.6 avoid data corruption if you set innodb_flush_method=fsync? |