[GH-ISSUE #711] [Question] How to remove completed tasks automatically from redis? #2373

Open
opened 2026-03-15 20:17:12 +03:00 by kerem · 3 comments
Owner

Originally created by @diptomondal007 on GitHub (Jul 30, 2023).
Original GitHub issue: https://github.com/hibiken/asynq/issues/711

It seems asynq tasks aren't being removed from redis which is making the redis memory full
I tried to get the TTL for a key and it's returning -1 which means it will never be expired. How to set TTL for a task?

Originally created by @diptomondal007 on GitHub (Jul 30, 2023). Original GitHub issue: https://github.com/hibiken/asynq/issues/711 It seems asynq tasks aren't being removed from redis which is making the redis memory full I tried to get the TTL for a key and it's returning -1 which means it will never be expired. How to set TTL for a task?
Author
Owner

@kamikazechaser commented on GitHub (Jul 31, 2023):

The GC is done internally. Set asynq.Retention when submitting tasks.

<!-- gh-comment-id:1657885095 --> @kamikazechaser commented on GitHub (Jul 31, 2023): The GC is done internally. Set [`asynq.Retention`](https://pkg.go.dev/github.com/hibiken/asynq?utm_source=godoc#Retention) when submitting tasks.
Author
Owner

@diptomondal007 commented on GitHub (Aug 12, 2023):

I have set asynq.Retention while enqueueing but the memory is still growing so the key number. Is that because of tasks being archived and not being deleted for 90 days? @kamikazechaser

<!-- gh-comment-id:1676091778 --> @diptomondal007 commented on GitHub (Aug 12, 2023): I have set [asynq.Retention](https://pkg.go.dev/github.com/hibiken/asynq?utm_source=godoc#Retention) while enqueueing but the memory is still growing so the key number. Is that because of tasks being archived and not being deleted for 90 days? @kamikazechaser
Author
Owner

@kamikazechaser commented on GitHub (Aug 14, 2023):

Archived tasks are different from completed tasks. The Retention option will successfully remove the completed ones.

Btw you can also use the inspector manually to delete tasks in various states manually in your own periodic go routiune.

<!-- gh-comment-id:1676656528 --> @kamikazechaser commented on GitHub (Aug 14, 2023): [Archived tasks are different](https://github.com/hibiken/asynq/wiki/Life-of-a-Task) from completed tasks. The Retention option will successfully remove the completed ones. Btw you can also use the [inspector](https://pkg.go.dev/github.com/hibiken/asynq?utm_source=godoc#Inspector) manually to delete tasks in various states manually in your own periodic go routiune.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#2373
No description provided.