Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task always retry when canceled #987

Open
thedmdim opened this issue Dec 16, 2024 · 2 comments
Open

Task always retry when canceled #987

thedmdim opened this issue Dec 16, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@thedmdim
Copy link

Hi everyone!

I need to cancel my task without retry. I call CancelProcessing for this.
CancelProcessing calls task's cancel function. At my handler I do this:

select {
		case <-ctx.Done():
			return asynq.SkipRetry
		case:
				...
}

But this does no effect as far as at processor.go at

select {
			case <-p.abort:
				// time is up, push the message back to queue and quit this worker goroutine.
				p.logger.Warnf("Quitting worker. task id=%s", msg.ID)
				p.requeue(lease, msg)
				return
			case <-lease.Done():
				cancel()
				p.handleFailedMessage(ctx, lease, msg, ErrLeaseExpired)
				return
			case <-ctx.Done():
				p.handleFailedMessage(ctx, lease, msg, ctx.Err())
				return
			case resErr := <-resCh:
				if resErr != nil {
					p.handleFailedMessage(ctx, lease, msg, resErr)
					return
				}
				p.handleSucceededMessage(lease, msg)
}

case <-ctx.Done() read from channel occurs before case resErr := <-resCh

And due to this we have no opportunity to skip retry when publish cancelation, is this right?

@thedmdim thedmdim added the bug Something isn't working label Dec 16, 2024
@kamikazechaser
Copy link
Collaborator

Possibly the same as #968

@thedmdim
Copy link
Author

Fixed this at #988

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants