[MDEV-9674] Server crash on large transaction combined with multi-update inside stored procedure Created: 2016-03-02 Updated: 2020-10-20 Resolved: 2020-10-20 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Update, Views |
| Affects Version/s: | 10.1.12 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Sander Pilon | Assignee: | Unassigned |
| Resolution: | Incomplete | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
We execute this query
And the server crashes:
The transaction had, at the point of the crash, about 10M undo entries. Table information:
my.cnf
|
| Comments |
| Comment by Elena Stepanova [ 2016-03-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
CrewOne,
for all tables involved in the query. Please also attach your cnf file(s). Thanks. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sander Pilon [ 2016-03-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I'm able to reproduce this, given the same server and same table. The amount of time it takes to crash differs though. If I do the replace into a new empty table - works fine. Can it be that the file itself is corrupt? (That a re-import of the table could fix this?) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-03-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
CrewOne, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sander Pilon [ 2016-03-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I have a (totally unfounded) feeling that this crash is also caused by the interaction of other queries that access the Feeds table. It is quite a "busy" table. I have, and not for the lack of trying, yet to reproduce this outside of the original crash scenario. Trying this outside of the live environment basically means the table is not accessed during that transaction. Anyway - quite a pain, because it prevents me from importing 5M records into a table in a live scenario. I will see and test how long "check table" will run, and maybe run it this evening on the live data. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sander Pilon [ 2016-03-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
It seems to be size-related. (Or time...) If I limit the replace query to 1000000 (1M) - everything works fine. This is on the live table. On copies of that table on the same or antother server, it completes without problems. (Edit) I just ran the query with 1.5M - query itself completes just fine. But the servers crashed when I did 'ROLLBACK'. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-03-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
CrewOne, what about structures of the table that you are updating, and the last joined table (however small)? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sander Pilon [ 2016-03-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Just added the 2 remaining tables. Something curious happened also. I exported the data using SELECT INTO OUTFILE. Which completed 100%, but I assume just before the commit came through - crash. It ran for 25 minutes and using innotop I saw that more or less 100% of the data was complete and then it crashed. Recovery took forever too. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sander Pilon [ 2016-03-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The server is in a habit of crashing multiple times a day now, every time the same backtrace - but not always when we do a large insert. Is there anything we can do to figure out which query is actually crashing? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sander Pilon [ 2016-03-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Actually, we got a new one today...
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-03-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I don't see how this REPLACE statement can possibly cause this stack traces.
The last query printed into the general log from the given connection ID (3267 in the example above) will be the one we are looking for. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sander Pilon [ 2016-03-04 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I hope so.
the crash
And the stored procedure in the last call:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sander Pilon [ 2016-03-04 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
We removed that particular stored procedure and since then we tried to crash it, no such luck. That is good news, but we keep trying. (Edit: We ran a number of succesful imports and the first import we enabled this stored procedure again - it crashed with exactly the same trace and general_log) The connection between that stored procedure and the large (5M rows) insert on another table (see original issue above) however eludes me. They seem totally unrelated, yet the insert almost always results in a crash. Also, the actual commit - which takes 60s - seems to lock about everything.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sander Pilon [ 2016-03-04 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Added the tables involved in the multi-update. (In an attachment file) Also, Elena Stepanova, thanks for the support. You're our hero! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-03-04 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
So, the Managementboek_Boeken.Boeken.table used in the procedure is not the same as the one you are replacing into? I see they have different structure. I also don't see an obvious relation between the REPLACE sandbox and the procedure sandbox. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sander Pilon [ 2016-03-04 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
No they are indeed different. And the table we are inserting into has no triggers, and nothing inserts into the Feeds.Boeken table using triggers. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-03-07 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I'm still struggling to reproduce the crash. Could you please let me know if any of these actions are possible for you? 1)
(or maybe some other argument, but importantly two identical calls one after another) from a fresh MySQL client and see if it causes the crash reliably? 2) 3) 4) 5) I realize that some of these steps are unwanted for a production server, but whatever of the above that you find possible could help us to pinpoint the problem. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sander Pilon [ 2016-03-07 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I can imagine. I will try and see what I can do for you tomorrow. I can tell you this at the moment: That stored procedure is called 1000+ times every day. We have had a lot of server crashes the last months (starting last year) - but we only noticed a reliable pattern when we started doing those large 5M updates. Also, I just tried - calling that stored procedure manually does not crash the server. Not when called twice, not when called 100 times. I might be able to run a debug version sometime late at night, but I tried it last week and it was too slow to handle production traffic. So I can't do that during business hours. (07:00-24:00) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-03-07 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Yes, it's certainly the procedure that causes the crash, everything fits, including two calls in a row – it so happens due to internals of the server that the 2nd execution of a stored procedure or prepared statement is a notoriously weak spot. The crash happens somewhere in optimizer code, which means that it depends on the contents of tables, or rather on the execution plan that the optimizer chooses (which, in turn, depends on the contents of the tables, indexes and such). So, if your test server does not have data identical to the production server, it might also be the reason why you don't observe the problem on the test server. I realize that even if you could provide the data dump, it would be too big, so I'm not asking about it, but SHOW INDEX might help me generate similar artificial data which would make optimizer follow the same code path. Getting execution plan is another approach to the same problem. But of course if you are not getting the crash reliably by executing the procedure, getting EXPLAIN is useless. SHOW INDEX could still be helpful though. There are known ways to make multi-update crash, but none of them 100% matches the query that you have, so you probably have something new. Unfortunately, the visible part of the stack trace is too generic, the most interesting lines would be the upper ones, so it's hard to say what the problem is, exactly. That's how the debug stack trace would help. Finally, regarding a large transaction, that's why I was asking for an unabridged general log – it would be useful to see what else was running at the time of the crash. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sander Pilon [ 2016-03-07 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The test server has more or less the same data - it is a replicated server.
You have to know Bestelling (in the update) is a VIEW for BestellingAll (WHERE Afgerond=1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2020-10-20 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
We have never been able to reproduce this exact failure, but we have other known bugs, either fixed or still open, which involve views, foreign keys and multi-table updates. Without a fully resolved stack trace it is difficult to determine the exact match, but some of them are bound to be related. An example of a still open one would be MDEV-19817 (it's filed as plain SQL test case without stored procedures, but can be converted into stored procedures as well). This group of problems will be further tracked within JIRA items which have ready-to-be-debugged test cases. |