Thanks to visit codestin.com
Credit goes to github.com

Skip to content

strange interactions between last_cleaned_at, maintenance_interval and rq:clean_registries lock key #2005

@dams

Description

@dams

Hi,

run_maintenance_tasks runs if should_run_maintenance_tasks returns True.
should_run_maintenance_tasks uses the last_cleaned_at attribute of the worker instance and compare it with maintenance_interval.
However if the worker just started, last_cleaned_at is None and should_run_maintenance_tasks returns True immediately. This could cause should_run_maintenance_tasks to return True too quickly if workers are short-lived
👉 Why not store last_cleaned_at as a redis key with the worker id as prefix?

the maintenance task runs the clean_registries method which takes a lock on queues. However the lock is implemented in a strange way, it's a simple redis key rq:clean_registries:%s with a TTL of 899, but it's never deleted. So the clean_registries cannot run more often than 899 sec, even if the maintenance_interval is smaller
👉 Why not delete the lock once the maintenance task has been done?

Thanks!

cc @tchapi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions