Skip to content

fix(coderd): remove CREATE INDEX CONCURRENTLY from migrations #8353

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

Merged
merged 1 commit into from
Jul 6, 2023

Conversation

coadler
Copy link
Contributor

@coadler coadler commented Jul 6, 2023

This seems to cause deadlocks with parallel migrations, which is why migrations seem to fail with multiple coderds.

coder-db-1      | 2023-07-06 20:15:04.322 UTC [90] ERROR:  deadlock detected
coder-db-1      | 2023-07-06 20:15:04.322 UTC [90] DETAIL:  Process 90 waits for ExclusiveLock on advisory lock [16384,0,4187539795,1]; blocked by process 89.
coder-db-1      | 	Process 89 waits for ShareLock on virtual transaction 4/15; blocked by process 90.
coder-db-1      | 	Process 90: SELECT pg_advisory_lock($1)
coder-db-1      | 	Process 89: CREATE INDEX CONCURRENTLY workspace_resources_job_id_idx ON workspace_resources USING btree (job_id);
coder-db-1      |
coder-db-1      | 2023-07-06 20:15:04.322 UTC [90] HINT:  See server log for query details.
coder-db-1      | 2023-07-06 20:15:04.322 UTC [90] STATEMENT:  SELECT pg_advisory_lock($1)

Fixes #8210

@coadler coadler self-assigned this Jul 6, 2023
This seems to cause deadlocks with parallel migrations, which is why
migrations seem to fail with multiple coderds.

```
coder-db-1      | 2023-07-06 20:15:04.322 UTC [90] ERROR:  deadlock detected
coder-db-1      | 2023-07-06 20:15:04.322 UTC [90] DETAIL:  Process 90 waits for ExclusiveLock on advisory lock [16384,0,4187539795,1]; blocked by process 89.
coder-db-1      | 	Process 89 waits for ShareLock on virtual transaction 4/15; blocked by process 90.
coder-db-1      | 	Process 90: SELECT pg_advisory_lock($1)
coder-db-1      | 	Process 89: CREATE INDEX CONCURRENTLY workspace_resources_job_id_idx ON workspace_resources USING btree (job_id);
coder-db-1      |
coder-db-1      | 2023-07-06 20:15:04.322 UTC [90] HINT:  See server log for query details.
coder-db-1      | 2023-07-06 20:15:04.322 UTC [90] STATEMENT:  SELECT pg_advisory_lock($1)
```
@coadler coadler force-pushed the colin/fix-parallel-migrations branch from 83a4977 to 21ad562 Compare July 6, 2023 20:51
@coadler coadler requested a review from kylecarbs July 6, 2023 21:03
@coadler coadler merged commit 9a0ba1b into main Jul 6, 2023
@coadler coadler deleted the colin/fix-parallel-migrations branch July 6, 2023 21:44
@github-actions github-actions bot locked and limited conversation to collaborators Jul 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DB migrations fail with multiple Coderd replicas
2 participants