mirror of
https://github.com/goharbor/harbor.git
synced 2024-10-01 23:07:39 +02:00
[cherry-pick] fix: clean the redis if the execution is not found (#18519)
fix: clean the redis if the execution is not found Delete the execution outdated status key in the redis when the execution is not found. Fixes: #18511 Signed-off-by: chlins <chenyuzh@vmware.com>
This commit is contained in:
parent
9ea2d3cbd9
commit
47f70cba86
@ -476,6 +476,14 @@ func scanAndRefreshOutdateStatus(ctx context.Context) {
|
||||
|
||||
statusChanged, currentStatus, err := ExecDAO.RefreshStatus(ctx, execID)
|
||||
if err != nil {
|
||||
// no need to refresh and should clean cache if the execution is not found
|
||||
if errors.IsNotFoundErr(err) {
|
||||
if err = cache.Default().Delete(ctx, key); err != nil {
|
||||
log.Errorf("failed to delete the key %s in cache, error: %v", key, err)
|
||||
}
|
||||
succeed++
|
||||
continue
|
||||
}
|
||||
log.Errorf("failed to refresh the status of execution %d, error: %v", execID, err)
|
||||
failed++
|
||||
continue
|
||||
|
@ -139,7 +139,7 @@ func (sm *sweepManager) ListCandidates(ctx context.Context, vendorType string, r
|
||||
n = n + 1
|
||||
}
|
||||
|
||||
sql = `SELECT id FROM execution WHERE vendor_type = ? AND vendor_id = ? AND start_time < ? AND status IN (?,?,?)`
|
||||
sql = `SELECT id FROM execution WHERE vendor_type = ? AND vendor_id = ? AND start_time < ? AND status IN (?,?,?) ORDER BY id`
|
||||
// default page size is 100000
|
||||
q2 := &q.Query{PageSize: int64(defaultPageSize)}
|
||||
for i := n; i >= 1; i-- {
|
||||
|
Loading…
Reference in New Issue
Block a user