-
Notifications
You must be signed in to change notification settings - Fork 305
fix(sync-service): Fix shape cleanup race condition #3761
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
📝 WalkthroughWalkthroughThis PR fixes a race condition in shape invalidation where a shape's offset regression (offset going backwards relative to the client's last offset) wasn't handled, causing a CaseClauseError. The fix adds handling to send a shape rotation signal, triggering a client refetch. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code graph analysis (1)packages/sync-service/test/electric/shapes/api_test.exs (5)
⏰ 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). (10)
🔇 Additional comments (2)
✏️ Tip: You can disable this entire section by setting Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3761 +/- ##
=======================================
Coverage 87.36% 87.36%
=======================================
Files 23 23
Lines 2011 2011
Branches 531 534 +3
=======================================
Hits 1757 1757
Misses 252 252
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
| # ETS gets deleted while ShapeStatus retains the shape entry | ||
| # 3. A pending API request queries the shape | ||
| # 4. Validation succeeds (shape exists in ShapeStatus), but metadata reading | ||
| # fails, causing resolve_shape_handle to return LogOffset.last_before_real_offsets() |
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.
My agent had found this race as well but I had disliked this solution - what is it that is actually returning last_before_real_offsets(), and should it be returning something else instead rather than having this as a default? The default should perhaps be set when the shape is created, but if the shape is deleted we shouldn't fall back to the default
Fixes #3760
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.