Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve mark file processing. #3762

Merged
merged 1 commit into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions pkg/storage/stores/shipper/compactor/retention/marker.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ func (r *markerProcessor) Start(deleteFunc func(ctx context.Context, chunkId []b
level.Error(util_log.Logger).Log("msg", "failed to list marks path", "path", r.folder, "err", err)
continue
}
r.sweeperMetrics.markerFilesCurrent.Set(float64(len(paths)))
if len(paths) == 0 {
level.Info(util_log.Logger).Log("msg", "no marks file found")
}
Expand All @@ -221,6 +220,29 @@ func (r *markerProcessor) Start(deleteFunc func(ctx context.Context, chunkId []b

}
}()
r.wg.Add(1)
go func() {
defer r.wg.Done()
ticker := time.NewTicker(10 * time.Second)
dannykopping marked this conversation as resolved.
Show resolved Hide resolved
defer ticker.Stop()
tick := func() {
select {
case <-r.ctx.Done():
case <-ticker.C:
}
}
for ; true; tick() {
if r.ctx.Err() != nil {
return
}
paths, _, err := r.availablePath()
if err != nil {
level.Error(util_log.Logger).Log("msg", "failed to list marks path", "path", r.folder, "err", err)
continue
}
r.sweeperMetrics.markerFilesCurrent.Set(float64(len(paths)))
}
}()
}

func (r *markerProcessor) processPath(path string, deleteFunc func(ctx context.Context, chunkId []byte) error) error {
Expand Down Expand Up @@ -259,7 +281,7 @@ func (r *markerProcessor) processPath(path string, deleteFunc func(ctx context.C
if err != nil {
return err
}
dbUpdate.MaxBatchDelay = 1 * time.Second // 1 s is way enough for saving changes, worst case this operation is idempotent.
dbUpdate.MaxBatchDelay = 5 * time.Millisecond
dannykopping marked this conversation as resolved.
Show resolved Hide resolved
defer func() {
close(queue)
wg.Wait()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
)
.addPanel(
$.panel('Marks Files to Process') +
$.queryPanel(['loki_boltdb_shipper_retention_sweeper_marker_files_current{%s}' % $.namespaceMatcher()], ['count']),
$.queryPanel(['sum(loki_boltdb_shipper_retention_sweeper_marker_files_current{%s})' % $.namespaceMatcher()], ['count']),
)
.addPanel(
$.panel('Delete Rate Per Status') +
Expand Down