Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-24501

Duplicate entry on concurrent content update

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: High High
    • None
    • dev-master
    • Legacy stack
    • 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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            bepla bepla
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: