[MDEV-5552] Deadlock when inserting NULL column value in column with UNIQUE index Created: 2014-01-22 Updated: 2014-03-01 Resolved: 2014-03-01 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 5.5.33a-galera, 5.5.34-galera |
| Fix Version/s: | 5.5.36-galera |
| Type: | Bug | Priority: | Major |
| Reporter: | Justin Warkentin | Assignee: | Nirbhay Choubey (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | galera | ||
| Attachments: |
|
| Description |
|
There is a problem that is consistently causing deadlocks when trying to INSERT or DELETE a row with a NULL value in a column that 1) can be NULL and 2) has a UNIQUE index. I've tested this on MariaDB 5.5.34 and it has this problem. On MySQL 5.5.34 it does NOT seem to have the problem. I narrowed this down to a very simple table setup to reproduce. Simply create a table with the following:
Note that the column type does not matter. It can be VARCHAR or whatever else, so long as it can be NULL and it has a UNIQUE index. Observations: |
| Comments |
| Comment by Sergei Golubchik [ 2014-01-28 ] | |||||||||||||
|
Are you using galera? You've selected 5.5.34-galera as your "affected version", was it intentional, or you've meant 5.5.34 without galera? I've tried the following test case:
And saw no deadlock. Please provide a full test case, not only a table definition. | |||||||||||||
| Comment by Justin Warkentin [ 2014-01-28 ] | |||||||||||||
|
No, it's not galera. I didn't see a 5.5.34 option when I created it. Maybe I just missed it. I changed it now. | |||||||||||||
| Comment by Justin Warkentin [ 2014-01-28 ] | |||||||||||||
|
Also, I don't know what more you want for a "full test case". I provided 3 specific steps you can do to see the issue. It reliably reproduces the deadlock every time for me. I'm not sure what else I can give you. | |||||||||||||
| Comment by Sergei Golubchik [ 2014-01-28 ] | |||||||||||||
|
Thanks for correcting the version. I mean the following — you wrote
but I have tried exactly that (see the INSERT statement above, in my first comment) and did not get a deadlock. Perhaps you used a different form of the INSERT statement. Perhaps your table already had rows and that made a difference. I don't know. This is why I am asking for a complete test case in SQL. Something, I can save to a file and execute as
and it will reproduce the deadlock. | |||||||||||||
| Comment by Justin Warkentin [ 2014-01-28 ] | |||||||||||||
|
I just dropped the test table, put this in a file and ran it:
When I run that it gives me this:
| |||||||||||||
| Comment by Elena Stepanova [ 2014-01-28 ] | |||||||||||||
|
Hi Justin, Please
INSERT INTO deadlock_test VALUES (NULL); Paste the whole unabridged output starting from when you started the client and up to and including the error message. Thanks. | |||||||||||||
| Comment by Justin Warkentin [ 2014-01-28 ] | |||||||||||||
|
Ok, I just did that, but it's really no different. Here's the output:
Is there any other database configuration or system information that may affect this that could be helpful to post? It's running on a Debian server if that matters. Also, here's the specific version info, in case you care:
| |||||||||||||
| Comment by Elena Stepanova [ 2014-01-28 ] | |||||||||||||
|
Justin, Are you able to locate your error log? It should be either in the location where @@log_error variable points, or in the syslog (with mysqld prefix). Please also attach your cnf file(s) or, if it's easier, output of SHOW GLOBAL VARIABLES command. Thanks. | |||||||||||||
| Comment by Justin Warkentin [ 2014-01-28 ] | |||||||||||||
|
Files: 1) Output of `SHOW GLOBAL VARIABLES;` | |||||||||||||
| Comment by Justin Warkentin [ 2014-01-28 ] | |||||||||||||
|
After running that INSERT that deadlocks it dumps this to syslog
| |||||||||||||
| Comment by Elena Stepanova [ 2014-01-28 ] | |||||||||||||
|
Hi Justin, So it turns out you are using Galera after all. If it's unintentional, please remove conf.d/mariadb.cnf file (or move it somewhere outside the config dirs) and restart the server. | |||||||||||||
| Comment by Justin Warkentin [ 2014-01-28 ] | |||||||||||||
|
It's probably not unintentional. I didn't set all this up, it was setup by our IT guys. And seeing as how it's a production environment I probably shouldn't mess with it without understanding what exactly I'm doing. We have a MySQL (not MariaDB) slave setup right now. The MariaDB server is the master. Will changing wresp_provider mess any of that up? | |||||||||||||
| Comment by Elena Stepanova [ 2014-01-28 ] | |||||||||||||
|
It should not affect traditional replication, but if you did not set it up and don't know why it is there, maybe you should not unset it either – it might be that not only do you have it configured, but also there is active Galera-style replication going on. Can you run SHOW STATUS LIKE 'wsrep_cluster_size' and see what it shows? If it says anything but "1", you definitely should not touch it, I'll re-route your request to MariaDB-Galera developers to check if the behavior you observe with the NULL is expected. If cluster size is "1", then there is no Galera-style replication, so you can try to unset wsrep_provider and see if it helps. In any case I suggest you contact your IT guys to find out if they configured it intentionally. | |||||||||||||
| Comment by Justin Warkentin [ 2014-01-28 ] | |||||||||||||
|
Ok, that was not so good. 'wsrep_cluser_size' is set to 1. It just threw an error trying to set it to an empty string, but after a quick google search I set it to 'none'. That just hung (probably this bug https://bugs.launchpad.net/codership-mysql/+bug/1208493) and it brought down our production server. It's all back up now, but I'm going to have the IT guys setup a separate environment for testing. | |||||||||||||
| Comment by Elena Stepanova [ 2014-01-28 ] | |||||||||||||
|
Sorry to hear that. Hopefully while restarting it anyway, you removed wsrep configuration because it really does not do you any good to have all limitations of a Galera cluster without actually having the cluster. | |||||||||||||
| Comment by Justin Warkentin [ 2014-01-28 ] | |||||||||||||
|
Ok, I just tested another stage DB server that was running MariaDB 5.5.33a with galera that also has the same issue (even though it's not replicating anywhere right now). I then removed the mariadb.cnf file to disable galera and restarted the server and it no longer had the deadlock issue. So it's definitely a galera issue. | |||||||||||||
| Comment by Elena Stepanova [ 2014-01-28 ] | |||||||||||||
|
Assigning to Nirbhay to determine whether it's a bug or an known limitation, and proceed accordingly. |