Skip to content

Commit

Permalink
adds Start() method to WAL interface to delay checkpointing until aft…
Browse files Browse the repository at this point in the history
…er replay (#3339)
  • Loading branch information
owen-d authored Feb 15, 2021
1 parent 76e713f commit 862cfa4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/ingester/flush_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func TestChunkFlushingShutdown(t *testing.T) {
type fullWAL struct{}

func (fullWAL) Log(_ *WALRecord) error { return &os.PathError{Err: syscall.ENOSPC} }
func (fullWAL) Start() {}
func (fullWAL) Stop() error { return nil }

func Benchmark_FlushLoop(b *testing.B) {
Expand Down
1 change: 1 addition & 0 deletions pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ func (i *Ingester) starting(ctx context.Context) error {
i.metrics.walReplayDuration.Set(elapsed.Seconds())
level.Info(util_log.Logger).Log("msg", "recovery finished", "time", elapsed.String())

i.wal.Start()
}

i.InitFlushQueues()
Expand Down
7 changes: 6 additions & 1 deletion pkg/ingester/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (cfg *WALConfig) RegisterFlags(f *flag.FlagSet) {

// WAL interface allows us to have a no-op WAL when the WAL is disabled.
type WAL interface {
Start()
// Log marshalls the records and writes it into the WAL.
Log(*WALRecord) error
// Stop stops all the WAL operations.
Expand All @@ -60,6 +61,7 @@ type WAL interface {

type noopWAL struct{}

func (noopWAL) Start() {}
func (noopWAL) Log(*WALRecord) error { return nil }
func (noopWAL) Stop() error { return nil }

Expand Down Expand Up @@ -92,9 +94,12 @@ func newWAL(cfg WALConfig, registerer prometheus.Registerer, metrics *ingesterMe
seriesIter: seriesIter,
}

return w, nil
}

func (w *walWrapper) Start() {
w.wait.Add(1)
go w.run()
return w, nil
}

func (w *walWrapper) Log(record *WALRecord) error {
Expand Down

0 comments on commit 862cfa4

Please sign in to comment.