Fix iteration error in invalidate task of candidate cache