fix the misleading log during compaction cancelation

Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
pull/5805/head
Krasi Georgiev 6 years ago
parent 9638c13ec8
commit 8ffd705346

@ -412,10 +412,11 @@ func (c *LeveledCompactor) Compact(dest string, dirs []string, open []*Block) (u
var merr MultiError
merr.Add(err)
for _, b := range bs {
if err := b.setCompactionFailed(); err != nil {
merr.Add(errors.Wrapf(err, "setting compaction failed for block: %s", b.Dir()))
if err != ErrCompactionCanceled {
for _, b := range bs {
if err := b.setCompactionFailed(); err != nil {
merr.Add(errors.Wrapf(err, "setting compaction failed for block: %s", b.Dir()))
}
}
}
@ -472,6 +473,9 @@ func (w *instrumentedChunkWriter) WriteChunks(chunks ...chunks.Meta) error {
return w.ChunkWriter.WriteChunks(chunks...)
}
// ErrCompactionCanceled is returned when the compaction was canceled during shutdown.
var ErrCompactionCanceled = errors.New("compaction cancelled")
// write creates a new block that is the union of the provided blocks into dir.
// It cleans up all files of the old blocks after completing successfully.
func (c *LeveledCompactor) write(dest string, meta *BlockMeta, blocks ...BlockReader) (err error) {
@ -539,7 +543,7 @@ func (c *LeveledCompactor) write(dest string, meta *BlockMeta, blocks ...BlockRe
if err := os.RemoveAll(tmp); err != nil {
level.Error(c.logger).Log("msg", "removed tmp folder after canceled compaction", "err", err.Error())
}
return
return ErrCompactionCanceled
default:
}

@ -753,8 +753,8 @@ func TestCancelCompactions(t *testing.T) {
testutil.Ok(t, err)
// Create some blocks to fall within the compaction range.
createBlock(t, tmpdir, 4000, 0, 1000)
createBlock(t, tmpdir, 4000, 1000, 2000)
createBlock(t, tmpdir, 10000, 0, 1000)
createBlock(t, tmpdir, 10000, 1000, 2000)
createBlock(t, tmpdir, 1, 2000, 2001) // The most recent block is ignored so can be e small one.
db, err := Open(tmpdir, log.NewNopLogger(), nil, &Options{BlockRanges: []int64{1, 2000}})
testutil.Ok(t, err)

Loading…
Cancel
Save