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

Migrate inbound_group_session2 to fix keys incorrectly copied from old store version #2957

Merged
merged 17 commits into from
Dec 21, 2023

Conversation

andybalaam
Copy link
Member

@andybalaam andybalaam commented Dec 19, 2023

Fixes element-hq/element-web#26782

In migrate_data_for_v6, we incorrectly copied the keys in inbound_group_sessions verbatim into inbound_group_sessions2. What we should have done is re-encrypt them using the new table name, so we fix that up with a new migration here.

This caused the bug because we were looking for sessions to mark as backed up by calculating their key (from room_id and session_id) but that key did not exist, because the old sessions were stored under the incorrect keys. So no sessions were marked as backed up, and we repeatedly tried to re-mark them.

Depending on your taste you might like to review this commit by commit.

@andybalaam andybalaam force-pushed the andybalaam/migrate-inbound-group-keys branch from 39ea3d8 to f81fb61 Compare December 20, 2023 11:32
@andybalaam andybalaam requested a review from richvdh December 20, 2023 11:36
@andybalaam andybalaam marked this pull request as ready for review December 20, 2023 11:36
@andybalaam andybalaam requested a review from a team as a code owner December 20, 2023 11:36
@andybalaam andybalaam requested review from Hywan and removed request for a team December 20, 2023 11:36
Copy link

codecov bot commented Dec 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (320b868) 83.50% compared to head (efea767) 83.50%.
Report is 17 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2957   +/-   ##
=======================================
  Coverage   83.50%   83.50%           
=======================================
  Files         221      221           
  Lines       23007    23007           
=======================================
  Hits        19211    19211           
  Misses       3796     3796           

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

@andybalaam
Copy link
Member Author

Running a git bisect to try and figure out what I did to the tests...

@andybalaam
Copy link
Member Author

Running a git bisect to try and figure out what I did to the tests...

OK, Rich helped me figure out it was due to missing calls to db.close(). In a future PR I will attempt to protect against forgetting this.

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm otherwise.

Signed-off-by: Richard van der Hoff <[email protected]>
Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have all the knowledge to validate this patch, but the code looks good (modulo 2 tiny comments).

@richvdh
Copy link
Member

richvdh commented Dec 21, 2023

I don't have all the knowledge to validate this patch, but the code looks good (modulo 2 tiny comments).

Thanks @Hywan! I'm pretty happy with this from the functionality side, so if you're happy from the code style side, I think we're good to go.

Co-authored-by: Ivan Enderlin <[email protected]>
Signed-off-by: Richard van der Hoff <[email protected]>
@richvdh richvdh enabled auto-merge (squash) December 21, 2023 14:40
@richvdh richvdh merged commit ec833c8 into main Dec 21, 2023
35 checks passed
@richvdh richvdh deleted the andybalaam/migrate-inbound-group-keys branch December 21, 2023 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ElementR keeps re-uploading the same set of keys to backup?
3 participants