-
Notifications
You must be signed in to change notification settings - Fork 270
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
indexeddb: Tidy the migrations code #3095
Conversation
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
Signed-off-by: Andy Balaam <[email protected]>
1f3a7ae
to
a92140f
Compare
Signed-off-by: Andy Balaam <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3095 +/- ##
=======================================
Coverage 83.73% 83.73%
=======================================
Files 224 224
Lines 23536 23536
=======================================
Hits 19708 19708
Misses 3828 3828 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I admire the effort to clean this tech debt. Thank you very much. The new code structure and new API is so much easier. Thanks!
crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v8_to_v10.rs
Outdated
Show resolved
Hide resolved
Signed-off-by: Andy Balaam <[email protected]>
a648522
to
e3c7e9d
Compare
Signed-off-by: Andy Balaam <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great to me, thank you for doing this!
One thing is that there is now an awful lot of opening and closing the DB going on, even in the simple case that there is no upgrade to be done, but maybe that's a quick enough operation, and there is no point optimising it prematurely.
@@ -86,6 +84,13 @@ pub async fn open_and_upgrade_db( | |||
Ok(IdbDatabase::open_u32(name, 10)?.await?) | |||
} | |||
|
|||
async fn db_version(name: &str) -> Result<u32, IndexeddbCryptoStoreError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might be worth documenting that this function will create the db (at version 1) if it does not already exist.
If there's no upgrade don't we only open it twice (to find the version, then to actually open it)? If the DB is empty, we open and close a lot, but I haven't seen any performance problem from that so hopefully it's fine. I'm not sure there is a good solution if we did find it is a problem in general, because need multiple separate schema migrations to happen, and the data migrations need to happen in between each one. We could special-case the empty DB case, but we'd only want to do that if we were convinced it caused a problem. |
True. It's not as bad as I thought it was going to be.
I think we could approximately halve the number of |
Ah right, by doing the data migration using the same DB handle as the schema upgrade we just did. But yeah, probably no need. |
I found it quite hard to understand the Indexed DB schema migration code, so I did my best to tidy it.
Definitely review this commit by commit. Each commit is supposed to be quite trivial, but together they add up to code that I am able to understand much better.