[claude] Keep the fwdata LcmCache alive during long syncs - #2500
Conversation
The LcmCache's 30-minute sliding expiration only resets when a new FwDataMiniLcmApi first touches the memory cache, so a sync that runs longer than that can have the cache disposed out from under it. FwDataFactory.PreventEviction returns a disposable timer that touches the cache entry every 5 minutes; the sync service holds one per sync. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughChangesSynchronization Cache Guard
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
backend/Testing/FwHeadless/Services/SyncWorkerTestHarness.cs (1)
251-256: 📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy liftAdd integration coverage for the keepalive path.
This harness mocks
CrdtFwdataProjectSyncServiceand suppliesnull!forFwDataFactory, so the newPreventEvictioncall is never exercised. Add a targeted integration or round-trip test using the real sync service and a real FwData project, or a focused test that verifies the keepalive is created and disposed.As per coding guidelines,
backend/FwLite/FwLiteProjectSync/**/*.cssynchronization changes must be covered with integration or round-trip tests.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend/Testing/FwHeadless/Services/SyncWorkerTestHarness.cs` around lines 251 - 256, Extend the sync worker test coverage around the CrdtFwdataProjectSyncService setup to exercise the keepalive path introduced by PreventEviction. Prefer a targeted integration or round-trip test using a real sync service and FwData project; otherwise verify that the keepalive is created and disposed, rather than relying on the existing Strict mock with null FwDataFactory.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/FwLite/FwDataMiniLcmBridge/FwDataFactory.cs`:
- Around line 138-143: Update PreventEviction to touch the cache entry
immediately by invoking cache.TryGetValue with the computed key before creating
and returning the periodic Timer. Keep the existing 5-minute refresh interval
and callback behavior unchanged.
---
Outside diff comments:
In `@backend/Testing/FwHeadless/Services/SyncWorkerTestHarness.cs`:
- Around line 251-256: Extend the sync worker test coverage around the
CrdtFwdataProjectSyncService setup to exercise the keepalive path introduced by
PreventEviction. Prefer a targeted integration or round-trip test using a real
sync service and FwData project; otherwise verify that the keepalive is created
and disposed, rather than relying on the existing Strict mock with null
FwDataFactory.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ee4cedf4-e34d-47be-8f8a-3ddba03c9ef0
📒 Files selected for processing (3)
backend/FwLite/FwDataMiniLcmBridge/FwDataFactory.csbackend/FwLite/FwLiteProjectSync/CrdtFwdataProjectSyncService.csbackend/Testing/FwHeadless/Services/SyncWorkerTestHarness.cs
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
CrdtFwdataProjectSyncService gained a FwDataFactory constructor parameter; the SyncWorker test harness mock was still passing four args, so Moq could not find a matching constructor and every SyncWorkerTests case failed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…expiration PreventEviction waited a full period before its first touch, so an entry with little of its 30-minute window left could be evicted before the first refresh. The refresh period was also an independent magic number that could silently exceed the sliding expiration if either changed. Fire the timer immediately (TimeSpan.Zero due-time), and derive the period from a shared CacheSlidingExpiration constant (half the window) so a refresh is guaranteed to land inside every window by construction. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The timer's cache lookup runs on a ThreadPool thread. If the shared MemoryCache is disposed during host shutdown while a sync is still finishing, TryGetValue throws ObjectDisposedException, and an unhandled throw there crashes the process. Swallow it so the keepalive stays best-effort, matching how a missing entry is already tolerated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@hahn-kev Regarding the discussion about moving the |
[Claude, autonomous]
The LcmCache's 30-minute sliding expiration only resets when a new
FwDataMiniLcmApifirst touches the memory cache, so a sync that outlives it (large project, or paused in a debugger) gets its cache disposed mid-run.FwDataFactory.PreventEvictionreturns a disposable timer that touches the cache entry every 5 minutes; the sync service holds one for the duration of a sync.TryGetValuenever creates or reloads, so a project explicitly closed for FieldWorks stays closed.🤖 Generated with Claude Code