Skip to content

Commit

Permalink
jobs: don't check the number of deleted rows
Browse files Browse the repository at this point in the history
When attempting to delete expired job records it's entirely possible to
legitimately delete less records than expected. This can happen when
another node is concurrently attempting cleanup. Previously, we returned
an assertion failure in these cases.

Fixes #65048.

Release note: None
  • Loading branch information
Marius Posta committed May 18, 2021
1 parent 08322ff commit a6f442e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pkg/jobs/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -933,18 +933,15 @@ func (r *Registry) cleanupOldJobsPage(

log.VEventf(ctx, 2, "read potentially expired jobs: %d", numRows)
if len(toDelete.Array) > 0 {
log.Infof(ctx, "cleaning up expired job records: %d", len(toDelete.Array))
log.Infof(ctx, "attempting to clean up %d expired job records", len(toDelete.Array))
const stmt = `DELETE FROM system.jobs WHERE id = ANY($1)`
var nDeleted int
if nDeleted, err = r.ex.Exec(
ctx, "gc-jobs", nil /* txn */, stmt, toDelete,
); err != nil {
return false, 0, errors.Wrap(err, "deleting old jobs")
}
if nDeleted != len(toDelete.Array) {
return false, 0, errors.AssertionFailedf("asked to delete %d rows but %d were actually deleted",
len(toDelete.Array), nDeleted)
}
log.Infof(ctx, "cleaned up %d expired job records", nDeleted)
}
// If we got as many rows as we asked for, there might be more.
morePages := numRows == pageSize
Expand Down

0 comments on commit a6f442e

Please sign in to comment.