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

Commit

Permalink
Merge pull request #1175 from grafana/fix-1168
Browse files Browse the repository at this point in the history
aggregated chunk GC fix + lower default metric-max-stale
  • Loading branch information
Dieterbe authored Dec 11, 2018
2 parents 3acc3e5 + e104710 commit 75b8206
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docker/docker-chaos/metrictank.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ drop-first-chunk = false
# max age for a chunk before to be considered stale and to be persisted to Cassandra
chunk-max-stale = 1h
# max age for a metric before to be considered stale and to be purged from in-memory ring buffer.
metric-max-stale = 6h
metric-max-stale = 3h
# Interval to run garbage collection job
gc-interval = 1h

Expand Down
2 changes: 1 addition & 1 deletion docker/docker-cluster/metrictank.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ drop-first-chunk = false
# max age for a chunk before to be considered stale and to be persisted to Cassandra
chunk-max-stale = 1h
# max age for a metric before to be considered stale and to be purged from in-memory ring buffer.
metric-max-stale = 6h
metric-max-stale = 3h
# Interval to run garbage collection job
gc-interval = 1h

Expand Down
2 changes: 1 addition & 1 deletion docker/docker-dev-custom-cfg-kafka/metrictank.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ drop-first-chunk = false
# max age for a chunk before to be considered stale and to be persisted to Cassandra
chunk-max-stale = 1h
# max age for a metric before to be considered stale and to be purged from in-memory ring buffer.
metric-max-stale = 6h
metric-max-stale = 3h
# Interval to run garbage collection job
gc-interval = 1h

Expand Down
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ drop-first-chunk = false
# max age for a chunk before to be considered stale and to be persisted to Cassandra
chunk-max-stale = 1h
# max age for a metric before to be considered stale and to be purged from in-memory ring buffer.
metric-max-stale = 6h
metric-max-stale = 3h
# Interval to run garbage collection job
gc-interval = 1h
# duration before secondary nodes start serving requests
Expand Down
15 changes: 5 additions & 10 deletions mdata/aggmetric.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,24 +604,19 @@ func (a *AggMetric) GC(now, chunkMinTs, metricMinTs uint32) bool {
return false
}

if currentChunk.Series.Finished {
// already closed and should be saved, though we cant guarantee that.
// Check if we should just delete the metric from memory.
if a.lastWrite < metricMinTs {
return a.gcAggregators(now, chunkMinTs, metricMinTs)
}
} else {
// chunk hasn't been written to in a while, and is not yet closed. Let's close it and persist it if
// we are a primary
if !currentChunk.Series.Finished {
// chunk hasn't been written to in a while, and is not yet closed.
// Let's close it and persist it if we are a primary
log.Debugf("AM: Found stale Chunk, adding end-of-stream bytes. key: %v T0: %d", a.Key, currentChunk.Series.T0)
currentChunk.Finish()
a.pushToCache(currentChunk)
if cluster.Manager.IsPrimary() {
log.Debugf("AM: persist(): node is primary, saving chunk. %v T0: %d", a.Key, currentChunk.Series.T0)
// persist the chunk. If the writeQueue is full, then this will block.
a.persist(a.CurrentChunkPos)
}
}
return false
return a.gcAggregators(now, chunkMinTs, metricMinTs) && a.lastWrite < metricMinTs
}

// gcAggregators returns whether all aggregators are stale and can be removed
Expand Down
2 changes: 1 addition & 1 deletion metrictank-sample.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ drop-first-chunk = false
# max age for a chunk before to be considered stale and to be persisted to Cassandra
chunk-max-stale = 1h
# max age for a metric before to be considered stale and to be purged from in-memory ring buffer.
metric-max-stale = 6h
metric-max-stale = 3h
# Interval to run garbage collection job
gc-interval = 1h

Expand Down
2 changes: 1 addition & 1 deletion scripts/config/metrictank-docker.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ drop-first-chunk = false
# max age for a chunk before to be considered stale and to be persisted to Cassandra
chunk-max-stale = 1h
# max age for a metric before to be considered stale and to be purged from in-memory ring buffer.
metric-max-stale = 6h
metric-max-stale = 3h
# Interval to run garbage collection job
gc-interval = 1h

Expand Down
2 changes: 1 addition & 1 deletion scripts/config/metrictank-package.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ drop-first-chunk = false
# max age for a chunk before to be considered stale and to be persisted to Cassandra
chunk-max-stale = 1h
# max age for a metric before to be considered stale and to be purged from in-memory ring buffer.
metric-max-stale = 6h
metric-max-stale = 3h
# Interval to run garbage collection job
gc-interval = 1h

Expand Down

0 comments on commit 75b8206

Please sign in to comment.