[MDEV-29566] Failed to read from the .par file upon concurrent DDL/SELECT with partition pruning Created: 2022-09-18 Updated: 2023-11-28 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Partitioning, Storage Engine - InnoDB |
| Affects Version/s: | 10.6, 10.7, 10.8, 10.9, 10.10, 10.11 |
| Fix Version/s: | 10.6, 10.11 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Elena Stepanova | Assignee: | Michael Widenius |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | regression | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
The test case is non-deterministic, run with --repeat=N. It fails for me (without rr) within a few attempts on various build types, but it can vary on different machines. The test is rr-able with --rr=-h, although it takes much longer, set repeat=N to a high value for rr.
The failure started happening (or, if it existed before, its probability hugely increased) after this commit in 10.6.8:
|
| Comments |
| Comment by Marko Mäkelä [ 2022-09-19 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I failed to reproduce this under rr, but I reproduced it easily without rr. The following change would fix this for me:
Even if I revert the above and add STATS_PERSISTENT=0 to one of the table definitions, then the test will not fail either. If we were to apply this code change, then an existing test case could be extended to cover partitioned tables:
I am not convinced that this really is the correct fix. Dropping a partition could fail for other reasons too, and ha_partition::delete_table() should be able to propagate the error to the caller, instead of blindly ignoring it. Based on my quick tests, it appears that ha_partition would correctly handle the failure to drop the very first partition. If the first partition was successfully dropped, it will just assume that the rest will succeed. Even worse, there is no API that would request the storage engine to drop multiple partitions atomically. If some partitions were successfully dropped and some not, we are sort-of lost, because there is no way to reach a consistent state. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-09-26 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
According to monty, handler::delete_table() is currently indeed assumed not to fail as part of ha_partition operations. Based on that, I will proceed with my above fix. That is, if acquiring an exclusive table lock on mysql.innodb_table_stats or mysql.innodb_index_stats fails, ha_innobase::delete_table() will proceed to remove the partition, without attempting to delete the corresponding records from those persistent statistics tables. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-09-27 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
My fix seems to have introduced sporadic test failures:
This could be worked around by disabling InnoDB persistent statistics in all tests of partitioned tables, or by setting innodb_stats_auto_recalc=OFF so that the background task of recomputing statistics would not compete for table locks with ha_innobase::delete_table(). I think that we really need an API that would allow DDL operations on partitioned tables to be executed in an atomic transaction. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-09-27 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I reverted the work-around because of the regression. I think that fixing this involves changing code outside InnoDB. Ideally, all partitioning ALTER TABLE operations should use a single atomic transaction inside the storage engine, so that in the test case of the Description, DROP TABLE t1 would be atomic, as implied or ‘promised’ by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-12-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Some regression tests may also fail due to this bug. Here is one example from buildbot:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-08-16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
While testing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-10-16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The following failure that occasionally occurs in any branch since 10.6 could be related to InnoDB persistent statistics and this design problem:
In MariaDB Server 10.0 to 10.5, the regression test disable InnoDB persistent statistics; see |