fix(da): serialize subscriber lifecycle transitions - #3430
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe subscriber now uses explicit ChangesSubscriber lifecycle serialization
Estimated code review effort: 3 (Moderate) | ~20 minutes Mergeability Score: ⚪ Minimal · up to The change serializes subscriber start and stop transitions and adds focused concurrency coverage; no actionable merge-blocking risk remains beyond normal checks and review. Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
|
@tac0turtle Hi, Could you please review this PR at your convenience? Thank you very much. |
| sub.Stop() | ||
| close(concurrentStopDone) | ||
| }() | ||
| select { |
There was a problem hiding this comment.
[suggestion] The concurrent-Stop assertion is a single default poll immediately after launching the goroutine, with no handshake that the second Stop has entered <-stopDone. If Stop treated subscriberStopping as a no-op (returned immediately), this check can still take the default branch if the goroutine has not been scheduled yet; after releaseGeneration(0) the later waitForLifecycleSignal on concurrentStopDone only proves the call eventually returned, not that it waited with the first Stop. Contrast with the first Stop, which is actually proven: the test waits for canceled[0] (so cancel() has run and Wait is blocked on the unreleased worker) before asserting stopDone is still open.
Suggestion: Handshake that the second Stop is inside the wait (for example a short timeout loop that fails only if concurrentStopDone closes before release, or observe state == subscriberStopping / a test hook after the waiter has copied stopDone), then release generation 0. Keep the existing canceled[0] handshake for the first Stop; that one is already deterministic.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3430 +/- ##
==========================================
+ Coverage 62.46% 62.52% +0.05%
==========================================
Files 121 121
Lines 13469 13485 +16
==========================================
+ Hits 8413 8431 +18
- Misses 4114 4115 +1
+ Partials 942 939 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Overview
Closes #3429
Subscriber.Startpreviously exposed its cancel function before registering the worker goroutines with the WaitGroup.Subscriber.Stopalso cleared that function before the current generation had fully exited.Those orderings allowed
Stopto miss newly registered workers and allowed a new subscriber generation to start while the previous generation was still stopping.This PR serializes the subscriber lifecycle and keeps the stopping state visible until all workers from the current generation have exited.
Changes
Start/Stopcalls safe.Testing
go test ./block/internal/dago test -race ./block/internal/daSummary by CodeRabbit
Bug Fixes
Tests