From 9c8049bf0bdbdb8ebb8d24599dc0c809674da896 Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Fri, 6 Sep 2024 18:31:37 +0530 Subject: [PATCH] chore: return deleted rows if stale history cleanup fails (#1025) --- job/cleanup.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/job/cleanup.go b/job/cleanup.go index 7b6cc067..e8d12462 100644 --- a/job/cleanup.go +++ b/job/cleanup.go @@ -58,9 +58,11 @@ func CleanupStaleAgentHistory(ctx context.Context, itemsToRetain int) (int, erro // We are deleting in batches since the query can timeout if size is too high deleted := 0 for { - res := ctx.FastDB("jobs").Exec(query, itemsToRetain, uuid.Nil) + // TODO (yashmehrotra): Use FastDB after debugging job failure + //res := ctx.FastDB("jobs").Exec(query, itemsToRetain, uuid.Nil) + res := ctx.DB().Exec(query, itemsToRetain, uuid.Nil) if res.Error != nil { - return 0, db.ErrorDetails(res.Error) + return deleted, db.ErrorDetails(res.Error) } deleted += int(res.RowsAffected) if res.RowsAffected == 0 {