mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 05:04:05 -08:00
Do not attempt isolation for appendID == 0
Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
parent
0e78908407
commit
d9af11e636
|
@ -1847,7 +1847,8 @@ func (s *memSeries) truncateChunksBefore(mint int64) (removed int) {
|
|||
}
|
||||
|
||||
// append adds the sample (t, v) to the series. The caller also has to provide
|
||||
// the appendID for isolation.
|
||||
// the appendID for isolation. (The appendID can be zero, which results in no
|
||||
// isolation for this append.)
|
||||
func (s *memSeries) append(t int64, v float64, appendID uint64) (success, chunkCreated bool) {
|
||||
// Based on Gorilla white papers this offers near-optimal compression ratio
|
||||
// so anything bigger that this has diminishing returns and increases
|
||||
|
@ -1885,7 +1886,9 @@ func (s *memSeries) append(t int64, v float64, appendID uint64) (success, chunkC
|
|||
s.sampleBuf[2] = s.sampleBuf[3]
|
||||
s.sampleBuf[3] = sample{t: t, v: v}
|
||||
|
||||
s.txs.add(appendID)
|
||||
if appendID > 0 {
|
||||
s.txs.add(appendID)
|
||||
}
|
||||
|
||||
return true, chunkCreated
|
||||
}
|
||||
|
|
|
@ -1558,7 +1558,7 @@ func TestIsolationLowWatermarkMonotonous(t *testing.T) {
|
|||
_, err = app1.Add(labels.FromStrings("foo", "bar"), 0, 0)
|
||||
testutil.Ok(t, err)
|
||||
testutil.Ok(t, app1.Commit())
|
||||
testutil.Equals(t, uint64(1), hb.iso.lowWatermark())
|
||||
testutil.Equals(t, uint64(1), hb.iso.lowWatermark(), "Low watermark should by 1 after 1st append.")
|
||||
|
||||
app1 = hb.Appender()
|
||||
_, err = app1.Add(labels.FromStrings("foo", "bar"), 1, 1)
|
||||
|
@ -1580,3 +1580,17 @@ func TestIsolationLowWatermarkMonotonous(t *testing.T) {
|
|||
is.Close()
|
||||
testutil.Equals(t, uint64(3), hb.iso.lowWatermark(), "After read has finished (iso state closed), low watermark should jump to three.")
|
||||
}
|
||||
|
||||
func TestIsolationAppendIDZeroIsNoop(t *testing.T) {
|
||||
h, err := NewHead(nil, nil, nil, 1000, DefaultStripeSize)
|
||||
testutil.Ok(t, err)
|
||||
defer h.Close()
|
||||
|
||||
h.initTime(0)
|
||||
|
||||
s, _ := h.getOrCreate(1, labels.FromStrings("a", "1"))
|
||||
|
||||
ok, _ := s.append(0, 0, 0)
|
||||
testutil.Assert(t, ok, "Series append failed.")
|
||||
testutil.Equals(t, 0, s.txs.txIDCount, "Series should not have an appendID after append with appendID=0.")
|
||||
}
|
||||
|
|
|
@ -110,7 +110,8 @@ func (i *isolation) State() *isolationState {
|
|||
return isoState
|
||||
}
|
||||
|
||||
// newAppendID increments the transaction counter and returns a new transaction ID.
|
||||
// newAppendID increments the transaction counter and returns a new transaction
|
||||
// ID. The first ID returned is 1.
|
||||
func (i *isolation) newAppendID() uint64 {
|
||||
i.appendMtx.Lock()
|
||||
defer i.appendMtx.Unlock()
|
||||
|
|
Loading…
Reference in a new issue