Skip to content

crypto: In sqlite, use the SQL column value for backed_up everywhere #3863

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

Merged
merged 2 commits into from
Aug 20, 2024

Conversation

andybalaam
Copy link
Member

Most times we pulled an InboundGroupSession from the sqlite DB, we were overriding whatever value for backed_up was stored inside the pickled value, and using the value stored in the SQL column.

But when we pulled a single InboundGroupSession from the DB by ID, we did not override it.

I am fairly sure this was an accidental oversight, so this change corrects it, and unifies the code with other places we create these objects.

Part of #3544
Applies on top of #3862

@andybalaam andybalaam requested a review from a team as a code owner August 20, 2024 12:13
@andybalaam andybalaam requested review from bnjbvr and removed request for a team August 20, 2024 12:13
Base automatically changed from andybalaam/simplify-igs-in-sqlite to main August 20, 2024 12:16
@richvdh
Copy link
Member

richvdh commented Aug 20, 2024

Hrm. I support the principle of being consistent, but (other than the comment asserting as much) why do we consider the sql column to be the primary source of truth?

  • It's not what the indexeddb impl does? I think?
  • It requires additional work to SELECT the column and overwrite the value we have in the pickle
  • I think the column was added later, so there is probably some migration code that reads from the pickle and populates the column. At the very least, that makes the runtime code inconsistent with the migration code.

@andybalaam
Copy link
Member Author

andybalaam commented Aug 20, 2024

Hrm. I support the principle of being consistent, but (other than the comment asserting as much) why do we consider the sql column to be the primary source of truth?

When we mark the sessions as backed up, we only update the SQL column, not the pickled value.

  • It's not what the indexeddb impl does

Yeah, it modifies the serialized values.

  • It requires additional work to SELECT the column and overwrite the value we have in the pickle

A very tiny amount of work, yes.

  • I think the column was added later, so there is probably some migration code that reads from the pickle and populates the column. At the very least, that makes the runtime code inconsistent with the migration code.

This is a one-time operation though, right? Then as soon as the column exists, it is the source of truth.

@bnjbvr bnjbvr requested review from richvdh and removed request for bnjbvr August 20, 2024 12:50
@richvdh
Copy link
Member

richvdh commented Aug 20, 2024

(in other words, I'd change

When we mark the sessions as backed up, we only update the SQL column, not the pickled value.

Right. This is the clincher. Sorry, I'd forgotten that.

Most times we pulled an InboundGroupSession from the sqlite DB, we were
overriding whatever value for `backed_up` was stored inside the pickled
value, and using the value stored in the SQL column.

But when we pulled a single InboundGroupSession from the DB by ID, we
did not override it.

I am fairly sure this was an accidental oversight, so this change
corrects it, and unifies the code with other places we create these
objects.
@andybalaam andybalaam force-pushed the andybalaam/use-sql-column-backed_up-value-everywhere branch from 35be35c to dec768c Compare August 20, 2024 14:20
@andybalaam andybalaam enabled auto-merge (rebase) August 20, 2024 14:21
@andybalaam andybalaam merged commit ca09917 into main Aug 20, 2024
40 checks passed
Copy link

codecov bot commented Aug 20, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 84.10%. Comparing base (668a267) to head (dec768c).
Report is 2 commits behind head on main.

Files Patch % Lines
crates/matrix-sdk-sqlite/src/crypto_store.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3863      +/-   ##
==========================================
+ Coverage   84.09%   84.10%   +0.01%     
==========================================
  Files         261      261              
  Lines       27629    27628       -1     
==========================================
+ Hits        23235    23237       +2     
+ Misses       4394     4391       -3     

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

@andybalaam andybalaam deleted the andybalaam/use-sql-column-backed_up-value-everywhere branch August 20, 2024 14:36
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.

2 participants