Skip to content

Commit d1520f2

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

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
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: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ func (r *RemoteWriteClient) connect(ctx context.Context) error {
109109
r.mu.Lock()
110110
defer r.mu.Unlock()
111111
if r.conn != nil {
112+
s := capnp.Client(r.writer).State()
113+
if !s.IsPromise {
114+
if err, ok := s.Brand.Value.(error); ok {
115+
// If bootstrap failed, close the connection to force a reconnect.
116+
r.closeUnlocked()
117+
return errors.Wrap(err, "client in error state")
118+
}
119+
}
120+
112121
return nil
113122
}
114123

@@ -123,11 +132,15 @@ func (r *RemoteWriteClient) connect(ctx context.Context) error {
123132

124133
func (r *RemoteWriteClient) Close() error {
125134
r.mu.Lock()
135+
r.closeUnlocked()
136+
r.mu.Unlock()
137+
return nil
138+
}
139+
140+
func (r *RemoteWriteClient) closeUnlocked() {
126141
if r.conn != nil {
127142
conn := r.conn
128143
r.conn = nil
129144
go conn.Close()
130145
}
131-
r.mu.Unlock()
132-
return nil
133146
}

0 commit comments

Comments
 (0)