Skip to content

Commit

Permalink
headblock checkpointing up to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-d committed Dec 1, 2020
1 parent dcbfecf commit 60072f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/chunkenc/memchunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,10 @@ func (hb *headBlock) FromCheckpoint(b []byte) error {
if db.err() != nil {
return errors.Wrap(db.err(), "verifying headblock header")
}
if version != chunkFormatV3 {
return errors.New("incompatible headBlock version, only V3 is currently supported")
switch version {
case chunkFormatV1, chunkFormatV2, chunkFormatV3:
default:
return errors.Errorf("incompatible headBlock version (%v), only V1,V2,V3 is currently supported", version)
}

ln := db.uvarint()
Expand Down
8 changes: 8 additions & 0 deletions pkg/chunkenc/memchunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,14 @@ func TestCheckpointEncoding(t *testing.T) {

cpy, err := MemchunkFromCheckpoint(chk, head, blockSize, targetSize)
require.Nil(t, err)

// TODO(owen-d): remove once v3+ is the default chunk version
// because that is when we started serializing uncompressed size.
// Until then, nil them out in order to ease equality testing.
for i := range c.blocks {
c.blocks[i].uncompressedSize = 0
}

require.Equal(t, c, cpy)
}

Expand Down

0 comments on commit 60072f2

Please sign in to comment.