Skip to content

Commit

Permalink
avoid lock issues, just wait (or fail) if someone else is modifying t…
Browse files Browse the repository at this point in the history
…he row
  • Loading branch information
dmanchon committed Jun 3, 2024
1 parent 4bf1608 commit 75a6a91
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions guillotina/db/storages/pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ def _wrap_return_count(txt):

# upsert without checking matching tids on updated object
NAIVE_UPSERT = f"""
SET lock_timeout = 5000;
SELECT * FROM {{table_name}} WHERE zoid = $1::varchar({MAX_UID_LENGTH}) FOR UPDATE;
INSERT INTO {{table_name}}
(zoid, tid, state_size, part, resource, of, otid, parent_id, id, type, json, state)
VALUES ($1::varchar({MAX_UID_LENGTH}), $2::bigint, $3::int, $4::int, $5::boolean,
Expand Down

0 comments on commit 75a6a91

Please sign in to comment.