Use NOWAIT when locking a table

lock is used to enforce a serializable level for all transaction using on the
same table. This is not achieved if transactions are waiting for the lock
instead of abort and retry with a new transaction because they will still have
the initial transaction row values with the repeatable read level.

issue4373
review5901002
This commit is contained in:
Cédric Krier
2015-01-03 11:37:24 +01:00
parent dcf57d8c33
commit 324d75ec8c
+1 -1
View File
@@ -356,7 +356,7 @@ class Cursor(CursorInterface):
return self.cursor.fetchone()[0]
def lock(self, table):
self.cursor.execute('LOCK "%s" IN EXCLUSIVE MODE' % table)
self.cursor.execute('LOCK "%s" IN EXCLUSIVE MODE NOWAIT' % table)
def has_constraint(self):
return True