mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-16 20:01:35 +01:00
fix: clean the redis if the execution is not found (#18517)
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
7edb447e14
commit
b755c43d12
@ -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