Details
-
Bug
-
Resolution: Unresolved
-
High
-
None
-
dev-master
-
None
Description
When concrurrent processes make use of eZContentFunctions::updateAndPublishObject() to update the same object, it results in "Duplicate entry" errors.
It seems to me, the problem comes from the eZContentObject::nextVersion() method :
function nextVersion() { $db = eZDB::instance(); $versions = $db->arrayQuery( "SELECT ( MAX( version ) + 1 ) AS next_id FROM ezcontentobject_version WHERE contentobject_id='$this->ID'" ); return $versions[0]["next_id"]; }
This SQL request returns the same next version number in several concurrent processes. This is normal from a transactional database point of view.
To avoid this problem, we should use "SELECT ... FOR UPDATE" (cf https://dev.mysql.com/doc/refman/5.0/en/innodb-locking-reads.html).
I checked and eZContentObject::nextVersion() is only called in eZContentObject::createNewVersion(). So using "SELECT ... FOR UPDATE" makes sense.
I tried but I experimented SQL deadlocks.
It becomes complicated to debug and fix the problem as there are many complex nested transactions in the corresponding eZ Publish Legacy code.
So I'm sorry I don't provide any fix yet.