Skip to content

Commit 6b642ff

Browse files
committed
Receive: fix capnproto replication in endless loop
Signed-off-by: Michał Mazur <[email protected]>
1 parent 72937ab commit 6b642ff

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
1010

1111
## Unreleased
1212

13+
### Fixed
14+
15+
- [#8254](https://github.com/thanos-io/thanos/issues/8254) Receive: Endless loop of retried replication with capnproto and distributors
16+
1317
## [v0.40.0](https://github.com/thanos-io/thanos/tree/release-0.40) - 2025 10 20 (in progress)
1418

1519
### Fixed
@@ -22,22 +26,21 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
2226

2327
- [#8366](https://github.com/thanos-io/thanos/pull/8366) Store: optionally ignore Parquet migrated blocks
2428
- [#8359](https://github.com/thanos-io/thanos/pull/8359) Tools: add `--shipper.upload-compacted` flag for uploading compacted blocks to bucket upload-blocks
25-
- [#8484](https://github.com/thanos-io/thanos/pull/8484) Query: add `/api/v1/status/tsdb` API endpoint.
2629

2730
### Changed
2831

2932
- [#8370](https://github.com/thanos-io/thanos/pull/8370) Query: announced labelset now reflects relabel-config
3033

3134
### Removed
3235

33-
## [v0.39.2](https://github.com/thanos-io/thanos/tree/release-0.39) - 2025 07 17
36+
### [v0.39.2](https://github.com/thanos-io/thanos/tree/release-0.39) - 2025 07 17
3437

3538
### Fixed
3639

3740
- [#8374](https://github.com/thanos-io/thanos/pull/8374) Query: fix panic when concurrently accessing annotations map
3841
- [#8375](https://github.com/thanos-io/thanos/pull/8375) Query: fix native histogram buckets in distributed queries
3942

40-
## [v0.39.1](https://github.com/thanos-io/thanos/tree/release-0.39) - 2025 07 01
43+
### [v0.39.1](https://github.com/thanos-io/thanos/tree/release-0.39) - 2025 07 01
4144

4245
Fixes a memory leak issue on query-frontend. The bug only affects v0.39.0.
4346

pkg/receive/writecapnp/client.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,28 @@ func (r *RemoteWriteClient) connect(ctx context.Context) error {
117117
return errors.Wrap(err, "failed to dial peer")
118118
}
119119
r.conn = rpc.NewConn(rpc.NewPackedStreamTransport(conn), nil)
120-
r.writer = Writer(r.conn.Bootstrap(ctx))
120+
writer := Writer(r.conn.Bootstrap(ctx))
121+
if err := writer.Resolve(ctx); err != nil {
122+
level.Warn(r.logger).Log("msg", "failed to bootstrap capnp writer, closing connection", "err", err)
123+
r.closeUnlocked()
124+
return errors.Wrap(err, "failed to bootstrap capnp writer")
125+
}
126+
127+
r.writer = writer
121128
return nil
122129
}
123130

124131
func (r *RemoteWriteClient) Close() error {
125132
r.mu.Lock()
133+
r.closeUnlocked()
134+
r.mu.Unlock()
135+
return nil
136+
}
137+
138+
func (r *RemoteWriteClient) closeUnlocked() {
126139
if r.conn != nil {
127140
conn := r.conn
128141
r.conn = nil
129142
go conn.Close()
130143
}
131-
r.mu.Unlock()
132-
return nil
133144
}

0 commit comments

Comments
 (0)