fix(supabase): V1-2.1 take the write budget after the foreign-key locks
This commit is contained in:
1 parent
f80f325fd6
commit
b9470b4d2d
1 file changed
+5
-3
@@ -477,9 +477,10 @@ begin
|
||||
or not exists (select 1 from public.species s where s.id = v_species) then
|
||||
raise exception 'sheet.species_invalid' using errcode = 'P0001';
|
||||
end if;
|
||||
perform private.consume_catalog_write_budget(v_actor);
|
||||
|
||||
v_sheet := private.insert_official_sheet(v_species, v_name, create_official_sheet.slug, v_description, null);
|
||||
-- The budget row last, after the rows the insert locks through its foreign
|
||||
-- keys (species), as every RPC takes it (M4).
|
||||
perform private.consume_catalog_write_budget(v_actor);
|
||||
|
||||
perform private.log_event(
|
||||
v_actor, 'anatomical_sheet.created', 'anatomical_sheet', v_sheet, null, null,
|
||||
@@ -1660,10 +1661,11 @@ begin
|
||||
if v_id is not null then
|
||||
return v_id;
|
||||
end if;
|
||||
perform private.consume_catalog_write_budget(v_actor);
|
||||
insert into public.anatomical_sheet_assets (sheet_id, sha256, byte_size, file_name, created_by)
|
||||
values (sheet_id, sha256, byte_size, file_name, v_actor)
|
||||
returning id into v_id;
|
||||
-- The budget row last, after the sheet row the insert locks through its key.
|
||||
perform private.consume_catalog_write_budget(v_actor);
|
||||
perform private.log_event(
|
||||
v_actor, 'anatomical_sheet_asset.registered', 'anatomical_sheet_asset', v_id, null, null,
|
||||
jsonb_build_object('sheet_id', sheet_id, 'sha256', sha256, 'byte_size', byte_size)
|
||||
|
||||
Reference in new issue
Block a user