Skip to content

Commit fbc4206

Browse files
committed
Potential Fix
1 parent e30d871 commit fbc4206

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

tsdb/head.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,7 @@ func (s *stripeSeries) gc(mint int64) (map[storage.SeriesRef]struct{}, int, int6
13741374
s.locks[j].Lock()
13751375
}
13761376

1377+
series.abortCommit = true
13771378
deleted[storage.SeriesRef(series.ref)] = struct{}{}
13781379
s.hashes[i].del(hash, series.lset)
13791380
delete(s.series[j], series.ref)
@@ -1503,6 +1504,8 @@ type memSeries struct {
15031504

15041505
pendingCommit bool // Whether there are samples waiting to be committed to this series.
15051506

1507+
abortCommit bool // Whether there are samples waiting to be committed to this series.
1508+
15061509
// Current appender for the head chunk. Set when a new head chunk is cut.
15071510
// It is nil only if headChunk is nil. E.g. if there was an appender that created a new series, but rolled back the commit
15081511
// (the first sample would create a headChunk, hence appender, but rollback skipped it while the Append() call would create a series).

tsdb/head_append.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,10 @@ func (a *headAppender) Commit() (err error) {
448448
for i, s := range a.samples {
449449
series = a.sampleSeries[i]
450450
series.Lock()
451-
ok, chunkCreated := series.append(s.T, s.V, a.appendID, a.head.chunkDiskMapper)
451+
ok, chunkCreated := false, false
452+
if !series.abortCommit {
453+
ok, chunkCreated = series.append(s.T, s.V, a.appendID, a.head.chunkDiskMapper)
454+
}
452455
series.cleanupAppendIDsBelow(a.cleanupAppendIDsBelow)
453456
series.pendingCommit = false
454457
series.Unlock()

0 commit comments

Comments
 (0)