From 1d18969ffa69c4baa643a98e1963358c75bde260 Mon Sep 17 00:00:00 2001 From: Stefan Hengl Date: Wed, 1 May 2024 09:33:23 +0200 Subject: [PATCH 1/5] go.mod: bump zoekt This includes the following changes - 783a51a784 docker: use go1.22 and alpine3.19 - 301c735b9c docker: fix typo in builder name - a0f051e95e all: remove gob and SSE rpc endpoints - 8619902b5d gitindex: include environ for git tests - 55b7aeee2d docker: simplify apk add lines - 734f5b64f8 gomod: update deps for CVE-2023-45288 and CVE-2024-24786 - 6df055493b gitindex: interpret SSH URLs - 5ecbc14cac zoekt-indexserver: prune branches on fetch - 5411e9b32e zoekt-mirror-gerrit: allow to use reponame without host in the index - 570757e20b Honor regex flags for case-sensitivity - 68d04651cc zoekt-mirror-gerrit: handle http authentication - 72f95004e6 fix: don't modify finalCands Test plan: Zoekt CI --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 09c88485e450..61edaee530b1 100644 --- a/go.mod +++ b/go.mod @@ -590,7 +590,7 @@ require ( github.com/scim2/filter-parser/v2 v2.2.0 github.com/sourcegraph/conc v0.3.1-0.20240108182409-4afefce20f9b github.com/sourcegraph/mountinfo v0.0.0-20240201124957-b314c0befab1 - github.com/sourcegraph/zoekt v0.0.0-20240418025752-74e75efaded6 + github.com/sourcegraph/zoekt v0.0.0-20240501072156-72f95004e6d6 github.com/spf13/cobra v1.8.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.5.2 // indirect diff --git a/go.sum b/go.sum index 91322a818146..b82e5301acc3 100644 --- a/go.sum +++ b/go.sum @@ -1709,6 +1709,8 @@ github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152 h1:z/MpntplPaW6 github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= github.com/sourcegraph/zoekt v0.0.0-20240418025752-74e75efaded6 h1:ZoA5u9P6wjoUFwfgi+alUVLJ60dc0XkshTjzDNoQpGg= github.com/sourcegraph/zoekt v0.0.0-20240418025752-74e75efaded6/go.mod h1:+j+huwz4ZnffJmDHeLJyI9AY4a8DKQnfNV0J//upnyo= +github.com/sourcegraph/zoekt v0.0.0-20240501072156-72f95004e6d6 h1:aXHLpH1rhdvg4gQOiQWLkqVd3D/DG2li5Nnf6WE7mRs= +github.com/sourcegraph/zoekt v0.0.0-20240501072156-72f95004e6d6/go.mod h1:K7dYKxtKLPBRwu55Useje/JUZEuWgzlu5O1F8VFHfwE= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v0.0.0-20170901052352-ee1bd8ee15a1/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= From f76dca5e03d9bb3b7b7475be2134ec36e1003ea9 Mon Sep 17 00:00:00 2001 From: Stefan Hengl Date: Wed, 1 May 2024 09:53:41 +0200 Subject: [PATCH 2/5] update call sites of SenderFunc --- cmd/frontend/graphqlbackend/BUILD.bazel | 1 - cmd/frontend/graphqlbackend/repository_text_search_index.go | 3 +-- internal/search/backend/BUILD.bazel | 1 - internal/search/backend/horizontal.go | 3 +-- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/cmd/frontend/graphqlbackend/BUILD.bazel b/cmd/frontend/graphqlbackend/BUILD.bazel index 0400f2ab584e..a9579b3871b0 100644 --- a/cmd/frontend/graphqlbackend/BUILD.bazel +++ b/cmd/frontend/graphqlbackend/BUILD.bazel @@ -375,7 +375,6 @@ go_library( "@com_github_sourcegraph_log//:log", "@com_github_sourcegraph_zoekt//:zoekt", "@com_github_sourcegraph_zoekt//query", - "@com_github_sourcegraph_zoekt//stream", "@com_github_stretchr_testify//require", "@com_github_throttled_throttled_v2//:throttled", "@io_opentelemetry_go_otel//:otel", diff --git a/cmd/frontend/graphqlbackend/repository_text_search_index.go b/cmd/frontend/graphqlbackend/repository_text_search_index.go index dded9f04ade3..46327b567866 100644 --- a/cmd/frontend/graphqlbackend/repository_text_search_index.go +++ b/cmd/frontend/graphqlbackend/repository_text_search_index.go @@ -10,7 +10,6 @@ import ( "github.com/grafana/regexp" "github.com/sourcegraph/zoekt" zoektquery "github.com/sourcegraph/zoekt/query" - "github.com/sourcegraph/zoekt/stream" "github.com/sourcegraph/sourcegraph/internal/gitserver" "github.com/sourcegraph/sourcegraph/internal/gqlutil" @@ -256,7 +255,7 @@ func (r *skippedIndexedResolver) Count(ctx context.Context) (BigInt, error) { // ask for ChunkMatches from Sourcegraph. ChunkMatches: true, }, - stream.SenderFunc(func(sr *zoekt.SearchResult) { + zoekt.SenderFunc(func(sr *zoekt.SearchResult) { stats.Add(sr.Stats) }), ); err != nil { diff --git a/internal/search/backend/BUILD.bazel b/internal/search/backend/BUILD.bazel index 0476ed6f0497..43c0fb106811 100644 --- a/internal/search/backend/BUILD.bazel +++ b/internal/search/backend/BUILD.bazel @@ -39,7 +39,6 @@ go_library( "@com_github_sourcegraph_zoekt//cmd/zoekt-sourcegraph-indexserver/protos/sourcegraph/zoekt/configuration/v1:configuration", "@com_github_sourcegraph_zoekt//grpc/protos/zoekt/webserver/v1:webserver", "@com_github_sourcegraph_zoekt//query", - "@com_github_sourcegraph_zoekt//stream", "@io_opentelemetry_go_otel//attribute", "@org_golang_google_grpc//:go_default_library", "@org_golang_google_grpc//codes", diff --git a/internal/search/backend/horizontal.go b/internal/search/backend/horizontal.go index 40416047c909..ba3554eac7ef 100644 --- a/internal/search/backend/horizontal.go +++ b/internal/search/backend/horizontal.go @@ -14,7 +14,6 @@ import ( "github.com/sourcegraph/conc/pool" "github.com/sourcegraph/zoekt" "github.com/sourcegraph/zoekt/query" - "github.com/sourcegraph/zoekt/stream" "go.opentelemetry.io/otel/attribute" "github.com/sourcegraph/sourcegraph/internal/conf" @@ -64,7 +63,7 @@ func (s *HorizontalSearcher) StreamSearch(ctx context.Context, q query.Q, opts * pl := pool.New().WithErrors() for endpoint, client := range clients { pl.Go(func() error { - err := client.StreamSearch(ctx, q, opts, stream.SenderFunc(func(sr *zoekt.SearchResult) { + err := client.StreamSearch(ctx, q, opts, zoekt.SenderFunc(func(sr *zoekt.SearchResult) { // This shouldn't happen, but skip event if sr is nil. if sr == nil { return From 5e6cc2ad6840d3d8b5b9cab7fa01118e9b55a607 Mon Sep 17 00:00:00 2001 From: Stefan Hengl Date: Wed, 1 May 2024 10:13:42 +0200 Subject: [PATCH 3/5] remove RPC optimizations --- internal/search/backend/cached.go | 3 --- internal/search/backend/metered_searcher.go | 8 -------- 2 files changed, 11 deletions(-) diff --git a/internal/search/backend/cached.go b/internal/search/backend/cached.go index dd916ca94a86..7e5a39c9d835 100644 --- a/internal/search/backend/cached.go +++ b/internal/search/backend/cached.go @@ -81,9 +81,6 @@ func (c *cachedSearcher) List(ctx context.Context, q zoektquery.Q, opts *zoekt.L // isTrueQuery returns true if q will always match all shards. func isTrueQuery(q zoektquery.Q) bool { - // the query is probably wrapped to avoid extra RPC work. - q = zoektquery.RPCUnwrap(q) - v, ok := q.(*zoektquery.Const) return ok && v.Value } diff --git a/internal/search/backend/metered_searcher.go b/internal/search/backend/metered_searcher.go index a037941cc91c..c747f8b32825 100644 --- a/internal/search/backend/metered_searcher.go +++ b/internal/search/backend/metered_searcher.go @@ -96,14 +96,6 @@ func (m *meteredSearcher) StreamSearch(ctx context.Context, q query.Q, opts *zoe tr, ctx := trace.New(ctx, "zoekt."+cat, attrs...) defer tr.EndWithErrIfNotContext(&err) - // We wrap our queries in GobCache, this gives us a convenient way to find - // out the marshalled size of the query. - if gobCache, ok := q.(*query.GobCache); ok { - b, _ := gobCache.GobEncode() - tr.SetAttributes(attribute.Int("query.size", len(b))) - event.AddField("query.size", len(b)) - } - // Instrument the RPC layer var writeRequestStart, writeRequestDone time.Time if isLeaf { From 49fed5934d3f07bcaa5d2fef5bd218610de392fc Mon Sep 17 00:00:00 2001 From: Stefan Hengl Date: Wed, 1 May 2024 10:17:04 +0200 Subject: [PATCH 4/5] go mod tidy --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index b82e5301acc3..d0122c5b939b 100644 --- a/go.sum +++ b/go.sum @@ -1707,8 +1707,6 @@ github.com/sourcegraph/sourcegraph-accounts-sdk-go v0.0.0-20240426173441-db5b0a1 github.com/sourcegraph/sourcegraph-accounts-sdk-go v0.0.0-20240426173441-db5b0a145ceb/go.mod h1:xul4Fiph3Pvdx/1qsmhCUL2GBeYjTcnga0LXZEbKdGo= github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152 h1:z/MpntplPaW6QW95pzcAR/72Z5TWDyDnSo0EOcyij9o= github.com/sourcegraph/yaml v1.0.1-0.20200714132230-56936252f152/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= -github.com/sourcegraph/zoekt v0.0.0-20240418025752-74e75efaded6 h1:ZoA5u9P6wjoUFwfgi+alUVLJ60dc0XkshTjzDNoQpGg= -github.com/sourcegraph/zoekt v0.0.0-20240418025752-74e75efaded6/go.mod h1:+j+huwz4ZnffJmDHeLJyI9AY4a8DKQnfNV0J//upnyo= github.com/sourcegraph/zoekt v0.0.0-20240501072156-72f95004e6d6 h1:aXHLpH1rhdvg4gQOiQWLkqVd3D/DG2li5Nnf6WE7mRs= github.com/sourcegraph/zoekt v0.0.0-20240501072156-72f95004e6d6/go.mod h1:K7dYKxtKLPBRwu55Useje/JUZEuWgzlu5O1F8VFHfwE= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= From e06626b61cf10471d3d510d4d187ed756855360e Mon Sep 17 00:00:00 2001 From: Stefan Hengl Date: Wed, 1 May 2024 10:23:04 +0200 Subject: [PATCH 5/5] deps.bzl --- deps.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deps.bzl b/deps.bzl index d6889d3a1fe1..fe08134b6684 100644 --- a/deps.bzl +++ b/deps.bzl @@ -5494,8 +5494,8 @@ def go_dependencies(): patches = [ "//third_party/com_github_sourcegraph_zoekt:x_defs_version.patch", ], - sum = "h1:ZoA5u9P6wjoUFwfgi+alUVLJ60dc0XkshTjzDNoQpGg=", - version = "v0.0.0-20240418025752-74e75efaded6", + sum = "h1:aXHLpH1rhdvg4gQOiQWLkqVd3D/DG2li5Nnf6WE7mRs=", + version = "v0.0.0-20240501072156-72f95004e6d6", ) go_repository( name = "com_github_spaolacci_murmur3",