contao/core — Issue #3682: Contao crashes when trying to create undo statement
Author: hschottm
Created: 2011-12-09 17:08:29+00:00
State: open

With very large data structures it can happen that the MySQL server dies with a 'MySQL server has gone away'. This happens when Contao tries to store a delete statement (in my case a category containing 1100 literature entries) in the tl_undo table

(DC_Table.php, line 1312/1313):
$objUndoStmt = $this->Database->prepare("INSERT INTO tl_undo (pid, tstamp, fromTable, query, affectedRows, data) VALUES (?, ?, ?, ?, ?, ?)")->execute($this->User->id, time(), $this->strTable, 'DELETE FROM '.$this->strTable.' WHERE id='.$this->intId, $affected, serialize($data));

Ideed the statement is quite large (about 1.6 MB). As a result of crashing with the undo statement, the delete action will not be executed. Though it is not a Contao problem but a problem with the MySQL connector I assume, it would be great to take some action because it seems to happen very often with a large amount of data.
I tried to execute the statement in a third party tool on the Mac (SequelPro) and it ran through in about 100 ms without any problems. So obviously the PHP php_mysql module is a problem here.

Maybe it is possible to split large statements into multiple smaller statements to prevent the problem.

I can provide you with my initial statement if you want to try to reproduce this behavior. Maybe it is OS dependent.