J
J
jenya77712019-06-30 10:56:12
PostgreSQL
jenya7771, 2019-06-30 10:56:12

How to do write lock in postgresql sequelize?

Hello, there is a table with records, the records have statuses, 1 and 2 (free and busy). And the cron runs the code, which should take one free record with the free status, and change it to the busy status. And due to the fact that this happens at the same time, one entry gets into the crown in several cycles, and when the status changes to busy, an error occurs that the entry was not found.
How can I make a record lock, or update only one record, with the status free?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitsliputsli, 2019-06-30
@Vitsliputsli

See select for update. Although I did not understand why there is competition if the launch is by krone.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question