You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bound exporter gRPC queries with client keepalive and request deadlines - #11
The gRPC-backed endpoints (/metrics/params, general, validators, wallet, validator, oracle) all share one grpc.ClientConn to seid, and every query on it used context.Background(). When that connection stops making progress, requests queue forever, each Prometheus scrape hits its 10s timeout, and nothing on the exporter side ever tears the transport down. On pacific-1 the only thing that eventually does is grpc-go's server-side keepalive default in seid (2h ping, 20s timeout), which is why the snapshotter exporters have been going up == 0 for exactly 2h00m15s at a time (Sept 8 13:51–15:51, Sept 15 01:07–03:07 and 03:16–05:17 UTC) and paging SnapshotOrGenesisMetricsEndpointUnreachable. The replace google.golang.org/grpc => v1.33.2 pin also kept the client on a 2020 transport; the module builds cleanly against the already-required v1.53.0 without it.
Each handler now derives its context via requestContext(r), which is context.WithTimeout(r.Context(), RequestTimeout) with a new --request-timeout flag defaulting to 8s, so a stuck query fails within the scrape window and is cancelled when the scraper disconnects. The dial adds keepalive.ClientParameters{Time: 5m, Timeout: 20s, PermitWithoutStream: true} (5m matches seid's keepalive-min-time, so the pings are not penalised) so a dead connection is detected and redialed within minutes instead of hours. grpc.WithInsecure() is replaced by grpc.WithTransportCredentials(insecure.NewCredentials()), and the grpc replace pin is dropped.
Medium Risk
Touches all metrics endpoints' gRPC behavior and upgrades grpc-go; mis-tuned timeouts could cause partial scrapes, but the change targets production stuck-connection outages.
Overview
Metrics scrape handlers no longer use unbounded context.Background() for gRPC. Each handler derives a context from requestContext(r) (context.WithTimeout on the HTTP request, default 8s via new --request-timeout), so stuck node queries fail inside the scrape window and cancel when the client disconnects.
The shared gRPC dial now uses insecure.NewCredentials() instead of deprecated WithInsecure, adds client keepalive (5m ping, 20s timeout, permit without stream), and go.mod drops the grpc v1.33.2 replace so the build uses v1.53.0 already in require.
Reviewed by Cursor Bugbot for commit 3374d5d. Bugbot is set up for automated code reviews on this repo. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The gRPC-backed endpoints (
/metrics/params,general,validators,wallet,validator,oracle) all share onegrpc.ClientConnto seid, and every query on it usedcontext.Background(). When that connection stops making progress, requests queue forever, each Prometheus scrape hits its 10s timeout, and nothing on the exporter side ever tears the transport down. On pacific-1 the only thing that eventually does is grpc-go's server-side keepalive default in seid (2h ping, 20s timeout), which is why the snapshotter exporters have been goingup == 0for exactly 2h00m15s at a time (Sept 8 13:51–15:51, Sept 15 01:07–03:07 and 03:16–05:17 UTC) and pagingSnapshotOrGenesisMetricsEndpointUnreachable. Thereplace google.golang.org/grpc => v1.33.2pin also kept the client on a 2020 transport; the module builds cleanly against the already-required v1.53.0 without it.Each handler now derives its context via
requestContext(r), which iscontext.WithTimeout(r.Context(), RequestTimeout)with a new--request-timeoutflag defaulting to 8s, so a stuck query fails within the scrape window and is cancelled when the scraper disconnects. The dial addskeepalive.ClientParameters{Time: 5m, Timeout: 20s, PermitWithoutStream: true}(5m matches seid'skeepalive-min-time, so the pings are not penalised) so a dead connection is detected and redialed within minutes instead of hours.grpc.WithInsecure()is replaced bygrpc.WithTransportCredentials(insecure.NewCredentials()), and the grpc replace pin is dropped.