Skip to content
This repository was archived by the owner on Aug 13, 2019. It is now read-only.

Commit 4690f00

Browse files
committed
Fix tests after rebase
Signed-off-by: Goutham Veeramachaneni <[email protected]>
1 parent 59ebdbd commit 4690f00

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ func (db *DB) retentionCutoff() (b bool, err error) {
371371
// Appender opens a new appender against the database.
372372
func (db *DB) Appender() Appender {
373373
db.writeMtx.Lock()
374-
id := db.writeLastId
375374
db.writeLastId++
375+
id := db.writeLastId
376376
db.writesOpen[id] = struct{}{}
377377
db.writeMtx.Unlock()
378378

db_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,9 @@ func readSeriesSet(t *testing.T, ss SeriesSet) map[string][]sample {
10121012
t, v := it.At()
10131013
samples = append(samples, sample{t: t, v: v})
10141014
}
1015+
if len(samples) == 0 {
1016+
continue
1017+
}
10151018

10161019
name := series.Labels().String()
10171020
seriesSet[name] = samples

head.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,14 +402,17 @@ func (h *rangeHead) Tombstones() (TombstoneReader, error) {
402402
type initAppender struct {
403403
app Appender
404404
head *Head
405+
406+
writeId uint64
407+
cleanupWriteIdsBelow uint64
405408
}
406409

407410
func (a *initAppender) Add(lset labels.Labels, t int64, v float64) (uint64, error) {
408411
if a.app != nil {
409412
return a.app.Add(lset, t, v)
410413
}
411414
a.head.initTime(t)
412-
a.app = a.head.appender(0, 0)
415+
a.app = a.head.appender(a.writeId, a.cleanupWriteIdsBelow)
413416

414417
return a.app.Add(lset, t, v)
415418
}
@@ -442,7 +445,7 @@ func (h *Head) Appender(writeId, cleanupWriteIdsBelow uint64) Appender {
442445
// The head cache might not have a starting point yet. The init appender
443446
// picks up the first appended timestamp as the base.
444447
if h.MinTime() == math.MinInt64 {
445-
return &initAppender{head: h}
448+
return &initAppender{head: h, writeId: writeId, cleanupWriteIdsBelow: cleanupWriteIdsBelow}
446449
}
447450
return h.appender(writeId, cleanupWriteIdsBelow)
448451
}
@@ -1296,13 +1299,16 @@ func computeChunkEndTime(start, cur, max int64) int64 {
12961299

12971300
func (s *memSeries) iterator(id int, isolation *IsolationState) chunkenc.Iterator {
12981301
c := s.chunk(id)
1302+
12991303
// TODO(fabxc): Work around! A querier may have retrieved a pointer to a series' chunk,
13001304
// which got then garbage collected before it got accessed.
13011305
// We must ensure to not garbage collect as long as any readers still hold a reference.
13021306
if c == nil {
13031307
return chunkenc.NewNopIterator()
13041308
}
13051309

1310+
ix := id - s.firstChunkID
1311+
13061312
numSamples := c.chunk.NumSamples()
13071313
stopAfter := numSamples
13081314

@@ -1311,7 +1317,7 @@ func (s *memSeries) iterator(id int, isolation *IsolationState) chunkenc.Iterato
13111317
previousSamples := 0 // Samples before this chunk.
13121318
for j, d := range s.chunks {
13131319
totalSamples += d.chunk.NumSamples()
1314-
if j < id {
1320+
if j < ix {
13151321
previousSamples += d.chunk.NumSamples()
13161322
}
13171323
}

0 commit comments

Comments
 (0)