From 2c2391dbf4f398ef336da87367e082bf469ada27 Mon Sep 17 00:00:00 2001 From: Keegan Carruthers-Smith Date: Tue, 28 Sep 2021 15:18:06 +0200 Subject: [PATCH] search: disable retries for zoekt (#25449) Currently our retry transport will always copy the request body. We plan on contributing upstream usage of Request.GetBody to overcome this. For now we disable to prevent possible OOMs on sourcegraph.com. --- internal/search/backend/zoekt.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/internal/search/backend/zoekt.go b/internal/search/backend/zoekt.go index 2328d83ab0e..ca2a0d5519f 100644 --- a/internal/search/backend/zoekt.go +++ b/internal/search/backend/zoekt.go @@ -9,7 +9,20 @@ import ( "github.com/sourcegraph/sourcegraph/internal/httpcli" ) -var zoektHTTPClient, _ = httpcli.NewInternalClientFactory("zoekt_webserver").Client() +// We don't use the normal factory for internal requests because we disable +// retries. Currently our retry framework copies the full body on every +// request, this is prohibitive when zoekt generates a large query. +// +// Once our retry framework supports the use of Request.GetBody we can switch +// back to the normal internal request factory. +var zoektHTTPClient, _ = httpcli.NewFactory( + httpcli.NewMiddleware( + httpcli.ContextErrorMiddleware, + ), + httpcli.NewMaxIdleConnsPerHostOpt(500), + httpcli.MeteredTransportOpt("zoekt_webserver"), + httpcli.TracedTransportOpt, +).Client() // ZoektStreamFunc is a convenience function to create a stream receiver from a // function.