Concurrency Patterns and Conflict
Explore techniques to manage concurrency in PostgreSQL batch updates for the MoMA Collection project. Understand how to use manual locks and the on conflict clause to avoid conflicts when inserting or updating data. This lesson equips you to handle concurrent operations effectively, ensuring seamless database transactions.
We'll cover the following...
We'll cover the following...
Prevention of concurrency patterns conflicts
There are two things that you can do to avoid the problem.
Manual lock
The first thing is to make it so you’re doing only one batch update at any time by building your application around that constraint. A good way to implement that idea is with a manual LOCK command, as explained in the explicit locking documentation part of PostgreSQL:
LOCK TABLE target IN SHARE ROW EXCLUSIVE MODE;
That ...