Skip to content

Commit 4cf610d

Browse files
committed
store: Add explicit locking to a migration
For this migration, we need to hold all necessary locks before we start making changes, otherwise concurrent operations can cause deadlocks and abort the migration.
1 parent 6026fe0 commit 4cf610d

File tree

1 file changed

+9
-0
lines changed
  • store/postgres/migrations/2025-05-13-173523_split_subgraph_deployment

1 file changed

+9
-0
lines changed

store/postgres/migrations/2025-05-13-173523_split_subgraph_deployment/up.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2+
-- Grab locks on all tables we are going to touch; otherwise, concurrently
3+
-- running operations might cause deadlocks
4+
lock table subgraphs.subgraph_deployment in access exclusive mode;
5+
lock table subgraphs.subgraph_manifest in access exclusive mode;
6+
lock table subgraphs.subgraph_error in access exclusive mode;
7+
lock table subgraphs.table_stats in access exclusive mode;
8+
lock table subgraphs.copy_state in access exclusive mode;
9+
110
create table subgraphs.head (
211
id int4 primary key,
312
entity_count int8 not null,

0 commit comments

Comments
 (0)