Problem/Motivation

We have a race condition in \Drupal\content_lock\ContentLock\ContentLock::locking() because the select and merge are separate queries.

Proposed resolution

Either use the lock service to wrap the select and merge in a lock or maybe code to do a merge without a select and then catch the failures when the lock exists already.

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

alexpott created an issue. See original summary.

alexpott’s picture

We can't do the merge idea because merge is implemented as a select and update or insert... so yet another opportunity for races... so we can consider using upsert or using the lock system.

alexpott’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Wasn't sure how to trigger the lock but applying the MR on the site we are using on and locks still appear to be working just fine. So going to lean on that.

alexpott’s picture

I've tried to write a test for this - both low level and and high level - using pcntl_fork() to simultaneously lock via the API and UI neither worked because it is hard to have multiple sessions as the same time in FunctionalTests and separate service instances in kernel tests.

alexpott’s picture

  • alexpott committed a6ce9ee2 on 8.x-2.x
    Issue #3441549 by alexpott: Race condition in \Drupal\content_lock\...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.