[v0.51] [AN] Backport graceful shutdown fix (#8662, #8664) - #8676
Conversation
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>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Leo Zhang <zhangchiqing@gmail.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
End-to-end validation on foundation testnet ANRan a before/after test against Fix under test: PR #8662 + PR #8664 ported to Before (unfixed build)Client side — streams did not close until Docker's 10s stop grace expired and the container was SIGKILLed: The Server side — matches the original bug report verbatim:
After (with fix, tag
|
| Before | After | |
|---|---|---|
| Stream close latency | ~10s | ~60ms |
| Stream close cause | Docker SIGKILL → RST_STREAM |
Interceptor cancel → context canceled |
node shutdown complete log |
never emitted | emitted |
| systemd result | Failed, status=137 |
Deactivated successfully |
Comment produced in collaboration with claude.
Mainnet validationRepeated the before/after test against the foundation mainnet AN Before (
|
Before (v0.51.0-rc.1) |
After (v0.51.0-graceful-an-shutdown) |
|
|---|---|---|
| Client-side close cause | RST_STREAM (container net drop) |
context canceled (interceptor) |
| Client-side latency | ~250ms | 71ms |
Server: node shutdown complete log |
never emitted | emitted |
| Server: shutdown duration | ~10s (bounded by Docker SIGKILL) | <1s |
| systemd result | Failed, status=137 |
Deactivated successfully |
| Docker SIGKILL required? | yes | no |
Fix is confirmed working on both foundation testnet AN (access-001.devnet54) and foundation mainnet AN (access-001.mainnet28) under real network traffic. Safe to roll out to external operators.
Comment produced in collaboration with claude.
Backports the graceful shutdown fix for the Access Node gRPC server from
mastertov0.51, so we can cut av0.51release with the fix.Cherry-picked commits, in order:
From #8662 (closes #8666):
4ad464cfix the graceful shutdown by adding a timeout (Leo)71fde5cmake tidy (Leo)b090d15cancel streaming RPCs on shutdown via interceptorb2d22afdrop unnecessary godoc and whitespace changes3a4c15eaddress review comments (Leo)From #8664:
2b2caadRemove entirely blocking on gracefulDone channel readiness (Ardit)c05db3cUpdate comment regarding time.Sleep on Stream() (Ardit)5402e2bFix linting issue around comment (Ardit)No merge conflicts — all cherry-picks applied cleanly.
module/grpcserver/matchesmasterexactly after the port (verified viagit diff origin/master -- module/grpcserver/).go build,go vet, andgo test ./module/grpcserver/...all pass.Nothing else from
masteris included beyond the commits in these two PRs.Suggested labels:
Bugfix,S-Access— please confirm.Produced in collaboration with claude.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.