Skip to content
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

Drop indices concurrently on background updates #18091

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions changelog.d/18091.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix rare race where on upgrade to v1.22.0 a long running database upgrade could lock out new events from being received or sent.
4 changes: 2 additions & 2 deletions synapse/storage/background_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ def create_index_psql(conn: "LoggingDatabaseConnection") -> None:
# we may already have a half-built index. Let's just drop it
# before trying to create it again.

sql = "DROP INDEX IF EXISTS %s" % (index_name,)
sql = "DROP INDEX CONCURRENTLY IF EXISTS %s" % (index_name,)
logger.debug("[SQL] %s", sql)
c.execute(sql)

Expand All @@ -814,7 +814,7 @@ def create_index_psql(conn: "LoggingDatabaseConnection") -> None:

if replaces_index is not None:
# We drop the old index as the new index has now been created.
sql = f"DROP INDEX IF EXISTS {replaces_index}"
sql = f"DROP INDEX CONCURRENTLY IF EXISTS {replaces_index}"
logger.debug("[SQL] %s", sql)
c.execute(sql)
finally:
Expand Down
Loading