diff --git a/block_test.go b/block_test.go index 0f164ae06..addb5ea97 100644 --- a/block_test.go +++ b/block_test.go @@ -15,7 +15,6 @@ package tsdb import ( "context" - "fmt" "io/ioutil" "math/rand" "os" @@ -70,22 +69,20 @@ func createBlock(tb testing.TB, dir string, nSeries int, mint, maxt int64) strin lbls, err := labels.ReadLabels(filepath.Join("testdata", "20kseries.json"), nSeries) testutil.Ok(tb, err) - var ref uint64 - - fmt.Println(len(lbls)) + refs := make([]uint64, nSeries) for ts := mint; ts <= maxt; ts++ { app := head.Appender() for i, lbl := range lbls { - if i > 0 && lbl.String() == lbls[i-1].String() { - err := app.AddFast(ref, ts, rand.Float64()) + if refs[i] != 0 { + err := app.AddFast(refs[i], ts, rand.Float64()) if err == nil { continue } } - ref, err = app.Add(lbl, int64(ts), rand.Float64()) + ref, err := app.Add(lbl, int64(ts), rand.Float64()) testutil.Ok(tb, err) - + refs[i] = ref } err := app.Commit() testutil.Ok(tb, err) diff --git a/compact.go b/compact.go index bf19199aa..33cd20adf 100644 --- a/compact.go +++ b/compact.go @@ -617,7 +617,6 @@ func (c *LeveledCompactor) populateBlock(blocks []BlockReader, meta *BlockMeta, c.metrics.populatingBlocks.Inc() - fmt.Println(blocks) for i, b := range blocks { select { case <-c.ctx.Done(): @@ -625,8 +624,6 @@ func (c *LeveledCompactor) populateBlock(blocks []BlockReader, meta *BlockMeta, default: } - fmt.Println("next block") - indexr, err := b.Index() if err != nil { return errors.Wrapf(err, "open index reader for block %s", b) @@ -689,7 +686,6 @@ func (c *LeveledCompactor) populateBlock(blocks []BlockReader, meta *BlockMeta, default: } - // fmt.Println("next set") lset, chks, dranges := set.At() // The chunks here are not fully deleted. // Skip the series with all deleted chunks. diff --git a/compact_test.go b/compact_test.go index b84cdf8dc..62db4d755 100644 --- a/compact_test.go +++ b/compact_test.go @@ -15,7 +15,6 @@ package tsdb import ( "context" - "fmt" "io/ioutil" "math" "os" @@ -753,8 +752,8 @@ func TestCancelCompactions(t *testing.T) { defer os.RemoveAll(tmpdir) // Create some blocks to fall within the compaction range. - createBlock(t, tmpdir, 1000, 0, 1000) - createBlock(t, tmpdir, 1000, 1000, 2000) + createBlock(t, tmpdir, 3000, 0, 1000) + createBlock(t, tmpdir, 3000, 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}}) @@ -764,8 +763,7 @@ func TestCancelCompactions(t *testing.T) { dbClosed := make(chan struct{}) for { if prom_testutil.ToFloat64(db.compactor.(*LeveledCompactor).metrics.populatingBlocks) > 0 { - fmt.Println("populating started.") - time.Sleep(2 * time.Millisecond) + time.Sleep(3 * time.Millisecond) go func() { testutil.Ok(t, db.Close()) close(dbClosed) diff --git a/db.go b/db.go index a580ea240..bfa52840c 100644 --- a/db.go +++ b/db.go @@ -819,9 +819,7 @@ func (db *DB) Head() *Head { // Close the partition. func (db *DB) Close() error { close(db.stopc) - // fmt.Println("closing") - // db.compactCnl() - // fmt.Println("closed") + db.compactCnl() <-db.donec db.mtx.Lock()