Skip to content

Commit

Permalink
chore: speed up agent history cleanup job
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Sep 7, 2024
1 parent ab015a1 commit debc16b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions job/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ func CleanupStaleAgentHistory(ctx context.Context, itemsToRetain int) (int, erro
) AS rn
FROM
job_history
WHERE
agent_id != ?
)
DELETE FROM job_history
WHERE id IN (
SELECT id
FROM grouped_history
WHERE
rn > ? AND
agent_id != ?
rn > ?
LIMIT %d
)`, batchSize)

Expand All @@ -60,7 +61,7 @@ func CleanupStaleAgentHistory(ctx context.Context, itemsToRetain int) (int, erro
for {
// 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)
res := ctx.DB().Exec(query, uuid.Nil, itemsToRetain)
if res.Error != nil {
return deleted, db.ErrorDetails(res.Error)
}
Expand Down

0 comments on commit debc16b

Please sign in to comment.