From 1397964cf4e13ceb36274e73df60e5e76d9ec7a8 Mon Sep 17 00:00:00 2001 From: Al Cutter Date: Mon, 11 May 2026 12:32:31 +0000 Subject: [PATCH] Add gRPC request hedging for GCS reads --- cmd/tesseract/gcp/main.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/cmd/tesseract/gcp/main.go b/cmd/tesseract/gcp/main.go index ba9cfdf8..3c8867e8 100644 --- a/cmd/tesseract/gcp/main.go +++ b/cmd/tesseract/gcp/main.go @@ -48,6 +48,7 @@ import ( "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" "golang.org/x/mod/sumdb/note" "google.golang.org/api/option" + "google.golang.org/grpc" ) func init() { @@ -120,6 +121,25 @@ var ( imageName = flag.String("image_name", "", "Name of the cached docker image. Only used to decorate slog events.") ) +// grpcServiceConfig is a gRPC service config in JSON format which explicitly specifies hedging for GCS ReadObject calls. +const grpcServiceConfig = `{ + "methodConfig": [ + { + "name": [ + { + "service": "google.storage.v2.Storage", + "method": "ReadObject" + } + ], + "hedgingPolicy": { + "maxAttempts": 3, + "hedgingDelay": "0.08s", + "nonFatalStatusCodes": ["UNAVAILABLE", "RESOURCE_EXHAUSTED"] + } + } + ] +}` + // nolint:staticcheck func main() { flag.Parse() @@ -145,7 +165,10 @@ func main() { Timeout: *clientHTTPTimeout, } - gcsClient, err := gcs.NewGRPCClient(ctx, option.WithGRPCConnectionPool(*gcsConnections)) + gcsClient, err := gcs.NewGRPCClient(ctx, + option.WithGRPCConnectionPool(*gcsConnections), + option.WithGRPCDialOption(grpc.WithDefaultServiceConfig(grpcServiceConfig)), + ) if err != nil { fatal(ctx, "Failed to create gRPC GCS client", slog.Any("error", err)) }