Is there a (locking?) mechanism to make mapped tas...
# prefect-community
j
Is there a (locking?) mechanism to make mapped tasks mutually exclusive at runtime? Use case is pulling data for an ETL from multiple sources and wanting to limit one task at a time attempting to insert to a target table. When the tasks run over each other trying to insert to the same table, it causes contention Architecture right now is: gather sources to poll for updates -> map(poll for updates) -> map(insert to db) I suppose one alternate approach would be feeding all the gathered tasks through a grouping task that sets them as upstream/downstream from one another based on target table?
c
There is a concept of locking on an individual tag basic in Prefect Cloud, as described here: https://docs.prefect.io/orchestration/concepts/task-concurrency-limiting.html
👍 1
j
So within core is there a means to this or just in cloud?
c
No, nothing native; locking requires something to manage global state, and Core by itself is effectively stateless
👍 1
j
What about flattening the update query so the inserts all run in sequence?
j
I think something like that is what I'll shoot for. Just need to tinker with the best way to sequence them; I think in asking my question I formulated a potential solution to try
❤️ 1
a
@Jonathan Lowery another option is to use Prefect GraphQL client to run a query to check for running/submitted tasks. I've done this for flows and it works nicely. Not the best solution, because it add some complexity to the code, but it works simple smile Feel free to DM me and I can share more details
👍 1