DB locking for parallel processing?

I have a queue db and I have a process that needs to pick a limited number of records from it and process them. Sometimes, when the queue is large I run multiple processes in parallel. Doing it by either hitting an internal API endpoint with a timeout for request OR with a lambda OR with just multiple tasks - tried all of those.

My question is — what will be the best way to avoid multiple parallel processes to pick the same entries?

Here is what I tried myself:
1. I tried immediately deleting the records that the processes picked so that another process doesn't pick those up. Ended up having this error:[Image]
2. I tried adding a 'status' column to the db and instead of deleting records. Once the process runs it picks up entries that are not in 'processing' status and immidiatly loop-edits them to mark as 'processing' Only after it it actually gets to processing. It seemed to work fine when I had some gap in time between running multiple processes. I think it allowed time for the db records to get updated. When I removed this time gap, things went nuts I ended up spamming users with alerts. 

I've read that some types of databases have a locking mechanism that prevents access when something important is happening. Is there something alike in Xano? Maybe it can help somehow. Or are there any better ways to achieve what I want?

Thanks.

I am still trying to find the best way to run multiple processes in parallel.
Other
6 replies