-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[PM-28555] Create idempotent sproc for creating a My Items collection #6677
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
base: main
Are you sure you want to change the base?
[PM-28555] Create idempotent sproc for creating a My Items collection #6677
Conversation
…eate-idempotent-sproc-for-creating-a-single-my-items-collection
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6677 +/- ##
==========================================
+ Coverage 53.39% 53.40% +0.01%
==========================================
Files 1911 1911
Lines 85190 85274 +84
Branches 7642 7645 +3
==========================================
+ Hits 45483 45539 +56
- Misses 37956 37983 +27
- Partials 1751 1752 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
|
@bitwarden/dept-dbops Can you please review my approach to locks/concurrency here and let me know if I'm on the right path? See the PR description for more info. My current approach has my tests working, but has broken every other instance where we're manually creating an EF transaction. I can fix those by explicitly using a strategy, but better to get some feedback before I spend more time on it. |
|
Claude finished @eliykat's task —— View job Code Review CompleteI've completed a comprehensive review of this PR. The core concurrency approach is sound, but there are critical issues that need to be addressed before merging. Executive SummaryThe idempotent stored procedure with SERIALIZABLE isolation is the right approach for preventing duplicate "My Items" collections. However, the implementation has:
Critical Issues (Must Fix)1. Missing
|
|
@claude I disagree with "1. Missing @CollectionId Parameter in Dapper Implementation" - double check that you've read this correctly. |
|
Claude finished @eliykat's task —— View job Re-verification CompleteYou are absolutely correct - I apologize for the error in my review. Corrected FindingIssue #1 - Missing I was wrong about this. Looking at var collectionId = CoreHelpers.GenerateComb();
var now = DateTime.UtcNow;
var parameters = new DynamicParameters();
parameters.Add("@CollectionId", collectionId); // ✓ THIS IS PRESENT
parameters.Add("@OrganizationId", organizationId);
parameters.Add("@OrganizationUserId", organizationUserId);
// ... rest of parametersI must have misread the code during my initial review. This implementation is correct. Updated Critical Issues (Must Fix)With issue #1 removed, there is now only one critical issue: 1. EnableRetryOnFailure Breaking Change ❌File: You've added The Problem: When Evidence from your own comment: You mentioned this "broke every other instance where we're manually creating an EF transaction" - that's exactly what happens. Recommendation: Remove global // In EntityFrameworkServiceCollectionExtensions.cs - REMOVE EnableRetryOnFailure
options.UseSqlServer(connectionString, b =>
{
// b.EnableRetryOnFailure(); // REMOVE THIS
});
// Your execution strategy approach in CollectionRepository.UpsertDefaultCollectionAsync is correct
// Keep it as-is - it's the only place that needs retry logic for this featureRemaining Review ItemsAll other items from my original review remain valid: Important Issues (Should Fix):
Minor Issues:
Positive Findings:
ApologyI apologize for the incorrect finding about the missing parameter. Thank you for pushing back and asking me to double-check. The Dapper implementation is correct on this point. The main remaining concern is the global |


🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-28555
📔 Objective
A user must only have a single My Items collection, however this is not enforced by db constraints, so it's particularly important that we enforce it at the time of creation. This implements a specific database method to create a My Items collection for a user, ensuring that:
The database changes required some trial-and-error to get a proper lock on the rows (using the
SERIALIZABLEoption) and to gracefully handle deadlocks. In particular, this required changes to system-wide EF configuration, so dbops please take a close look at this and let me know if there is a better / preferred way to achieve this.📸 Screenshots
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes