fix: test concurrent cache-miss#4340
Conversation
ff626b1 to
7c5a0bb
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a Redis-based “single-flight” helper and integrates it into the members advanced query cache-miss/refresh paths to prevent concurrent requests from stampeding the database on cold keys.
Changes:
- Added
withSingleFlighthelper in@crowd/redisto coordinate concurrent callers behind a lock while polling cache. - Updated
queryMembersAdvancedto single-flight cache misses and align background refresh locking with the same primitive. - Added a shared cap constant to prevent the activityCount top‑N optimization from silently truncating oversized pages.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| services/libs/redis/src/singleFlight.ts | New single-flight helper built on existing Redis mutex primitives. |
| services/libs/redis/src/index.ts | Exports the new single-flight helper from the redis lib barrel. |
| services/libs/data-access-layer/src/members/queryCache.ts | Removes the previous refresh-lock helpers from MemberQueryCache. |
| services/libs/data-access-layer/src/members/queryBuilder.ts | Adds a shared top‑N cap constant and guards optimized path against truncation. |
| services/libs/data-access-layer/src/members/base.ts | Uses single-flight on members advanced cache misses and switches background refresh locking to acquireLock/releaseLock. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| this.selectedProjectGroup = projectGroup; | ||
| this.fetchSubprojectsForProjectGroup(projectGroup.slug); |
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
f16f05a to
60042d7
Compare
PR SummaryMedium Risk Overview Background refreshes now use the same lock key and Query behavior fixes: the main list query no longer forces the member-orgs join when orgs are loaded separately; the activityCount top-N path falls back to the full query when Reviewed by Cursor Bugbot for commit 60042d7. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 60042d7. Configure here.
| }) | ||
| return await withSingleFlight( | ||
| redis, | ||
| computeLockKey, |
There was a problem hiding this comment.
Compute locks survive invalidation
Medium Severity
Single-flight and background refresh now take Redis mutexes on unprefixed cache key strings via acquireLock, but MemberQueryCache invalidation still only deletes locks under the members-refresh-lock cache prefix. After cache invalidation, leftover compute locks can block repopulation for up to the 90s TTL.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 60042d7. Configure here.


Summary
improve lock for redis
Type of change