You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Purge Room API fails to remove all rows from state_groups_state #6566
Furthermore, multiple attempts to purge !QtykxKocfZaZOUrTwp:matrix.org fail to remove any rows, even as each attempt indicates success. There are more than 4 million!
I assume it has managed to remove all the rows from state_groups?
The problem is that state_groups_state lacks an index on room_id so we can't just delete the rows from state_groups_state; instead we look up the state groups to delete from state_groups and then delete the relevant groups.
So that explains why it still doesn't do anything on a second attempt. What it doesn't explain is why it fails on the first attempt. There are two possibilities:
the relevant state groups lack entries in state_groups for some reason, so we don't know that we have to purge the rows from state_groups_state
the purge transaction got as far as deleting the rows from state_groups, but then failed to remove the rows from state_groups_state.
Logs from the first purge attempt would be useful in determining which of these is the problem.
For case (b) (the rows have gone from state_groups but there are still orphaned rows in state_groups_state), you might be able to build a list of such rows with a SELECT query and then run a series of DELETEs.
I have rows for both ostensibly-purged rooms in state_groups, but a comparatively trivial number: only 365 for !PcCidzjUKXHKImhTrB:matrix.org, and 1531 for '!QtykxKocfZaZOUrTwp:matrix.org'. I'll try Erik's tool, thanks! From the warning, I gather it's safe to run deletes for orphaned rooms, or when synapse is shut down, but generally not for live rooms when synapse is running?
For all victims of the spam wave in «Matrix HQ»: Using synapse-find-unreferenced-state-groups (still) works!
After closing down Matrix HQ (!OGEhHVWSdvArJzumhm:matrix.org) using Synapse Admin on my homeserver, I was left with 2.5M rows for this room in the state_groups_state stable. Using synapse-find-unreferenced-state-groups deleted all of those. Did not shut down Synapse while doing so, as the room got deleted before already.
I'm seeing about 700K rows in current_state_delta_stream and more than 40M rows in state_groups_state for rooms that should have been purged (ref. #12730). At some point purging failed because of a serialization error.
Unfortunately, synapse-find-unreferenced-state-groups doesn't seem to work. I can delete the rows manually, but I don't know exactly what tables I should be looking at.
Activity
Ralith commentedon Dec 18, 2019
Furthermore, multiple attempts to purge
!QtykxKocfZaZOUrTwp:matrix.orgfail to remove any rows, even as each attempt indicates success. There are more than 4 million!richvdh commentedon Dec 24, 2019
I assume it has managed to remove all the rows from
state_groups?The problem is that
state_groups_statelacks an index onroom_idso we can't just delete the rows fromstate_groups_state; instead we look up the state groups to delete fromstate_groupsand then delete the relevant groups.So that explains why it still doesn't do anything on a second attempt. What it doesn't explain is why it fails on the first attempt. There are two possibilities:
state_groupsfor some reason, so we don't know that we have to purge the rows fromstate_groups_statestate_groups, but then failed to remove the rows fromstate_groups_state.Logs from the first purge attempt would be useful in determining which of these is the problem.
richvdh commentedon Mar 17, 2020
closing this pending the information needed to investigate.
Ralith commentedon Mar 17, 2020
What recourse is available for cleaning up the millions of orphaned rows?
richvdh commentedon Jul 9, 2020
@Ralith : are the orphaned rows in question in (a)
state_groupsor (b)state_groups_state?For case (a), https://github.com/erikjohnston/synapse-find-unreferenced-state-groups is a thing that helps find unreferenced state groups and clear them out.
For case (b) (the rows have gone from
state_groupsbut there are still orphaned rows instate_groups_state), you might be able to build a list of such rows with aSELECTquery and then run a series ofDELETEs.Ralith commentedon Jul 9, 2020
I have rows for both ostensibly-purged rooms in
state_groups, but a comparatively trivial number: only 365 for!PcCidzjUKXHKImhTrB:matrix.org, and 1531 for'!QtykxKocfZaZOUrTwp:matrix.org'. I'll try Erik's tool, thanks! From the warning, I gather it's safe to run deletes for orphaned rooms, or when synapse is shut down, but generally not for live rooms when synapse is running?richvdh commentedon Jul 9, 2020
yes.
rettichschnidi commentedon Jun 29, 2021
For all victims of the spam wave in «Matrix HQ»: Using synapse-find-unreferenced-state-groups (still) works!
After closing down Matrix HQ (!OGEhHVWSdvArJzumhm:matrix.org) using Synapse Admin on my homeserver, I was left with 2.5M rows for this room in the state_groups_state stable. Using synapse-find-unreferenced-state-groups deleted all of those. Did not shut down Synapse while doing so, as the room got deleted before already.
lnicola commentedon May 20, 2022
I'm seeing about 700K rows in
current_state_delta_streamand more than 40M rows instate_groups_statefor rooms that should have been purged (ref. #12730). At some point purging failed because of a serialization error.Unfortunately,
synapse-find-unreferenced-state-groupsdoesn't seem to work. I can delete the rows manually, but I don't know exactly what tables I should be looking at.