diff --git a/guillotina/db/storages/pg.py b/guillotina/db/storages/pg.py index e35ff67cb..aba925066 100644 --- a/guillotina/db/storages/pg.py +++ b/guillotina/db/storages/pg.py @@ -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,