-
-
Notifications
You must be signed in to change notification settings - Fork 5
Only regenerate snapshot if Send/Receive works #2069
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: develop
Are you sure you want to change the base?
Only regenerate snapshot if Send/Receive works #2069
Conversation
📝 WalkthroughWalkthroughThe changes reorganize project snapshot regeneration logic during CRDT-FW synchronization. Automatic snapshot regeneration is removed from the main sync service, made conditionally applied in the hosted service based on CRDT changes, and explicitly invoked in test operations. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes The diff introduces conditional snapshot regeneration logic in the hosted service, removes automatic regeneration from the sync service, and adds explicit snapshot calls in tests. This requires understanding the sync workflow timing and snapshot lifecycle implications across multiple layers. Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 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 |
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
backend/FwHeadless/Services/SyncHostedService.cs(1 hunks)backend/FwLite/FwLiteProjectSync.Tests/CrdtRepairTests.cs(2 hunks)backend/FwLite/FwLiteProjectSync.Tests/Sena3SyncTests.cs(1 hunks)backend/FwLite/FwLiteProjectSync/CrdtFwdataProjectSyncService.cs(0 hunks)
💤 Files with no reviewable changes (1)
- backend/FwLite/FwLiteProjectSync/CrdtFwdataProjectSyncService.cs
🧰 Additional context used
🧬 Code graph analysis (2)
backend/FwHeadless/Services/SyncHostedService.cs (1)
backend/LexCore/Entities/Project.cs (1)
Project(9-75)
backend/FwLite/FwLiteProjectSync.Tests/CrdtRepairTests.cs (1)
backend/FwLite/FwLiteShared/Sync/SyncService.cs (1)
SyncService(23-240)
🪛 GitHub Actions: Develop FwHeadless CI/CD
backend/FwHeadless/Services/SyncHostedService.cs
[error] 223-223: CS1002: ; expected. Command: dotnet build backend/FwHeadless/FwHeadless.csproj
🪛 GitHub Check: Build FwHeadless / publish-fw-headless
backend/FwHeadless/Services/SyncHostedService.cs
[failure] 223-223:
} expected
[failure] 223-223:
; expected
[failure] 223-223:
} expected
[failure] 223-223:
; expected
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Build API / publish-api
- GitHub Check: Build FW Lite and run tests
- GitHub Check: frontend
- GitHub Check: frontend-component-unit-tests
- GitHub Check: Analyze (csharp)
🔇 Additional comments (5)
backend/FwLite/FwLiteProjectSync.Tests/Sena3SyncTests.cs (1)
228-228: Test adapted to new explicit snapshot regeneration pattern.The explicit call to
RegenerateProjectSnapshotafterSyncis the expected pattern following the removal of automatic snapshot regeneration from the sync service.backend/FwLite/FwLiteProjectSync.Tests/CrdtRepairTests.cs (2)
93-93: Test adapted to new explicit snapshot regeneration pattern.The explicit call to
RegenerateProjectSnapshotafterSyncis the expected pattern following the removal of automatic snapshot regeneration from the sync service.
160-160: Test adapted to new explicit snapshot regeneration pattern.The explicit call to
RegenerateProjectSnapshotafterSyncis the expected pattern following the removal of automatic snapshot regeneration from the sync service.backend/FwHeadless/Services/SyncHostedService.cs (2)
210-224: Conditional snapshot regeneration correctly implements PR objective.The logic correctly ensures snapshots are only regenerated when:
- CRDT changes exist (
result.CrdtChanges > 0), AND- Send/Receive either succeeded or wasn't needed (no early return at line 203)
If Send/Receive fails after CRDT sync (line 203), the early return prevents snapshot regeneration, which is correct since the changes might have been rolled back.
226-226: Verify dual Harmony sync pattern is intentional.The code now performs Harmony sync twice:
- Conditionally at line 176 (if
HasSyncedSuccessfully)- Unconditionally at line 226 (after snapshot regeneration)
This appears intentional to ensure Harmony is synced both before and after the CRDT/FW sync operations, but you may want to verify this pattern is necessary and doesn't cause redundant work.
| } | ||
| else | ||
| { | ||
| logger.LogInformation("Skipping regenerating project snapshot, because there were no crdt changes"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix syntax error: replace colon with semicolon.
The line has a colon : instead of semicolon ; at the end, causing a compilation failure.
Apply this diff:
- logger.LogInformation("Skipping regenerating project snapshot, because there were no crdt changes"):
+ logger.LogInformation("Skipping regenerating project snapshot, because there were no crdt changes");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| logger.LogInformation("Skipping regenerating project snapshot, because there were no crdt changes"): | |
| logger.LogInformation("Skipping regenerating project snapshot, because there were no crdt changes"); |
🧰 Tools
🪛 GitHub Actions: Develop FwHeadless CI/CD
[error] 223-223: CS1002: ; expected. Command: dotnet build backend/FwHeadless/FwHeadless.csproj
🪛 GitHub Check: Build FwHeadless / publish-fw-headless
[failure] 223-223:
} expected
[failure] 223-223:
; expected
[failure] 223-223:
} expected
[failure] 223-223:
; expected
🤖 Prompt for AI Agents
In backend/FwHeadless/Services/SyncHostedService.cs around line 223, the
statement ends with a colon instead of a semicolon causing a compile error;
replace the trailing ':' with ';' so the logger.LogInformation(...) statement
terminates correctly.
This addresses the critical danger of #2052.
EDIT: Actually, this fix would result in all the CRDT changes being overridden if an exception was thrown without a roll-back happening... 😬 (e.g. this exception).
EDIT2:....actually that's not true. It would just result in repeating the same sync, which already happens if an exception is thrown anywhere else in the sync pipeline. It's suboptimal and a bit noisy, but is not expected to lose data, so mostly harmless.
EDIT3: After chatting with Jason, it sounds like roll-backs should be considered an extreme case. Based on that, I might try to implement my initial proposal/plan, but only if the exception explicitly results in a rollback. I'm assuming we can fairly safely determine that.
We're not in a position where we could easily write a test for this change.Planned work for this PR:
SyncWorker.ExecuteSyncCrdtFwdataProjectSyncService.Sync()Sync()in tests, but I think overall it will be cleaner. Currently in some tests weBypassImport()by creating a snapshot in the background. That will become more declarative when we pass the snapshot explicitly.