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

Fix bug where persisting some events fails after unclean shutdown. #18137

Merged
merged 4 commits into from
Feb 5, 2025
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
1 change: 1 addition & 0 deletions changelog.d/18137.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix regression where persisting events in some rooms could fail after a previous unclean shutdown. Introduced in v1.124.0rc1.
14 changes: 12 additions & 2 deletions synapse/storage/databases/state/deletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,18 @@ def __init__(
self.db_pool = database
self._instance_name = hs.get_instance_name()

# TODO: Clear from `state_groups_persisting` any holdovers from previous
# running instance.
with db_conn.cursor(txn_name="_clear_existing_persising") as txn:
self._clear_existing_persising(txn)

def _clear_existing_persising(self, txn: LoggingTransaction) -> None:
"""On startup we clear any entries in `state_groups_persisting` that
match our instance name, in case of a previous unclean shutdown"""

self.db_pool.simple_delete_txn(
txn,
table="state_groups_persisting",
keyvalues={"instance_name": self._instance_name},
)

async def check_state_groups_and_bump_deletion(
self, state_groups: AbstractSet[int]
Expand Down
Loading