mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Periodically trigger compaction
This addresses an issue where the compaction triggered on cutting a new block doesn't find anything as the writers are still active on the block that should be ready for compaction.
This commit is contained in:
parent
db5c88ea9a
commit
6c4217276f
8
db.go
8
db.go
|
@ -187,8 +187,16 @@ func Open(dir string, l log.Logger, r prometheus.Registerer, opts *Options) (db
|
||||||
func (db *DB) run() {
|
func (db *DB) run() {
|
||||||
defer close(db.donec)
|
defer close(db.donec)
|
||||||
|
|
||||||
|
tick := time.NewTicker(30 * time.Second)
|
||||||
|
defer tick.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
case <-tick.C:
|
||||||
|
select {
|
||||||
|
case db.compactc <- struct{}{}:
|
||||||
|
default:
|
||||||
|
}
|
||||||
case <-db.compactc:
|
case <-db.compactc:
|
||||||
db.metrics.compactionsTriggered.Inc()
|
db.metrics.compactionsTriggered.Inc()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue