[PM-39455] Reuse the connection and transaction during user key rotation - #8165
Open
mzieniukbw wants to merge 2 commits into
Open
[PM-39455] Reuse the connection and transaction during user key rotation#8165mzieniukbw wants to merge 2 commits into
mzieniukbw wants to merge 2 commits into
Conversation
Replace UpdateEncryptedDataForKeyRotation with the generic DatabaseTransactionAction, which takes a DbConnection and DbTransaction rather than the SQL Server specific SqlConnection and SqlTransaction. This matches the delegate introduced in #7548. Every EF repository that takes part in a key rotation now binds its DatabaseContext to the caller's connection and transaction through GetTransactionalDatabaseContext, instead of opening a second connection. Opening a second connection deadlocks on single-writer providers such as SQLite, and left each write outside the rotation transaction on the others, which breaks integration tests.
mzieniukbw
requested review from
coroiu,
ike-kottlowski,
jrmccannon,
nikwithak and
quexten
August 7, 2026 13:20
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8165 +/- ##
==========================================
+ Coverage 63.02% 67.49% +4.47%
==========================================
Files 2316 2315 -1
Lines 100453 100534 +81
Branches 9037 9043 +6
==========================================
+ Hits 63306 67857 +4551
+ Misses 34962 30392 -4570
- Partials 2185 2285 +100 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
harr1424
approved these changes
Aug 7, 2026
harr1424
left a comment
Contributor
There was a problem hiding this comment.
Tools-owned changes look good
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-39455
📔 Objective
Replace UpdateEncryptedDataForKeyRotation with the generic
DatabaseTransactionAction, which takes aDbConnectionandDbTransactionrather than the SQL Server specificSqlConnectionandSqlTransaction. This matches the delegate introduced in #7548, which is planned to get merged first.Every EF repository that takes part in a key rotation now binds its DatabaseContext to the caller's connection and transaction through GetTransactionalDatabaseContext, instead of opening a second connection. Opening a second connection deadlocks on single-writer providers such as SQLite, and left each write outside the rotation transaction on the others, which breaks integration tests.
📸 Screenshots