Mapping Push Retries is not used instead maxFails is when calculating if max retries reached.

Created on 16 March 2022, over 2 years ago
Updated 26 October 2023, about 1 year ago

Problem/Motivation

In /admin/structure/salesforce/mappings/manage/{mapping} each Mapping has it's own Push Retries limit.

This setting is then used in Drupal\salesforce_push\PushQueue::processQueue() to limit the items retrieved from the salesforce_push_queue table.

      // Claim as many items as we can from this queue and advance our counter.
      // If this queue is empty, move to the next mapping.
      $items = $this->claimItems($mapping->push_limit, $mapping->push_retries);

So any queue items that have more than or equal that many failures will be ignored.

However, in Drupal\salesforce_push\PushQueue::failItem() to determine whether the item has reached the limit of retries it uses the property Drupal\salesforce_push\PushQueue::maxFails to determine if the limit has been reached.
As far as I can tell the maxFails property shouldn't be used if number of retries is configurable for each mapping?

Steps to reproduce

Configure a mapping that will fail to be pushed (missing required data for example) and set the number of Push Retries to 2.
Process the push queue twice. On the second run (if the expire has passed) the queue item will fail again. However, the maxFails will equal the default 10 and during failItem() it will treat it as a temporary failure that should be retried when dispatching the SalesforceErrorEvent. On subsequent push queue runs the item will be skipped as it will have to many failures according to the Mapping Push Retries setting.

Proposed resolution

Use Mapping Push Retries instead of maxFails. I think that maxFails is then unused?

    if ($item->failures >= $mapping->push_retries) {
      $message = 'Permanently failed queue item %item failed %fail times. Exception while pushing entity %type %id for salesforce mapping %mapping. ' . $message;
    }
    else {
      $message = 'Queue item %item failed %fail times. Exception while pushing entity %type %id for salesforce mapping %mapping. ' . $message;
    }

TBH - I would think that it should also dispatch a new SalesforceEvents::PUSH_QUEUE_FAIL_PERMANENT event so that code can catch and handle failed queue items? Currently, we have to catch all the SalesforceEvents::ERROR and inspect the SalesforceExceptionEvent::context to determine if a Push Queue item has reached the limit of retries.

🐛 Bug report
Status

Active

Version

5.0

Component

salesforce_push.module

Created by

🇬🇧United Kingdom altcom_neil

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.

  • 🇬🇧United Kingdom altcom_neil

    Updated version of the patch for 5.0.3

    Still not sure why there are two vars - one configurable per mapping \Drupal\salesforce_mapping\Entity\SalesforceMapping::$push_retries and one that is set during install and as far as I can tell not configurable \Drupal\salesforce_push\PushQueue::$maxFails?

Production build 0.71.5 2024