Lock table in Postgres to allow reading by other transactions, but disallow writing

Viewed 2339

I'm developing a Django application. There's a functionality where I want to change the database state by reading from, making calculations, and inserting to many tables. This is an atomic procedure, and it can't be only "single-threaded", because the resulting state depends on the order, in which such procedures are executed.

For that I use Celery with a single worker. I thought about SERIALIZED isolation level in Postgres, until I had read:

Serializable transactions is guaranteed to produce the same effect as running them one at a time in some order

But I don't need some, I need the exact order, that's why I chose the message queue.

During the procedure I want to disallow writing to the tables I operate on completely, but still allow reading. What least restrictive LOCK mode suits my case?

1 Answers
Related