[MDEV-13498] DELETE with CASCADE constraints takes long time and then crashes the instance with Signal 6 Created: 2017-08-11 Updated: 2020-08-25 Resolved: 2017-08-15 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Delete, Storage Engine - InnoDB |
| Affects Version/s: | 10.2.2, 10.2.7, 10.2 |
| Fix Version/s: | 10.2.8 |
| Type: | Bug | Priority: | Major |
| Reporter: | Claudio Nanni | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
linux |
||
| Attachments: |
|
||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
Running DELETE on a table with a single ROW which causes a cascade constraint to trigger hangs for long time (about 20 minutes in the reported case) and then crashes the instance with:
To reproduce: 1) Import attached dump 2) Execute: DELETE FROM BRc273a13dfda91b1add89; 3) Wait ~20 minutes On 10.1 the same completes successfully in 15 seconds. |
| Comments |
| Comment by Alice Sherepa [ 2017-08-11 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the report!
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2017-08-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There is no need to wait for 20 minutes, we have innodb-fatal-semaphore-wait-threshold=N option (600 seconds by default), if it's set to a lower value, the failure will happen earlier. Also, if you set it to a bigger value, you won't get the failure at all – the query doesn't hang or anything, it's just extremely slow. If it's given enough time, like ~20 min on my machine, it eventually deletes everything and succeeds (it still throws intermediate "long semaphore" warnings with increasing wait, they are just not fatal if the threshold is high). If another connection with READ UNCOMMITTED checks the contents of the referencing tables, it's obvious that the rows keep being deleted. It does have to cascade-delete ~800K rows in two tables, but it's not an excuse for taking 20 minutes – on unaffected versions it finishes in ~1 minute. An MTR-friendly test case is attached. It's pretty much the same test as in the initial attachment, only unrelated tables are removed, the contents re-formatted for MTR, and tables are renamed to t1, t2, t3. Run it with --mysqld=--innodb-fatal-semaphore-wait-threshold=60 to get the failure in reasonable time. The test case can be reduced, but since it takes different time on different builds and machines, it's unclear how much data is safe to remove until the test becomes unreliable. 10.2 is affected, including the latest build. 10.1, 5.5, MySQL 5.6, MySQL 5.7 are not affected.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Claudio Nanni [ 2017-08-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I need to wait around 20 minutes even with default 600 seconds for innodb_fatal_semaphore_wait_threshold.
If you look at the SHOW ENGINE INNODB STATUS just before the crash you see transaction time to be close to real time, semaphore wait being less than real time, but more than 600 seconds:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2017-08-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Right, because the problem, and hence the counting, apparently doesn't start right away, and also timing is not absolutely precise (that is, InnoDB doesn't abort immediately when the timeout is exceeded). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-08-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I did not observe a hang, but only slowness, when running the test case on a debug binary.
pointed me out a very costly std::find() call, in a condition was being evaluated even though the Galera cluster is not enabled!
Even with this patch applied, the test case takes a very long time (several minutes, and counting) on a non-debug server. So, I wonder if further fixes are needed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-08-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
bb-10.2-marko | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-08-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
My observation of the predicate being not only slow but also possibly wrong could explain There was a compilation error in my patch when WITH_WSREP was not enabled. Revised patch on bb-10.2-marko | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2017-08-15 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ok to push with change discussed on slack. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-08-15 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The change that was discussed: pick up the !wsrep_thd_is_BF() condition from Galera MW-369 FK fixes, which was missing from MariaDB 10.2. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Claudio Nanni [ 2017-08-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Now it's much faster on a single instance, but if Galera is enabled it's exactly like before, lasting so long it will eventually render the cluster unusable. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-08-30 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
claudio.nanni, you are right, the Galera logic was not fixed yet. I filed |