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

crypto: Add curve_key and sender_data_type columns to inboundgroupsessions table/store #3797

Conversation

andybalaam
Copy link
Contributor

No description provided.

@andybalaam andybalaam requested a review from richvdh August 2, 2024 12:36
@andybalaam andybalaam changed the title crypto: Pass the db upgrade transaction into do_schema_upgrade crypto: Add curve_key and sender_data_type columns to inboundgroupsessions table/store Aug 2, 2024
crates/matrix-sdk-indexeddb/src/crypto_store/mod.rs Outdated Show resolved Hide resolved
// Open and return the DB (we know it's at the latest version)
Ok(IdbDatabase::open_u32(name, 11)?.await?)
Ok(IdbDatabase::open_u32(name, 12)?.await?)
Copy link
Member

Choose a reason for hiding this comment

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

Note to self: this will mean the application release can't be rolled back without breaking everyone's sessions: we need to make sure this is called out, loudly, in changelogs all the way up the stack.

Copy link
Member

Choose a reason for hiding this comment

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

As an aside: I wonder if, for future changes, there is a way we can do this that doesn't actually break compatibility. The addition of an index doesn't mean that the new database won't work with the old application, but the indexeddb version mechanism doesn't know that.

What if we did something like this:

  • Promise that any future schema versions between 12 and (say) 19 will be backwards-compatible with applications expecting version 12.
  • Replace this line with:
        if old_version > 19 {
           return Err("db too new");
        }
        Ok(IdbDatabase::open(name)?.await?)

Then, if we make a schema change that is actually breaking, we bump the version to 20 (there is no reason that schema versions have to be sequential).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See #3812 for Rich's follow-up on this idea.

Comment on lines 171 to 173
let mut params = IdbIndexParameters::new();
params.unique(false);
object_store.create_index_with_params(name, &IdbKeyPath::str_sequence(key_path), &params)
Copy link
Member

Choose a reason for hiding this comment

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

It's not a strong opinion, but it's worth noting that this whole thing can equivalently be written:

Suggested change
let mut params = IdbIndexParameters::new();
params.unique(false);
object_store.create_index_with_params(name, &IdbKeyPath::str_sequence(key_path), &params)
object_store.create_index(name, key_path.into())

... at which point, I really question whether the helper function has any value.

(even if you want to make the nonunique bit explicit, that's not much longer, because it can be written: IdbIndexParameters::new().unique(false))

richvdh and others added 5 commits August 7, 2024 13:47
We weren't updating the database schema version immediately after the v10 -> v11
migration. This was fine in practice, because (a) for now, there is no v12
migration so we ended up setting the schema version immediately anyway; (b) the
migration is idempotent.

However, it's inconsistent with the other migrations and confusing, and is
about to make my test fail, so let's clean it up.
... so that next time we make a non-breaking change to the schema, it doesn't
break rollback
@richvdh richvdh force-pushed the andybalaam/schema-for-finding-igs-for-device branch from 9c80560 to b08403f Compare August 7, 2024 13:19
@richvdh richvdh merged commit b08403f into andyrich/sender-data-from-keys-query Aug 7, 2024
2 checks passed
@richvdh richvdh deleted the andybalaam/schema-for-finding-igs-for-device branch August 7, 2024 13:20
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