chore: use quartz in metastore (#13900)

pull/14072/head^2
George Robinson 9 months ago committed by GitHub
parent e9cec1d159
commit 4cd77b9747
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      pkg/ingester-rf1/metastore/metastore.go
  2. 2
      pkg/ingester-rf1/metastore/metastore_hack.go

@ -12,6 +12,7 @@ import (
"sync"
"time"
"github.com/coder/quartz"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/grafana/dskit/flagext"
@ -88,6 +89,9 @@ type Metastore struct {
done chan struct{}
wg sync.WaitGroup
// Used in tests.
clock quartz.Clock
}
func New(config Config, logger log.Logger, reg prometheus.Registerer, hs health.Service) (*Metastore, error) {
@ -97,6 +101,7 @@ func New(config Config, logger log.Logger, reg prometheus.Registerer, hs health.
reg: reg,
db: newDB(config, logger),
done: make(chan struct{}),
clock: quartz.NewReal(),
}
m.leaderhealth = raftleader.NewRaftLeaderHealthObserver(hs, logger)
m.state = newMetastoreState(logger, m.db)

@ -29,7 +29,7 @@ func (m *Metastore) cleanupLoop() {
if m.raft.State() != raft.Leader {
continue
}
timestamp := uint64(time.Now().Add(-1 * time.Hour).UnixMilli())
timestamp := uint64(m.clock.Now().Add(-1 * time.Hour).UnixMilli())
req := &raftlogpb.TruncateCommand{Timestamp: timestamp}
_, _, err := applyCommand[*raftlogpb.TruncateCommand, *anypb.Any](m.raft, req, m.config.Raft.ApplyTimeout)
if err != nil {

Loading…
Cancel
Save