Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
This commit is contained in:
Krasi Georgiev 2019-01-18 19:21:09 +02:00
parent 921f82cfc1
commit 9874377ead
4 changed files with 9 additions and 20 deletions

View File

@ -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)

View File

@ -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.

View File

@ -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)

4
db.go
View File

@ -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()