How to retry seriazible transactions Drizzle Orm
Hello everyone,
I'm currently working with Drizzle ORM in a Node.js application and facing challenges handling high concurrency when multiple instances of my program are interacting with the same PostgreSQL database. Specifically, I have multiple processes running that update a scraped status in a URL table. When one process is updating a row, I want the other processes to skip this row and proceed to the next available one instead of trying to update the same row.
However, I'm encountering frequent serialization errors like "could not serialize access due to concurrent update," which cause my programs to crash completely.
Here's a simplified version of how my transaction logic is set up:
Is there a best way to handle retrying when one process is encountering "could not serialize access due to concurrent update"?
Thanks!
1 Reply
Got it working! Looks like there is for lock that is not in the documentation. Just set something up like this: