I am attempting to the record of a specific Member if it no longer has child records in another table. When I commit the DELETE FROM, I am receiving a Lost Connection or MySQL server has gone away. If I SELECT the same record from the database, I get a valid return. I have included the interaction below:
SELECT m.* FROM Member m LEFT OUTER JOIN MemberAssociation ma ON m.memberID = ma.memberID WHERE m.scanCode = 12345 AND ma.associationCode IS NULL;
/* The expected Member records, which appear to be valid. 2 Rows */
DELETE m.* FROM Member m LEFT OUTER JOIN MemberAssociation ma ON m.memberID = ma.memberID WHERE m.scanCode = 12345 AND ma.associationCode IS NULL;
ERROR 2013 (HY000): Lost connection to MySQL server during query
DELETE m.* FROM Member m LEFT OUTER JOIN MemberAssociation ma ON m.memberID = ma.memberID WHERE m.scanCode = 12345 AND ma.associationCode IS NULL;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 2
Current database: my_database
ERROR 2013 (HY000): Lost connection to MySQL server during query
Is it possible that there is something I can do to fix this problem, or is it more likely that I stumbled across a software bug?
I am running innodb_version: 5.6.19-67.0 and MariaDB version: 10.0.13-MariaDB. The Member table is an InnoDB table.
I have resolved the issue myself and have some recommendations about anyone experiencing something like this in the future.
In my case, MySQL was failing because of a table corruption. I found the error by using the
CHECK TABLE
tool.I then tried to copy the data out, but could not due to a
PRIMARY KEY
issue:Something is wrong obviously.
At this point I did a
mysqldump
and discovered that there was a duplicate for the majority of rows in theMemberAssociation
table. Because this was a development database, I restored the data via the following procedure:Note: On a production system, I would not follow the above procedure. I would recommend copying the data out of the corrupted table into a new table that has no keys and manually cleaning out any duplicates before applying the removed keys and then copying the data back into the original table.