Skip to content

Commit ad74391

Browse files
authored
Merge pull request #8351 from thanos-io/rel_0391
Release 0.39.1
2 parents 0453c9b + e9bdd79 commit ad74391

File tree

3 files changed

+34
-23
lines changed

3 files changed

+34
-23
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ NOTE: As semantic versioning states all 0.y.z releases can contain breaking chan
88

99
We use *breaking :warning:* to mark changes that are not backward compatible (relates only to v0.y.z releases.)
1010

11+
### [v0.39.1](https://github.com/thanos-io/thanos/tree/release-0.39) - 2025 07 01
12+
13+
Fixes a memory leak issue on query-frontend. The bug only affects v0.39.0.
14+
15+
### Fixed
16+
17+
- [#8349](https://github.com/thanos-io/thanos/pull/8349) Query-Frontend: properly clean up resources
18+
- [#8338](https://github.com/thanos-io/thanos/pull/8338) Query-Frontend: use original roundtripper + close immediately
19+
1120
### [v0.39.0](https://github.com/thanos-io/thanos/tree/release-0.39) - 2025 06 25
1221

1322
In short: there are a bunch of fixes and small improvements. The shining items in this release are memory usage improvements in Thanos Query and shuffle sharding support in Thanos Receiver. Information about shuffle sharding support is available in the documentation. Thank you to all contributors!

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.39.0
1+
0.39.1

cmd/thanos/query_frontend.go

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -329,13 +329,13 @@ func runQueryFrontend(
329329
return err
330330
}
331331

332-
roundTripper, err := cortexfrontend.NewDownstreamRoundTripper(cfg.DownstreamURL, downstreamTripper)
332+
downstreamRT, err := cortexfrontend.NewDownstreamRoundTripper(cfg.DownstreamURL, downstreamTripper)
333333
if err != nil {
334334
return errors.Wrap(err, "setup downstream roundtripper")
335335
}
336336

337337
// Wrap the downstream RoundTripper into query frontend Tripperware.
338-
roundTripper = tripperWare(roundTripper)
338+
roundTripper := tripperWare(downstreamRT)
339339

340340
// Create the query frontend transport.
341341
handler := transport.NewHandler(*cfg.CortexHandlerConfig, roundTripper, logger, nil)
@@ -402,17 +402,9 @@ func runQueryFrontend(
402402
ctx, cancel := context.WithCancel(context.Background())
403403

404404
g.Add(func() error {
405-
406405
var firstRun = true
407-
for {
408-
if !firstRun {
409-
select {
410-
case <-ctx.Done():
411-
return nil
412-
case <-time.After(10 * time.Second):
413-
}
414-
}
415406

407+
doCheckDownstream := func() (rerr error) {
416408
timeoutCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
417409
defer cancel()
418410

@@ -422,23 +414,33 @@ func runQueryFrontend(
422414
return errors.Wrap(err, "creating request to downstream URL")
423415
}
424416

425-
resp, err := roundTripper.RoundTrip(req)
417+
resp, err := downstreamRT.RoundTrip(req)
426418
if err != nil {
427-
level.Warn(logger).Log("msg", "failed to reach downstream URL", "err", err, "readiness_url", readinessUrl)
428-
statusProber.NotReady(err)
429-
firstRun = false
430-
continue
419+
return errors.Wrapf(err, "roundtripping to downstream URL %s", readinessUrl)
431420
}
432-
runutil.ExhaustCloseWithLogOnErr(logger, resp.Body, "downstream health check response body")
421+
defer runutil.CloseWithErrCapture(&rerr, resp.Body, "downstream health check response body")
433422

434423
if resp.StatusCode/100 == 4 || resp.StatusCode/100 == 5 {
435-
level.Warn(logger).Log("msg", "downstream URL returned an error", "status_code", resp.StatusCode, "readiness_url", readinessUrl)
436-
statusProber.NotReady(errors.Errorf("downstream URL %s returned an error: %d", readinessUrl, resp.StatusCode))
437-
firstRun = false
438-
continue
424+
return errors.Errorf("downstream URL %s returned an error: %d", readinessUrl, resp.StatusCode)
425+
}
426+
427+
return nil
428+
}
429+
for {
430+
if !firstRun {
431+
select {
432+
case <-ctx.Done():
433+
return nil
434+
case <-time.After(10 * time.Second):
435+
}
439436
}
437+
firstRun = false
440438

441-
statusProber.Ready()
439+
if err := doCheckDownstream(); err != nil {
440+
statusProber.NotReady(err)
441+
} else {
442+
statusProber.Ready()
443+
}
442444
}
443445
}, func(err error) {
444446
cancel()

0 commit comments

Comments
 (0)