[MDEV-28951] InnoDB corrupts the database tables Created: 2022-06-27  Updated: 2022-08-30  Resolved: 2022-08-30

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.5.16
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: C N Helkenn Assignee: Marko Mäkelä
Resolution: Incomplete Votes: 0
Labels: None

Attachments: File mysql.err     File mysql.err.old    

 Description   

I have been working with MariaDB since last November; first with 10.6, & now with 10.5.16. I use MariaDB as the internal server for DigiKam photo management software. I was advised by DigiKam support that MariaDB 10.6 was not working with DigiKam 7.4. I read that MariaDB 10.7 was less stable than 10.6 & it was recommended to use 10.5. The full crash of MariaDB in early April caused DigiKam to fail to launch. I managed to completely remove MariaDB 10.6 & do a fresh install of 10.5.16. But all the additions to the database done between Nov & April were lost. Early June I was able to recover from the crash and re-edit the database. It appeared as though 10.5.16 was working well with DigiKam 7.6.0. Today it has crashed again. DigiKam will not launch. The error log says to report this as a bug. So here it is. Please see the attached error logs.

I'm working with Win 10 Pro 64-bit.



 Comments   
Comment by Marko Mäkelä [ 2022-06-27 ]

Both logs show a crash in the function fseg_inode_get(), which was replaced in MDEV-13542. Even though the upcoming 10.6.9 release should be much less likely to crash upon encountering a corrupted page, it will refuse some operations when encountering corruption.

In mysql.err.old there is an early sign of corruption in the following message:

2022-06-16 19:13:04 0 [Note] InnoDB: Completed initialization of buffer pool
2022-06-16 19:13:04 0 [Note] InnoDB: Setting log file .\ib_logfile101 size to 67108864 bytes
2022-06-16 19:13:05 0 [Note] InnoDB: Renaming log file .\ib_logfile101 to .\ib_logfile0
2022-06-16 19:13:06 0 [Note] Recovering after a crash using mysql-bin
Version: '10.5.16-MariaDB-log'  socket: ''  port: 3307  mariadb.org binary distribution
2022-06-16 19:16:17 47 [ERROR] InnoDB: Transaction id 0x241032 associated with recordCOMPACT RECORD(info_bits=0, 3 fields): {[32]c3b1d9070625dc72ccaebfbb59963468(0x6333623164393037303632356463373263636165626662623539393633343638),[8]        (0x800000000507A116),[6]    x+(0x00000003782B)} in index `uniqueHash` of table `digikam`.`uniquehashes` is greater than the global counter 2363055! The table is corrupted.

This suggests that the ib_logfile0 had been deleted before the database was started up. If the server had not been shut down cleanly, discarding the log is a sure way to corrupt the database. MariaDB Server 10.8 or later would refuse normal startup in such a case; see MDEV-27199.

What could have caused the redo log to be disappear before the attempt to start up the server? Note: After the redo log was created and anything written to the data or log files, an older log file cannot be restored without also restoring older data files. The log and the data files are tightly coupled with each other.

Comment by C N Helkenn [ 2022-06-27 ]

All right. I kind of know that the errors have been on going. What I need to know is what to do to fix it. I don't use command line. MariaDB is launched by Digikam, not by any commands I execute. I rely on the DigiKam software to work with MariaDB to manage the database files. I don't make inquiries or delete any files. How can I recover from these file corruptions? What exactly is InnoDB doing that is corrupting the files? I am not a database programmer. I have minimal skills with MariaDB. Your guidance is very much appreciated.

Comment by Marko Mäkelä [ 2022-06-27 ]

cnhelkenn, you’d better ask a developer of DigiKam to comment on this ticket. All that I can say is that for any database whose implementation of ACID depends on write-ahead logging (ARIES), discarding the write-ahead log (also known as redo log, recovery log, mini-transaction log) is a recipe for disaster. So is copying the data directory while the database server is running. For correct backups, you would need a file system snapshot (I do not know if anything on Microsoft Windows would support that) or a special tool, such as mariadb-backup.

I would also be interested to know why anyone would think that the 10.5 series of MariaDB Server might be better in any way than the 10.6 series.

Comment by Elena Stepanova [ 2022-07-25 ]

I would also be interested to know why anyone would think that the 10.5 series of MariaDB Server might be better in any way than the 10.6 series

Quick googling shows that there was at least one incompatibility between DigiKam and MariaDB 10.6 resolved on DigiKam side only in the beginning of this year, so the advise from DigiKam support likely referred to that. I don't know of course whether there are any other problems, known or not. If DigiKam has now lifted the limitation, maybe 10.6 is worth trying again, to see if the crash is resolved by the changes which marko mentioned (maybe after the above-mentioned fix is out with 10.6.9).

Comment by Marko Mäkelä [ 2022-08-01 ]

elenst, thank you. For the record, that incompatibility was apparently caused by some incorrect use of an API in Qt, as noted in MDEV-26271.

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