Skip to content

refactor: use unified connection [WPB-23775]#2303

Merged
coriolinus merged 52 commits into
mainfrom
prgn/refactor/23775-use-unified-connection
Jul 24, 2026
Merged

refactor: use unified connection [WPB-23775]#2303
coriolinus merged 52 commits into
mainfrom
prgn/refactor/23775-use-unified-connection

Conversation

@coriolinus

@coriolinus coriolinus commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

What's new in this PR

Partially implements 23775. This accomplishes most of that PR, except for two more steps:

  • Rename all Unified* entity trait family traits to rm the Unified prefix
  • Fix all the errors which fall out of this API changes in CC.

One issue I see right away: this new Database wraps a connection directly, where the old one wrapped a Mutex<Option<Connection>>. This means we can no longer use the Database::close method, because it consumes self and consumers all always have an Arc<Database>.

Whoever picks this up will need to either adjust that and all the access patterns, or determine that we can omit close methods entirely now.


PR Submission Checklist for internal contributors
  • The PR Title
    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@coriolinus
coriolinus requested a review from a team July 2, 2026 14:52
@fewerner
fewerner force-pushed the prgn/refactor/23775-use-unified-connection branch 8 times, most recently from 924d5dd to 6410221 Compare July 15, 2026 07:08
@coriolinus
coriolinus force-pushed the prgn/refactor/23775-use-unified-connection branch 2 times, most recently from 22f14e4 to d793639 Compare July 21, 2026 16:08
Comment thread keystore/src/mls.rs
Comment thread keystore/tests/z_entities.rs
Comment thread crypto/src/lib.rs
Comment thread crypto/src/mls/session/mod.rs
@coriolinus
coriolinus force-pushed the prgn/refactor/23775-use-unified-connection branch 2 times, most recently from 2cb4498 to f9f6893 Compare July 24, 2026 10:21

@SimonThormeyer SimonThormeyer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am amazed that this actually works. This is the greatest improvement to the keystore crate this year, if not ever.

Great work @fewerner @coriolinus!

We are now deprecating the old connection module in favor of the
unified connection, and removing platform-specific code from the
entity implementations.

Unfortunately, we need to retain sufficient wasm code that we can
still run enough of a migration to upgrade into the new unified
entity database, and that means that we've got a whole rump of otherwise-
useless code sitting in the legacy module. Can't be helped, unfortunately.
We're deprecating those in favor of the new `UnifiedEntity` traits
and will eventually update the names to remove the `Unified*` prefix.

The old traits still exist and are implemented in the
`idb_migration::legacy` module.
We only need the new stuff now. Old implementations can live in
the legacy module.
Just keeping things in parity with the old `Database` impl.
- rm now-obsolete trait implementations
- move certain implementations out of the platform module
- in general make the entities implement what they need inline
`Database` needs to be able to manage the `KeystoreTransaction`
lifecycle, so we organize these methods centrally here.
fewerner and others added 27 commits July 24, 2026 13:24
Committing a transaction will now take the transaction and end it, no
matter what the outcome is.
Thus, it can't be rolled back here.
This test passes now on wasm using the same sql implementation.
Previously, this was implemented on the old connections.
An explicit close method used to be required to ensure that indexeddb
would persist its final changes; it had no automatic sync-on-drop
behavior.

Now that the unified database has Sqlite behavior in all contexts,
it finalizes on drop. At the same time, supporting a close method
requires a design in which the internal connection can be taken
out and dropped. So, as the initial need has vanished, and eliminating
the close method means we can have a simpler internal implementation,
we just do that.
pathStr start with`/private/var/` but location just starts with `/var/`
`getLocation` now returns the absolute path to the db file.
`getLocation` now returns the absolute path to the db file.
We successfully moved to a unified database layer and no longer
distinguish between unified and not unified.
Previously this was doing the wrong thing when upgrading an old wasm
database to bytes. This fixes it.
We don't support that function internally at all anymore, but in order
to prevent breaking changes we retain the stub as a noop.
@coriolinus
coriolinus force-pushed the prgn/refactor/23775-use-unified-connection branch from f9f6893 to 9c89c82 Compare July 24, 2026 11:24
@coriolinus
coriolinus merged commit 9c89c82 into main Jul 24, 2026
18 of 19 checks passed
@coriolinus
coriolinus deleted the prgn/refactor/23775-use-unified-connection branch July 24, 2026 11:24
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.

3 participants