Deferrable Tasks do not Respect Task Pools #21243
Replies: 10 comments 21 replies
-
I think this is an intended feature, not a bug. It's the matter of assumption/definiton of whether the deferred task takes the pool slot or not. I think (but I would love to hear what others think) this is quite a reasonable assumption that deferred task does not take a slot. Taking into account that the deferred task - by definition takes almost no resources and any external communication is asynchronous and pool feature is designed to limit resources an potentially decrease the loaad/throttle external, mostly synchronous services, I think not taking a pool slot by deferred task is quite reasonable. Does the task take the slot back when it is back from defferred state @ReadytoRocc ? |
Beta Was this translation helpful? Give feedback.
-
@potiuk yes. Once the |
Beta Was this translation helpful? Give feedback.
-
So I'd say it's pretty expected behaviour. I wonder what others think. |
Beta Was this translation helpful? Give feedback.
-
@andrewgodwin @uranusjr - WDYT ? I think the behaviour is intended and maybe just need a bit clarification in the docs. |
Beta Was this translation helpful? Give feedback.
-
This was indeed originally by design, as I saw pools as a "worker/active task slot" system, designed to concurrency-limit things that were running - and of course, deferred tasks are not really running. I think either option here is reasonable, and we could change it to have deferred tasks use up a pool slot if that's the consensus, but I went with this behaviour in the initial feature as it seemed most "sensible". It's probably worth documenting it explicitly, though? |
Beta Was this translation helpful? Give feedback.
-
I agree with @andrewgodwin @ReadytoRocc - is that explanation/behaviour plausible for you ? |
Beta Was this translation helpful? Give feedback.
-
In short: |
Beta Was this translation helpful? Give feedback.
-
@andrewgodwin & @potiuk thank you for the detailed responses and for confirming this behavior is expected. Are we able to convert this An example would be if you want to limit the use of an external service that Airflow is orchestrating. Another would be to limit certain sets of tasks from using all of the triggerer’s resources. Please let me know your thoughts, thanks! |
Beta Was this translation helpful? Give feedback.
-
FYI I am relying on the behavior that given an async operator the trigger task doesn't take up a pool slot but the worker processes does. We have occasional performance issue with lots of processes starting at once (e.g. say we want to start 50 FileSensorAsyncs), but we don't have any performance issues with the triggerer running many trigger tasks. So we put these async operators under a pool and it limits too many starting or stopping all at once. Given the different runtime context of trigger tasks vs. worker processes I feel that if pools applied to both I would want a way to distinguish between them and get different behavior (like we do now) |
Beta Was this translation helpful? Give feedback.
-
I added a PR at #32709 that works for me in some basic testing. It introduces a new flag on |
Beta Was this translation helpful? Give feedback.
-
Apache Airflow version
2.2.3 (latest released)
What happened
When using a deferrable operator, the pool slot is released after the task goes into a state of deferred.
What you expected to happen
I would expect the task to retain the pool slot for the entire execution across the worker and triggerer resources, and only release the pool once it reaches a terminal state.
How to reproduce
Create a DAG the below dag, and a Pool named
async
with a slot count of1
. Let this dag run, and notice that tasks first 16 tasks enterqueued
->running
->deferred
.Operating System
Debian GNU/Linux 11 (bullseye)
Versions of Apache Airflow Providers
No response
Deployment
Other Docker-based deployment
Deployment details
No response
Anything else
No response
Are you willing to submit PR?
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions