Revisions have a race condition and can be out of order / conflicting

Created on 5 October 2018, almost 7 years ago
Updated 19 August 2025, 5 days ago

Problem/Motivation

If two processes are acting on the same license at the same time, and both of them save revisions, then the revisions can be created out of order.

If:

  • Process 1 loads license at time=123
  • Process 2 loads license at time=124
  • Process 2 saves license revision at time=126
  • Process 1 saves license revision at time=127

Then the resulting revision table will look like:

revision_id  revision_created  revision_ended
1            124               0
2            123               0

That history would not make sense, because the created dates are out of order, and there are >1 open revisions.

Proposed resolution

Perhaps the best academic solution would be to create pessimistic locks when loading licenses for update.

This solution is a little unrealistic (see the problems with commerce_order locking in πŸ“Œ Improve commerce entities locking Needs review ).

The proposed solution is to prevent saving a license if another revision already exists with a simultaneous or later revision_created timestamp.

πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom pjcdawkins

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024