Duplicate entries added to queue for license expiration

Created on 8 March 2017, over 8 years ago
Updated 19 August 2025, 5 days ago

Problem/Motivation

Duplicated items can be created in the queue commerce_license_expiration. And duplicate items update the same license multiple times.

There are cases where we want each license to get expired only once and this issue can be problematic for such cases.

This problem can occur if the worker callback commerce_license_expiration_queue_process() takes a relatively long time compared to commerce_license_cron().

Steps to reproduce:

  1. Enable commerce_license module and rules module.
  2. Add a reaction rule with a process which takes a long time to the event "After updating an existing commerce order".
  3. Create a license which expires and provide it to a user.
  4. Run cron several times after the license's expires.
  5. You can see duplicated items in the queue commerce_license_cron.

Proposed resolution

There are some options.

  • a) Prevent duplicate items from being created.
  • b) Make the queue worker callback idempotent for the license data.

a) is the best if we have a good way to prevent duplicated items but it's basically impossible without using a dirty manner.

So currently b) is the only implementable approach, I think.

FYI, there are some attempts for the unique queue function.

Adopt the approach b) and make the worker callback idempotent for licenses.

Remaining tasks

  • Review the patch

User interface changes

(None)

API changes

(None)

Data model changes

(None)

Original report by nmowat

We had an issue where the same 2 entries for 'commerce_license_expiration' were repeatedly added to the 'queue' table during cron runs.
These 2 entries were failing a custom function to update a Mailchimp subscriber list and as a result were not being processed and removed from the queue. The failure was due to the users to whom these license relate having been deleted from the 'users' table.

The net result of these entries failing processing was that the 'queue' table became over-populated to the point that no subscriptions were being expired.
The patch prevents the addition to the 'queue' table of an pre-existing entry.

πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

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