Skip to content
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
4 changes: 3 additions & 1 deletion pkg/chunk/chunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ func (c *Chunk) Decode(decodeContext *DecodeContext, input []byte) error {
if err != nil {
return errors.Wrap(err, "when decoding chunk metadata")
}
if len(input)-r.Len() != int(metadataLen) {
metadataRead := len(input) - r.Len()
// Older versions of Cortex included the initial length word; newer versions do not.
if !(metadataRead == int(metadataLen) || metadataRead == int(metadataLen)+4) {
return ErrMetadataLength
}

Expand Down
1 change: 1 addition & 0 deletions pkg/chunk/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
)

var (
chunkTimeRangeKeyV1a = []byte{1}
chunkTimeRangeKeyV1 = []byte{'1'}
chunkTimeRangeKeyV2 = []byte{'2'}
chunkTimeRangeKeyV3 = []byte{'3'}
Expand Down
3 changes: 3 additions & 0 deletions pkg/chunk/schema_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ func parseChunkTimeRangeValue(rangeValue []byte, value []byte) (

// v3 schema had four components - label name, label value, chunk ID and version.
// "version" is 1 and label value is base64 encoded.
// (older code wrote "version" as 1, not '1')
case bytes.Equal(components[3], chunkTimeRangeKeyV1a):
fallthrough
case bytes.Equal(components[3], chunkTimeRangeKeyV1):
chunkID = string(components[2])
labelValue, err = decodeBase64Value(components[1])
Expand Down