diff --git a/changelog.d/18091.bugfix b/changelog.d/18091.bugfix new file mode 100644 index 000000000..c163b4f9a --- /dev/null +++ b/changelog.d/18091.bugfix @@ -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. diff --git a/synapse/storage/background_updates.py b/synapse/storage/background_updates.py index 34139f580..a02b4cc9c 100644 --- a/synapse/storage/background_updates.py +++ b/synapse/storage/background_updates.py @@ -789,7 +789,7 @@ class BackgroundUpdater: # 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) @@ -814,7 +814,7 @@ class BackgroundUpdater: 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: