Hi team, I'm running into some concurrency issues ...
# ask-community
g
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
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
yep i'm using the
flow.serve
method on a managed k8s cluster
c
ok great! So the main question is: is that error actually killing the running pod?
g
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
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.