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

[k102] Add more logging for delete requests #6473

Merged
merged 1 commit into from
Jun 23, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,30 @@ func (d *DeleteRequest) IsDeleted(entry retention.ChunkEntry) (bool, []retention
return false, nil
}

level.Debug(util_log.Logger).Log(
"msg", "starting filter function",
"delete_request_id", d.RequestID,
"user", d.UserID,
"labels", entry.Labels.String(),
)
ff, err := d.FilterFunction(entry.Labels)
if err != nil {
// The query in the delete request is checked when added to the table.
// So this error should not occur.
level.Error(util_log.Logger).Log("msg", "unexpected error getting filter function", "err", err)
level.Error(util_log.Logger).Log(
"msg", "unexpected error getting filter function",
"delete_request_id", d.RequestID,
"user", d.UserID,
"err", err,
)
return false, nil
}
level.Debug(util_log.Logger).Log(
"msg", "finished filter function",
"delete_request_id", d.RequestID,
"user", d.UserID,
"labels", entry.Labels.String(),
)

if d.StartTime <= entry.From && d.EndTime >= entry.Through {
// if the logSelectorExpr has a filter part return the chunk boundaries as intervals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package deletion

import (
"context"
"fmt"
"sync"
"time"

Expand Down Expand Up @@ -148,6 +147,11 @@ func (d *DeleteRequestsManager) Expired(ref retention.ChunkEntry, _ model.Time)
})

for _, deleteRequest := range d.deleteRequestsToProcess {
level.Info(util_log.Logger).Log(
"msg", "started processing delete request",
"delete_request_id", deleteRequest.RequestID,
"user", deleteRequest.UserID,
)
rebuiltIntervals := make([]retention.IntervalFilter, 0, len(d.chunkIntervalsToRetain))
for _, ivf := range d.chunkIntervalsToRetain {
entry := ref
Expand All @@ -163,9 +167,20 @@ func (d *DeleteRequestsManager) Expired(ref retention.ChunkEntry, _ model.Time)

d.chunkIntervalsToRetain = rebuiltIntervals
if len(d.chunkIntervalsToRetain) == 0 {
level.Info(util_log.Logger).Log(
"msg", "no chunks to retain: the whole chunk is deleted",
"delete_request_id", deleteRequest.RequestID,
"user", deleteRequest.UserID,
"chunkID", string(ref.ChunkID),
)
d.metrics.deleteRequestsChunksSelectedTotal.WithLabelValues(string(ref.UserID)).Inc()
return true, nil
}
level.Info(util_log.Logger).Log(
"msg", "finished processing delete request",
"delete_request_id", deleteRequest.RequestID,
"user", deleteRequest.UserID,
)
}

if len(d.chunkIntervalsToRetain) == 1 && d.chunkIntervalsToRetain[0].Interval.Start == ref.From && d.chunkIntervalsToRetain[0].Interval.End == ref.Through {
Expand Down Expand Up @@ -198,7 +213,18 @@ func (d *DeleteRequestsManager) MarkPhaseFinished() {

for _, deleteRequest := range d.deleteRequestsToProcess {
if err := d.deleteRequestsStore.UpdateStatus(context.Background(), deleteRequest.UserID, deleteRequest.RequestID, StatusProcessed); err != nil {
level.Error(util_log.Logger).Log("msg", fmt.Sprintf("failed to mark delete request %s for user %s as processed", deleteRequest.RequestID, deleteRequest.UserID), "err", err)
level.Error(util_log.Logger).Log(
"msg", "failed to mark delete request for user as processed",
"delete_request_id", deleteRequest.RequestID,
"user", deleteRequest.UserID,
"err", err,
)
} else {
level.Info(util_log.Logger).Log(
"msg", "delete request for user marked as processed",
"delete_request_id", deleteRequest.RequestID,
"user", deleteRequest.UserID,
)
}
d.metrics.deleteRequestsProcessedTotal.WithLabelValues(deleteRequest.UserID).Inc()
}
Expand Down