Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Add possibility to fix the room state using resolve-state #3249

Closed
wants to merge 7 commits into from

Conversation

S7evinK
Copy link
Contributor

@S7evinK S7evinK commented Oct 30, 2023

This adds a room_id and a fix flag to resolve-state.

When using room_id, resolve-state will ignore all snapshot NIDs passed to it and use all existing snapshots NIDs stored in the database to resolve the current state of a room.
If passed the fix flag, it will create a new snapshot containing the resolved state. (only after confirming the user knows what they are doing)

@S7evinK S7evinK requested a review from a team as a code owner October 30, 2023 07:59
@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

Attention: 24 lines in your changes are missing coverage. Please review.

Comparison is base (7863a40) 65.50% compared to head (2a09c26) 65.44%.

❗ Current head 2a09c26 differs from pull request most recent head 8588850. Consider uploading reports for the commit 8588850 to get more accurate results

Files Patch % Lines
...oomserver/storage/postgres/state_snapshot_table.go 5.26% 18 Missing ⚠️
roomserver/storage/postgres/storage.go 0.00% 2 Missing ⚠️
roomserver/storage/sqlite3/state_snapshot_table.go 0.00% 2 Missing ⚠️
roomserver/storage/sqlite3/storage.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3249      +/-   ##
==========================================
- Coverage   65.50%   65.44%   -0.07%     
==========================================
  Files         507      507              
  Lines       57291    57223      -68     
==========================================
- Hits        37531    37449      -82     
- Misses      15914    15924      +10     
- Partials     3846     3850       +4     
Flag Coverage Δ
unittests 49.43% <4.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@S7evinK
Copy link
Contributor Author

S7evinK commented Oct 30, 2023

Example output:

$ go run ./cmd/resolve-state/main.go -room_id '!OGEhHVWSdvArJzumhm:matrix.org' -filtertype 'm.room.name' -fix
Opening database
Room version 5
Fetching 359 snapshot NIDs
  358 of 359
Fetching 108480 state events
Fetching 67885 auth events
Resolving state
Resolved state contains 102535 events

* $cmfAyePJH4n7AnzWDGlJyS6g3RRkNDOGBTtbnTrWgzs m.room.name ""
  {"name":"Matrix HQ"}

Returned 1 state events after filtering

                 !!! WARNING !!!
Attempting to fix the state of a room can make things even worse.
For the best result, please shut down Dendrite to avoid concurrent database changes.
If you have missing state events (e.g. users not in a room, missing power levels
make sure they would be added by checking the resolved state events above first (or by running without -fix).
If you are sure everything looks fine, press Return, if not, press CTRL+c.

Attempting to fix state
Successfully set new snapshot NID 216980 containing 102535 state events

@S7evinK
Copy link
Contributor Author

S7evinK commented Nov 15, 2023

Tried to fix the state for #dendrite with this, managed to get myself reset out of the room 🙃

@S7evinK
Copy link
Contributor Author

S7evinK commented Nov 25, 2023

Closing this for now, not working as intended. May revisit later.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant