Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes a panic in the query-tee. #4465

Merged
merged 2 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
* [ENHANCEMENT] Updated Prometheus to include changes from prometheus/prometheus#9083. Now whenever `/labels` API calls include matchers, blocks store is queried for `LabelNames` with matchers instead of `Series` calls which was inefficient. #4380
* [ENHANCEMENT] Exemplars are now emitted for all gRPC calls and many operations tracked by histograms. #4462
* [ENHANCEMENT] New options `-server.http-listen-network` and `-server.grpc-listen-network` allow binding as 'tcp4' or 'tcp6'. #4462
* [BUGFIX] Fixes a panic in the query-tee when comparing result. #4465
* [BUGFIX] Frontend: Fixes @ modifier functions (start/end) when splitting queries by time. #4464
* [BUGFIX] Compactor: compactor will no longer try to compact blocks that are already marked for deletion. Previously compactor would consider blocks marked for deletion within `-compactor.deletion-delay / 2` period as eligible for compaction. #4328
* [BUGFIX] HA Tracker: when cleaning up obsolete elected replicas from KV store, tracker didn't update number of cluster per user correctly. #4336
Expand Down
7 changes: 6 additions & 1 deletion tools/querytee/proxy_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ func (p *ProxyEndpoint) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func (p *ProxyEndpoint) executeBackendRequests(r *http.Request, resCh chan *backendResponse) {
responses := make([]*backendResponse, 0, len(p.backends))

wg := sync.WaitGroup{}
var (
wg = sync.WaitGroup{}
mtx = sync.Mutex{}
)
wg.Add(len(p.backends))

for _, b := range p.backends {
Expand Down Expand Up @@ -105,7 +108,9 @@ func (p *ProxyEndpoint) executeBackendRequests(r *http.Request, resCh chan *back

// Keep track of the response if required.
if p.comparator != nil {
mtx.Lock()
responses = append(responses, res)
mtx.Unlock()
}

resCh <- res
Expand Down
10 changes: 9 additions & 1 deletion tools/querytee/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ import (
)

var testRoutes = []Route{
{Path: "/api/v1/query", RouteName: "api_v1_query", Methods: []string{"GET"}, ResponseComparator: nil},
{Path: "/api/v1/query", RouteName: "api_v1_query", Methods: []string{"GET"}, ResponseComparator: &testComparator{}},
}

type testComparator struct{}

func (testComparator) Compare(expected, actual []byte) error { return nil }

func Test_NewProxy(t *testing.T) {
cfg := ProxyConfig{}

Expand Down Expand Up @@ -156,6 +160,10 @@ func Test_Proxy_RequestsForwarding(t *testing.T) {
BackendReadTimeout: time.Second,
}

if len(backendURLs) == 2 {
cfg.CompareResponses = true
}

p, err := NewProxy(cfg, log.NewNopLogger(), testRoutes, nil)
require.NoError(t, err)
require.NotNil(t, p)
Expand Down