From 485050ee7c14417659c0fb49e1bf26c6819f0b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 4 Apr 2024 12:12:35 +0200 Subject: [PATCH] fix: harmony: Try other tasks when storage claim fails --- lib/harmony/harmonytask/task_type_handler.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/harmony/harmonytask/task_type_handler.go b/lib/harmony/harmonytask/task_type_handler.go index 2b2521949..7aecd380f 100644 --- a/lib/harmony/harmonytask/task_type_handler.go +++ b/lib/harmony/harmonytask/task_type_handler.go @@ -85,6 +85,7 @@ top: } // 3. What does the impl say? +canAcceptAgain: tID, err := h.CanAccept(ids, h.TaskEngine) if err != nil { log.Error(err) @@ -100,6 +101,18 @@ top: if h.TaskTypeDetails.Cost.Storage != nil { if err = h.TaskTypeDetails.Cost.Storage.Claim(int(*tID)); err != nil { log.Infow("did not accept task", "task_id", strconv.Itoa(int(*tID)), "reason", "storage claim failed", "name", h.Name, "error", err) + + if len(ids) > 1 { + var tryAgain = make([]TaskID, 0, len(ids)-1) + for _, id := range ids { + if id != *tID { + tryAgain = append(tryAgain, id) + } + } + ids = tryAgain + goto canAcceptAgain + } + return false } releaseStorage = func() {