Skip to content

Commit

Permalink
Merge pull request #6203 from fpetkovski/tsdb-copy-chunks
Browse files Browse the repository at this point in the history
Copy chunk bytes in TSDB store before sending to client
  • Loading branch information
fpetkovski committed Mar 13, 2023
2 parents 5262948 + 681a17a commit 9992c4c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re

### Fixed

- [#6203](https://github.com/thanos-io/thanos/pull/6203) Receive: Fix panic in head compaction under high query load.

### Changed

### Removed
Expand Down
6 changes: 4 additions & 2 deletions pkg/store/tsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,15 @@ func (s *TSDBStore) Series(r *storepb.SeriesRequest, srv storepb.Store_SeriesSer
return status.Errorf(codes.Internal, "TSDBStore: found not populated chunk returned by SeriesSet at ref: %v", chk.Ref)
}

chunkBytes := make([]byte, len(chk.Chunk.Bytes()))
copy(chunkBytes, chk.Chunk.Bytes())
c := storepb.AggrChunk{
MinTime: chk.MinTime,
MaxTime: chk.MaxTime,
Raw: &storepb.Chunk{
Type: storepb.Chunk_Encoding(chk.Chunk.Encoding() - 1), // Proto chunk encoding is one off to TSDB one.
Data: chk.Chunk.Bytes(),
Hash: hashChunk(hasher, chk.Chunk.Bytes(), enableChunkHashCalculation),
Data: chunkBytes,
Hash: hashChunk(hasher, chunkBytes, enableChunkHashCalculation),
},
}
frameBytesLeft -= c.Size()
Expand Down

0 comments on commit 9992c4c

Please sign in to comment.