[MDEV-9384] Key File Corruption for TokuDB Created: 2016-01-09 Updated: 2023-09-24 Resolved: 2023-09-24 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - TokuDB |
| Affects Version/s: | 10.1.9, 10.1.10 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | John Barratt | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 1 |
| Labels: | tokudb | ||
| Environment: |
Ubuntu 14.04.3 LTS |
||
| Description |
|
We have started to see almost daily corruption of of one of our core tables using TokuDB with FAST compression enabled. These tables are manually partitioned by day, and have 180-200 million rows added each day. A small percentage of these rows are deleted (< 5%), and another portion (< 10%) are updated one or more times through the day. Here is an example table :
We find at some point the table becomes corrupt, and that trying to select from a certain sequence of rows fails and reports the following error :
As I understand it, it isn't possible to repair a tokudb, the only option is to restore from backups. This server isn't currently running with a slave, so I can't verify if a slave would have been corrupted in the same way. The database is running on a pair of mirrored SSDs, and only holds up to 8 days worth of these tables, and some views pointing to these tables. Also of note we have had this problem on 10.1.9 and 10.1.10, and on two different servers running different hardware, with different models of CPU and SSDs, so it doesn't appear to be a hardware issue. One of the servers had ECC memory, and one didn't. I am going to turn of deletions on this table, and just flag rows as deleted to see if that changes the rate of occurrence, or if it fixes it completely, and points to deletion of rows as the problem. My only other anecdotal evidence is that this seems to have only started to happen after we begun doing relatively heavy updates of the data, I don't think it has ever occurred when we were only doing inserts, selects and deletes. Given it is happening only relatively infrequently (We have had 5 tables corrupted over the last week or so this way) and randomly and on such a large dataset, I am not sure how else to try to debug this further, or what other information may be of help, but please let me know what other details may be of assistance in resolving this issue. |
| Comments |
| Comment by John Barratt [ 2016-01-09 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
One other note that may be relevant with regards to the update, is that is a case/when/then statement that is updating 1000 rows at once, each with different values on two integer fields. This is done to be much, much more efficient than 1,000 individual queries (1,000 seemed to be about the sweet spot for this query/table), but it is I would expect a much less commonly used syntax (first time I've ever used it), and hence potentially may be more likely to contain an undiscovered edge case. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-01-11 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Does it always happen on the same table, or on tables with identical/similar structure? Please also paste the template of the update that you identified as a reason of the trouble, and attach your cnf file(s). Thanks. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by John Barratt [ 2016-01-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the followup Elena.
Please let me know if there are any other details I can supply. Thanks, JB. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by John Barratt [ 2016-01-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
EDIT : This actually isn't confirmed, there was still some code running CASE based updates on the table.
Please let me know if there is any other info I can provide. Thanks, JB. - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by John Barratt [ 2016-01-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sorry, one more thing that may further help to pinpoint the corruption, a mysqldump on a 'corrupt' table succeeds OK with no errors reported. However re-importing this data into another database however shows that it has less rows in it than the original corrupt one does. This is around 20k rows out of nearly 200 million. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-01-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
johnbarratt, Thanks. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by John Barratt [ 2016-01-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The resulting dump contains around 200m rows, but 20k less rows than are in the original, corrupted table. The dump file is created just by using mysqldump on the table, so just contains the multi-row insert statements it creates by default. It is loaded into another database just by piping the dump file directly into the database via the mysql command. Thanks, JB. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by John Barratt [ 2016-01-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
So it seems very likely now that the CASE statement is what is inducing the corruption here. I (actually) stopped all CASE based updates nearly 5 days ago now, and since then we haven't had a single corruption of the database. Doing single updates rather than using the CASE statement though is adding additional load and additional delays in updating the data. Please let me know if I can provide any more details. Thanks, JB. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by John Barratt [ 2016-01-18 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
We just had a further corruption whilst using single updates after nearly 6 days of no corruption. So while the use of the CASE statement may not be solely responsible, it appears given the relatively long time with no corruption with just simple updates, that it does induce the issue more regularly. I will have to see if we can swap back to no compression, or even perhaps to innodb to see if that avoids further corruption next. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-01-21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
John Barratt, There is a little problem with your column obfuscation: since it's a key corruption, we need to know on which columns the table has indexes, and now three indexes are indistinguishable. Could you please somehow identify them? Thanks. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by John Barratt [ 2016-01-21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Ahh, sorry, this one should be better. If you need me to send the actual table and some sample data directly to whoever may be investigating, please let me know.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by John Barratt [ 2016-01-21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
As an aside, I am still only doing single updates to the table, and have changed from TOKUDB_FAST to TOKUDB_LZMA compression to see if that makes any difference. So far (since my update a few days ago) there is no corruption, but it is only early days. I can't try no compression, or innodb with the same setup at the moment due to disk space limitations on the server it is running. Thanks, JB. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-01-22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I've been running some test flow with UPDATEs of the same pattern, we'll see how it goes. Thanks. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by John Barratt [ 2016-01-22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Elena,
Please let me know if you need any more info. Thanks, JB | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by John Barratt [ 2016-01-25 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Further quick update to this, we've now had 3 further corruptions in just under 2 days whilst using LZMA compression, and single updates. Two of the corruptions occured within an hour of one another. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by John Barratt [ 2016-05-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Just wanted to check in on this to see if there had been any progress, and give an update. We are still experiencing this issue every few days, and is causing more and more problems for us. Some new information :
Thanks, JB. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Hayden Clark [ 2017-02-01 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hmm. This one has been "open" for a year. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2017-02-01 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Yes, unfortunately the bug has had no action for over half a year because we couldn't create a repeatable test case. Can you provide one? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Hayden Clark [ 2017-02-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
It's a bit tricky. The problem happens occasionally, under heavy load, with very large datasets. Even if scripting a test case was possible, I have no idea what the sensitivity of the bug is. This is really one of those really hard bugs to spot. The actual error may lie in the table or its indexes for days before a query hits the bad patch. How can we proceed with this? What logs can I turn on to diagnose this in the future? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by John Barratt [ 2017-02-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sorry to hear you've got the same problem Hayden, though I am selfishly pleased that there is someone else out there that may be able to help get to the bottom of it. Our situation seems absolutely identical to yours. It has been still happening to us, we have just put in place some work arounds to minimise the impact, as we aren't in a position to be able to downgrade to innodb due to the size of the data and the hardware available. Dumping and recreating the table 'fixes' it with no lost data it seems, it is only the index that is breaking, but that isn't a practical solution. We have tried to keep up with the latest releases of mariadb, but it is still happening to us every few days, even on v10.1.20. One clarification on this, the table this corruption is occurring on is currently write once and forget, ie it is effectively just logging data. The rows are never modified or deleted after insertion, and a new one gets created each day, and gets a new 250million odd rows. Also as before, an identical system with less data (about half the rows, same structure) has never seen this problem, though it has less read load on the data as well. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by dennis [ 2018-03-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I got the same bug in the percona 5.7, and report the bug: But there is no solution now. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2023-09-24 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
TokuDB engine is no longer maintained in MariaDB, and as of 10.5, no longer released. |