-
Notifications
You must be signed in to change notification settings - Fork 76
Create group lock table, GroupGuard, and related tests #2823
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?
Conversation
|
Claude finished @tylerhawkes's task —— View job Code Review CompleteReview Date: 2025-11-21 08:36:00 UTC Critical Issues1. Lock ordering issue in The
// Current (problematic):
self.conn.delete_group_lock(&lock.group_id, lock.locked_at_ns)?;
self.lock = None; // Lock cleared even if deletion affects 0 rows
// Should be:
let deleted = self.conn.delete_group_lock(&lock.group_id, lock.locked_at_ns)?;
if deleted > 0 {
self.lock = None;
} else {
return Err(StorageError::...); // or keep lock for Drop to retry
}2. Potential integer overflow in time calculation (xmtp_db/src/encrypted_store/group_lock.rs:62, 111) Using expires_in.as_nanos().min(NS_IN_MIN as u128 * 5) as i64If let capped_ns = expires_in.as_nanos().min(NS_IN_MIN as u128 * 5);
let expires_at_ns = locked_at_ns.saturating_add(
i64::try_from(capped_ns).unwrap_or(NS_IN_MIN * 5)
);Security Concerns3. No lock expiration enforcement at acquisition time The code sets
Performance Issues4. Lack of index on If expired lock cleanup is added later, queries filtering by CREATE INDEX idx_group_locks_expires_at ON group_locks(expires_at_ns);Test Coverage Gaps5. Missing edge case tests:
6. WASM test coverage incomplete The transaction test uses Code Quality7. Inconsistent error handling patterns
Consider returning a more specific error when 0 rows are deleted. 8. Missing mutable access to connection
pub fn conn_mut(&mut self) -> &mut Q {
&mut self.conn
}SummaryThe implementation is well-structured with good RAII semantics, but has critical bugs around lock cleanup ordering and potential time arithmetic issues. Address the |
How to use the Graphite Merge QueueAdd the label mergequeue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2823 +/- ##
==========================================
+ Coverage 74.57% 74.62% +0.04%
==========================================
Files 386 387 +1
Lines 49874 50086 +212
==========================================
+ Hits 37193 37375 +182
- Misses 12681 12711 +30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
2f2c0e2 to
5683492
Compare
5683492 to
c1a59b8
Compare

Add database-backed group locks and
GroupGuardto manage exclusive access with a 5-minute expiry cap in group_lock.rsIntroduce
group_lockstable via migrations, implementQueryGroupLockforConnectionExtand&mut SqliteConnection, and addGroupGuardthat acquires and deletes locks on drop; include tests and schema definitions.📍Where to Start
Start with the
GroupGuard::acquireand trait methods in group_lock.rs.Macroscope summarized c1a59b8.