[AN] Remove readiness blocking on gracefulDone channel - #8664
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe shutdown worker returns after ChangesgRPC shutdown behavior
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change removes a shutdown wait that can block past its timeout; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 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 |
|
|
||
| rawServer := grpc.NewServer() | ||
| handler := &blockingStreamServer{started: make(chan struct{})} | ||
| handler := &blockingStreamServer{ |
There was a problem hiding this comment.
By adding <-gracefulDone as the final statement on shutdownWorker, this test (TestGrpcServerShutdown_WithActiveStream), fails with:
could not close done channel on time: failed to shutdown all components on timeshowcasing the blocking that was still possible.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
| func (s *blockingStreamServer) Stream(stream grpc.ServerStream) error { | ||
| close(s.started) | ||
| if s.blockDuration > 0 { | ||
| time.Sleep(s.blockDuration) |
There was a problem hiding this comment.
Besides blocking on the done channel readiness, also add some artificial blocking with time.Sleep, whenever configured.
Co-authored-by: Leo Zhang <zhangchiqing@gmail.com>
gracefulDone channelgracefulDone channel
* fix the graceful shutdown by adding a timeout * make tidy * cancel streaming RPCs on shutdown via interceptor Adds a StreamServerInterceptor that couples stream.Context() to the node's SignalerContext, so long-lived subscriptions exit cleanly when shutdown begins. GracefulStop then completes without needing the force-stop fallback in the common case. The 5s timeout remains as a backstop for any hung RPCs. Also defaults NewGrpcServer's timeout when zero, switches the shutdown timer to time.NewTimer to avoid a leak on the fast path, and brackets type references in godocs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * drop unnecessary godoc and whitespace changes Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * address review comments * Remove entirely blocking on gracefulDone channel readiness * Update comment regarding time.Sleep on Stream() Co-authored-by: Leo Zhang <zhangchiqing@gmail.com> * Fix linting issue around comment --------- Co-authored-by: Leo Zhang (zhangchiqing) <zhangchiqing@gmail.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Ardit Marku <markoupetr@gmail.com>
Follow-up on #8662 .
On #8662 (comment), I suggested that
<-gracefulDoneis better to be moved outside theselect, but after carefully revisiting the unit tests, it should in fact be removed entirely, as it can still block after the timeout.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
Tests