I have implemented this into beanstalkd but I think it should also be implemented here in the drupal_queue_cron_run().

This is what I did in beanstalkd and I am wondering this should also be done in drupal queue.

try {
  beanstalkd_log(t("Processing job @id for queue @name", array('@id' => $item->id, '@name' => $item->name)));
  ini_set('display_errors', 0);
  $function($item->data);
  ini_set('display_errors', 1);
  return TRUE;
}
catch (Exception $e) {
  beanstalkd_log(t('Exception caught: @message', array('@message' => $e->getMessage())));
  $queue->releaseItem($item);
  return FALSE;
}

Basically if a job crashes it will release the item so that it can be processed again, which could or could not crash again depending on the error. Most of the time I get out of memory errors so releasing the job to be reprocessed is a good thing.

Gordon

Comments

dave reid’s picture

Status: Active » Closed (won't fix)

Any features need to come directly from Drupal 7 core's queue API. Feel free to re-open and transfer this issue to the core queue for consideration.

Grayside’s picture

Project: Drupal Queue » Drupal core
Version: 6.x-1.2 » 8.x-dev
Component: Code » cron system
Status: Closed (won't fix) » Needs review
StatusFileSize
new586 bytes
new605 bytes

If the item processing callback function returns TRUE, delete the item out of the queue. Otherwise release back to the queue.

Status: Needs review » Needs work

The last submitted patch, 1020954-cron_run_release.patch, failed testing.

Grayside’s picture

Status: Needs work » Needs review
StatusFileSize
new606 bytes

Failed to account for backwards compatibility. Now the return value concept is "TRUE" for the non-standard behavior of leaving the item on the queue for another worker, and no effort needed to delete the item from the queue.

Status: Needs review » Needs work

The last submitted patch, 1020954-4-cron_run_release.patch, failed testing.

Grayside’s picture

Status: Needs work » Needs review
StatusFileSize
new606 bytes

Wrong patch.

Also, leaving additional backport rerolls until this gets farther along.

Status: Needs review » Needs work

The last submitted patch, 1020954-5-cron_run_release.patch, failed testing.

Grayside’s picture

Status: Needs work » Needs review
StatusFileSize
new605 bytes

>.>

gordon’s picture

+++ b/includes/common.inc
@@ -5055,8 +5055,12 @@ function drupal_cron_run() {
+      if ($function($item->data)) {
+        $queue->releaseItem($item);
+      }
+      else {
+        $queue->deleteItem($item);
+      }

This will not work, since the function doesn't return anything to say that it has been successful or not.
How I did it in beanstalk is to have it catch any errors and then release it when an error occurred.

Powered by Dreditor.

gordon’s picture

Status: Needs review » Needs work
Grayside’s picture

Why can't the function return something optionally in order to trigger release behavior? Error catching as a logical flow trigger does not seem a common pattern in Drupal.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jhedstrom’s picture

Version: 8.3.x-dev » 8.4.x-dev
Issue summary: View changes

Using a try/catch pattern, as outlined in the issue summary, in Drupal 8 would be preferable.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for sharing your idea for improving Drupal.

We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Since this was a feature request and there's been no follow up going to close out. Assigning credit for the early patches. This can always be re-opened if so lets get a summary update as well please.

Thanks all.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.