-
Notifications
You must be signed in to change notification settings - Fork 304
fix(sync-service): Fix RelationTracker not syncing with Configurator after restart #3753
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
📝 WalkthroughWalkthroughRelationTracker now triggers an immediate publication update after rebuilding/restoring filters on restart, so the PublicationManager (and thus the Configurator) is explicitly notified of restored filters instead of relying on the Configurator to pull them later. Changes
Sequence Diagram(s)sequenceDiagram
participant RT as RelationTracker
participant PUB as PublicationManager
participant CFG as Configurator
rect rgba(200,150,255,0.5)
Note over RT,CFG: RelationTracker restart with Configurator running
end
RT->>RT: Restart
RT->>PUB: Rebuild initial filters
RT->>PUB: restore_relations()
RT->>PUB: update_publication_if_necessary()
PUB->>CFG: Notify restored filters
CFG->>PUB: Acknowledge / apply updates
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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 (3)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧬 Code graph analysis (1)packages/sync-service/test/electric/replication/publication_manager_test.exs (3)
⏰ 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). (1)
🔇 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 #3753 +/- ##
==========================================
+ Coverage 84.01% 87.36% +3.35%
==========================================
Files 44 23 -21
Lines 2834 2011 -823
Branches 528 529 +1
==========================================
- Hits 2381 1757 -624
+ Misses 451 252 -199
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:
|
…after restart When the RelationTracker restarts while the Configurator is still running, it now properly notifies the Configurator of the restored filters. Previously, after a RelationTracker restart, subsequent shape removals would not update the publication because the internal filter state was inconsistent: - prepared_relation_filters was restored from ShapeStatus - submitted_relation_filters remained empty - update_needed? returned false, skipping publication update The system would eventually self-heal via the 60-second periodic refresh, but this fix makes it immediate. Also fixed the "handles relation tracker restart" test which was fundamentally broken - it expected a RuntimeError but GenServer.call to a stopped server produces an EXIT. The async task wasn't being awaited, so the assertion failure was being silently ignored. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
dd73c4b to
b602ce8
Compare
msfstef
left a comment
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.
Makes sense!
Summary
Problem
Production bug: When the
RelationTrackerrestarts while theConfiguratoris still running (:one_for_onesupervision), the restored filters were not being synced to the Configurator. This caused the internal state to become inconsistent:prepared_relation_filterswas restored from ShapeStatussubmitted_relation_filtersremained empty (from init)After a shape removal, both would be empty, so
update_needed?returned false and no publication update was triggered. The system would eventually self-heal via the 60-second periodic refresh, but this is too slow for correct behavior.Test bug: The original test expected
assert_raise RuntimeErrorbut the actual behavior when a GenServer dies during a call is an EXIT, not a RuntimeError. The async task wasn't being awaited, so the assertion failure was being silently ignored - the test was "passing" based on other assertions.Solution
Added
update_publication_if_necessary(state)after restoring filters inhandle_continue(:restore_relations, ...)to immediately sync with the Configurator.Rewrote the test to correctly verify the restart-and-recovery scenario without the flawed async/RuntimeError expectations.
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.