Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change psql concurrency from autocommit to serializable. #1190

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions nipap/nipap/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,10 @@ def remove_vrf(self, auth, spec):
self.remove_prefix(auth, spec = v6spec, recursive = True)

where, params = self._expand_vrf_spec(spec)
sql = "DELETE FROM ip_net_vrf WHERE %s" % where
sql = """LOCK TABLE ip_net_plan IN EXCLUSIVE MODE;
LOCK TABLE ip_net_vrf IN EXCLUSIVE MODE;
LOCK TABLE ip_net_pool IN EXCLUSIVE MODE;
DELETE FROM ip_net_vrf WHERE %s""" % where
self._execute(sql, params)

# write to audit table
Expand Down Expand Up @@ -1875,7 +1878,10 @@ def remove_pool(self, auth, spec):
pools = self.list_pool(auth, spec)

where, params = self._expand_pool_spec(spec)
sql = "DELETE FROM ip_net_pool AS po WHERE %s" % where
sql = """LOCK TABLE ip_net_plan IN EXCLUSIVE MODE;
LOCK TABLE ip_net_vrf IN EXCLUSIVE MODE;
LOCK TABLE ip_net_pool IN EXCLUSIVE MODE;
DELETE FROM ip_net_pool AS po WHERE %s""" % where
self._execute(sql, params)

# write to audit table
Expand Down Expand Up @@ -3095,7 +3101,10 @@ def _db_remove_prefix(self, spec, recursive = False):
else:
where, params = self._expand_prefix_spec(spec)

sql = "DELETE FROM ip_net_plan AS p WHERE %s" % where
sql = """LOCK TABLE ip_net_plan IN EXCLUSIVE MODE;
LOCK TABLE ip_net_vrf IN EXCLUSIVE MODE;
LOCK TABLE ip_net_pool IN EXCLUSIVE MODE;
DELETE FROM ip_net_plan AS p WHERE %s""" % where
self._execute(sql, params)


Expand Down Expand Up @@ -3934,7 +3943,10 @@ def remove_asn(self, auth, asn):

# remove
where, params = self._expand_asn_spec(asn)
sql = "DELETE FROM ip_net_asn WHERE " + where
sql = """LOCK TABLE ip_net_plan IN EXCLUSIVE MODE;
LOCK TABLE ip_net_vrf IN EXCLUSIVE MODE;
LOCK TABLE ip_net_pool IN EXCLUSIVE MODE;
DELETE FROM ip_net_asn WHERE """ + where
self._execute(sql, params)

# write to audit table
Expand Down