Hi team,
I'm running into some concurrency issues with prefect subflows and recently got a
RuntimeError: this borrower is already holding one of this CapacityLimiter's tokens
. Any ideas what could be going wrong.
c
Chris White
11/14/2023, 11:13 PM
Could you share more details about your setup?
That error usually arises in one of two places, both of which are related to concurrency limiting the amount of work taking place:
• using a prefect worker with the
--limit
flag
• running flows with
flow.serve
(which uses a default concurrency limit of 5)
g
Gabe Villasana
11/14/2023, 11:14 PM
yep i'm using the
flow.serve
method on a managed k8s cluster
c
Chris White
11/14/2023, 11:14 PM
ok great! So the main question is: is that error actually killing the running pod?
g
Gabe Villasana
11/14/2023, 11:16 PM
hmm it is but only when running locally (not on k8s). I was really curious to see whether this error might help me diagnose some of the other issues i'm having in our production instance around concurrency.
c
Chris White
11/14/2023, 11:18 PM
ok gotcha - i don't believe it's intended to actually abort the process so I will investigate that as a bug.
In the meantime, you can explore the behavior to confirm whether my diagnosis is correct through the environment variable `PREFECT_RUNNER_PROCESS_LIMIT`; it defaults to 5 but feel free to set it to whatever integer you'd like, just be aware that it controls how many subprocesses are running simultaneously so setting it too high risks an OOM or a CPU bottleneck depending on how many flow runs you execute in parallel.
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.