-
-
Notifications
You must be signed in to change notification settings - Fork 909
Open
Labels
Description
Describe the bug
Unable to delete archived tasks retrieved from ListArchivedTasks.
Environment (please complete the following information):
- OS: MacOS,
asynqpackage version v0.25.1- Redis/Valkey version 5.0.12
To Reproduce
Steps to reproduce the behavior (Code snippets if applicable):
- I used ListArchivedTasks to retrieve archived tasks,and then iterated through them to delete each one.
- It returned the error "asynq: FAILED_PRECONDITION: cannot delete task in active state. use CancelProcessing instead," indicating that the task is still active. But the tasks I retrieved were archived tasks, and in debug mode, I can see that the task being deleted has State=TaskStateArchived (5), which is indeed the archived state.
Expected behavior
Success to delete archived tasks retrieved from ListArchivedTasks.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
the function
`func (uc *ClusterOpUsecase) cleanArchivedTasks(ctx context.Context) {
for {
page := 1
pageSize := 100
tasks, err := uc.taskManager.GetInspector().ListArchivedTasks(task.QueueCritical, asynq.Page(page), asynq.PageSize(pageSize))
if err != nil {
log.Fatal(err)
}
for _, taskInfo := range tasks {
taskId, err := strconv.ParseUint(string(taskInfo.Payload), 10, 64)
if err != nil {
continue
}
err = uc.taskManager.GetInspector().DeleteTask(task.QueueCritical, taskInfo.ID)
if err != nil {
uc.logger.WithContext(ctx).Errorf("delete archived task failed: %s", err)
}
}
time.Sleep(1 * time.Minute)
}
}`
Reactions are currently unavailable