Skip to content

fix: unlock a deferred task so it runs again - #122

Open
david-mccullars wants to merge 1 commit into
apalis-dev:mainfrom
david-mccullars:fix/deferred-task-refetch
Open

david-mccullars wants to merge 1 commit into
apalis-dev:mainfrom
david-mccullars:fix/deferred-task-refetch

Conversation

@david-mccullars

Copy link
Copy Markdown

Description

Closes #121

A task deferred with DeferredError or RetryAfterError goes back to Pending but keeps its worker's lock, so it is never fetched again. The ack now clears the lock when it sends a task back to Pending.

RetryAfterError's delay never reaches the backend, so the task runs again on the next fetch. Honouring the delay would need a change in apalis-core.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Refactoring (no functional changes)

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • I have run the existing tests and they pass
  • I have run cargo fmt and cargo clippy

deferred_task_runs_again defers a task once and expects it to run a second time. On main it times out.

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

A handler that returns DeferredError or RetryAfterError sends the task
back to Pending, but the ack left it locked by the worker that ran it.
fetch_next only takes Pending tasks with no lock, so the task was never
fetched again. The ack now clears the lock when it returns a task to
Pending.

Closes apalis-dev#121

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: A deferred task never runs again

1 participant