[MDEV-21189] Dropping partition with 'wsrep_OSU_method=RSU' and 'SESSION sql_log_bin = 0' cases the galera node to hang Created: 2019-12-02 Updated: 2019-12-23 Resolved: 2019-12-23 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Galera |
| Affects Version/s: | 10.2.27 |
| Fix Version/s: | 10.2.31, 10.3.22, 10.4.12 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Tomas Mozes | Assignee: | Seppo Jaakola |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Suppose there is a 3 node mariadb galera cluster and an async replicated node connected to it. The galera cluster has a partitioned table that you wish to keep only for a few weeks, while the slave has several months of data in it. Once in a while you have to drop the partitions in the galera cluster without affecting the async slave. On the load-balancer (haproxy): disable traffic to galera1 node. galera1 node) ALTER TABLE db.table DROP PARTITION 201909; And so on for all galera nodes. This way the galera nodes will have the 201909-201911 partitions dropped, while the slave will have the table as before. In some cases the DROP PARTITION statement causes the mariadb process to hang, the operation doesn't end and a new connection cannot be made to the server. Server version 10.2.27. There is nothing in the error log. Galera nodes have the following configuration: wsrep_on=ON binlog_checksum = CRC32 This also happened in version 10.1, but it does not happen all the time. If it happens, only sending kill -9 to mariadb works to stop it. |
| Comments |
| Comment by Jan Lindström (Inactive) [ 2019-12-03 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Can you share output for show create table for the problematic table and error log for at least one node? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tomas Mozes [ 2019-12-03 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Please find attached the table definition and the log from db3b (donor for the broken node db3a) 2019-12-02 9:53:34: tried dropping partitions from db3a (with GLOBAL wsrep_OSU_method='RSU' and SESSION sql_log_bin = 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tomas Mozes [ 2019-12-03 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Seems like a long running process was still running against this database and was writing to the mentioned table. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tomas Mozes [ 2019-12-03 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Steps to reproduce in testing environment (mariadb 10.2.29 with galera 25.3.28):
The node is blocked, cannot connect to it. The log contains:
After doing $(pkill -f mysqld) the process doesn't terminate:
Sending signal 9 means the tables are corrupted and mariadb cannot start and a full sst is probably needed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tomas Mozes [ 2019-12-03 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Just tested with mariadb 10.4.10 and galera 26.4.3. The ALTER is blocked, but at least a new session can be opened and the query terminated. This is in the processlist:
The ALTER won't run and the mysqld process cannot be stopped normally. The error log after trying to shutdown the server:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2019-12-03 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I can't immediately repeat your problem, one thing I noticed that SET GLOBAL wsrep_OSU_method='RSU'; is not effective it does use TOI instead, I must use SET SESSION wsrep_OSU_method='RSU'; to do it on RSU (see my attached test case). Did you check you really used RSU ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tomas Mozes [ 2019-12-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
If I understand the test scenario correctly, it creates the table on node1, populates the data and then drops the partitions, while the second node only drops the partitions. This scenario is different from what causes the issue. How to trigger the hang on node1: It's important that the node on which I'm dropping the partitions and one other node is inserting data into the table in parallel while dropping the partitions. As seen below it's really RSU because it's called in other session before setting the session variable sql_log_bin with dropping the partitions:
If you set a global variable and check it, it will show the old value as seen below (you then close the session and open a new one and it's changed):
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tomas Mozes [ 2019-12-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
https://mariadb.com/kb/en/library/set/
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2019-12-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Is the new data you insert inserted to partitions that are not being dropped ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tomas Mozes [ 2019-12-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Yes, the data are written to the December partition and I'm dropping the August partitions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2019-12-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I retry with 4 node cluster, where nodes 2-4 will execute procedure inserting data to partitions not being dropped and node 1 executes alters, then node by node I execute alters on other nodes (see updated attachments). I still can't repeat the hang. If you have a repeatable test case I could try it would help a lot. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tomas Mozes [ 2019-12-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
You need to keep inserting data on node1 in the moment you are dropping the partitions (in 2 separate sessions on node1). Can you execute commands in parallel with this testing suite? I'm running it on 3 separate virtual machines and with 100% success rate in simulating this issue. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2019-12-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
In node_2 I do send call p1(1000); and similarly nodes 3 and 4, it should then concurrently run those drop partition -clauses in node_1, but there is not much control on that test case so I can only hope that those inserts and alter really run concurrently. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2019-12-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Can you provide output of show processlist when it starts to hang and show engine innodb status. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tomas Mozes [ 2019-12-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
In mariadb 10.2 you cannot open a new session after the hanging alter so I cannot check the processlist nor the innodb engine status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tomas Mozes [ 2019-12-04 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I see the tests are inserting on nodes2-4, but you need to also insert on node1 and call the alter simultaneously. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2019-12-05 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
After adding inserting on node_1 from second connection I got assertion (note this is debug build) see attachment. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tomas Mozes [ 2019-12-05 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Cool, I'm glad it's simulated on your side too | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2019-12-05 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I think I found a fix for your issue. However, there is one thing you should remember on Galera 3 ALTER will take metadata lock (MDL) for whole table, this will effectively restrict inserts from other connections and nodes it does not matter if insert are done to other partitions. If ALTER does not get change to continue (i.e. there can't be other active transactions doing something on same table) it will return a error and same could happen to insert transactions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tomas Mozes [ 2019-12-06 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
What is then the recommended solution for this scenario? Since I wasn't sure what triggered the error I did the following in a rolling fashion on all 3 nodes (to be sure the DROP will pass and the node won't be crippled):
This way the change wasn't propagated to the other nodes and it wasn't written to the binary log either (that's what I wanted). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tomas Mozes [ 2019-12-09 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks Jan, just tried applying the patch from https://github.com/MariaDB/server/commit/59e14b96847e458909ca7fcf95b144fd6ccdb708.patch to 10.2.29 and it works great. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-12-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The test reliably times out on 10.4. Here is one of many examples. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-12-20 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I am raising the priority, because the fix is present in 10.2 and 10.3 branches but not yet in the 10.4 (or 10.5) branch. I think that we should try to include the fix in the next set of releases for all versions. |