Add support for row-level locking (via FOR UPDATE SKIP LOCKED
)
#5983
Labels
domain/client
Issue in the "Client" domain: Prisma Client, Prisma Studio etc.
kind/feature
A request for a new feature.
topic: database-functionality
topic: locking
I have a table that acts as a job queue. I want to read the first row where
processed_at
is null. There can be multiple workers reading from the same table. To ensure only a single worker is processing one job, I can use row-level locking. In postgres, I can do:In 1), it returns the data associated with the job, but still keeps the transaction open. If there is another worker running the same
select
, it would not get back a job withjob_id = 42
.Between 1) and 2), I want to do some work on the server and call
update
only when that work is done. I didn't find a way how this is currently possible with Prisma (I've read the Transaction guide).I imagine this is a significant feature to implement, but is that something on the roadmap?
The text was updated successfully, but these errors were encountered: