Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dstack/_internal/server/migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def run_migrations(connection: Connection):
# lock_timeout is needed so that migrations that acquire locks
# do not wait for locks forever, blocking live queries.
# Better to fail and retry a deployment.
connection.execute(text("SET lock_timeout='10s';"))
connection.execute(text("SET lock_timeout='15s';"))
connection.commit()
context.configure(
connection=connection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.get_context().autocommit_block():
if op.get_context().dialect.name == "postgresql":
# Concurrent index ops can fail midway, leaving invalid indexes behind.
# Use DROP INDEX IF EXISTS so the migration can be retried safely.
op.drop_index(
"ix_compute_groups_pipeline_fetch_q",
table_name="compute_groups",
if_exists=True,
postgresql_concurrently=True,
)
op.drop_index(
"ix_placement_groups_pipeline_fetch_q",
table_name="placement_groups",
if_exists=True,
postgresql_concurrently=True,
)
op.create_index(
"ix_compute_groups_pipeline_fetch_q",
"compute_groups",
Expand Down Expand Up @@ -47,11 +62,13 @@ def downgrade() -> None:
op.drop_index(
"ix_placement_groups_pipeline_fetch_q",
"placement_groups",
if_exists=True,
postgresql_concurrently=True,
)
op.drop_index(
"ix_compute_groups_pipeline_fetch_q",
"compute_groups",
if_exists=True,
postgresql_concurrently=True,
)
# ### end Alembic commands ###