From ce781a5d0e9ecec76eda1e2b5b03a3b3e7f2d035 Mon Sep 17 00:00:00 2001 From: Albert Cervera i Areny Date: Thu, 19 Dec 2013 20:58:13 +0100 Subject: [PATCH] Use EXCLUSIVE MODE when locking PostgreSQL tables. Previous implementation used ACCESS EXCLUSIVE MODE (PostgreSQL's default) which does not allow SELECTs on the locked table. This is too pessimistic so it's been replaced by a plain EXCLUSIVE MODE which still blocks INSERTs and UPDATEs but not SELECTs. review1011002 issue2280 --- trytond/backend/postgresql/database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trytond/backend/postgresql/database.py b/trytond/backend/postgresql/database.py index b73ade21e1..ca444cde62 100644 --- a/trytond/backend/postgresql/database.py +++ b/trytond/backend/postgresql/database.py @@ -353,7 +353,7 @@ class Cursor(CursorInterface): return self.cursor.fetchone()[0] def lock(self, table): - self.cursor.execute('LOCK "%s"' % table) + self.cursor.execute('LOCK "%s" IN EXCLUSIVE MODE' % table) def has_constraint(self): return True