-
Notifications
You must be signed in to change notification settings - Fork 526
Description
Example scenario:
There is only 1 request in RQ
The request is processed for a long time - it fails twice, and it will pass only on the third attempt.
After each failure, the request is reclaimed.
The problem is that AutoscalePool can go completely rouge and can start burning resources up to the point where it blocks itself due to the system being overloaded.
The root cause is that __is_task_ready_function (which decides whether a new task should be scheduled) is checking if the not await request_manager.is_empty(). Since there is one request in progress and RQ is not empty, this will return True and the AutoscalePool will schedule a new task. The problem is that RQ has no available requests as the only one is already in progress. This will create a situation where new tasks are spawned as fast as possible, only to get no request from RQ.
Preferably, in such scenario __is_task_ready_function should return False, because the RQ should be aware of the fact that the only request available is already being handled. So __is_task_ready_function should return True if there are some available requests and return False if the only requests available are already being processed - but there is no such interface on RQ for this.
Bottom lime not RequestManager.is_empty does not imply __is_task_ready, but our code has this expectation.