lpwindow: Don't deadlock in CanAccept

This commit is contained in:
Łukasz Magiera 2023-10-31 10:08:13 +01:00
parent 024727177a
commit 008891bc6b

View File

@ -23,7 +23,6 @@ import (
"github.com/filecoin-project/go-state-types/dline" "github.com/filecoin-project/go-state-types/dline"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/actors/policy"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/lib/harmony/harmonydb" "github.com/filecoin-project/lotus/lib/harmony/harmonydb"
"github.com/filecoin-project/lotus/lib/harmony/harmonytask" "github.com/filecoin-project/lotus/lib/harmony/harmonytask"
@ -251,8 +250,12 @@ func (t *WdPostTask) CanAccept(ids []harmonytask.TaskID, te *harmonytask.TaskEng
} }
} }
// todo fix the block below
// workAdderMutex is held by taskTypeHandler.considerWork, which calls this CanAccept
// te.ResourcesAvailable will try to get that lock again, which will deadlock
// Discard those too big for our free RAM // Discard those too big for our free RAM
freeRAM := te.ResourcesAvailable().Ram /*freeRAM := te.ResourcesAvailable().Ram
tasks = lo.Filter(tasks, func(d wdTaskDef, _ int) bool { tasks = lo.Filter(tasks, func(d wdTaskDef, _ int) bool {
maddr, err := address.NewIDAddress(tasks[0].Sp_id) maddr, err := address.NewIDAddress(tasks[0].Sp_id)
if err != nil { if err != nil {
@ -273,7 +276,7 @@ func (t *WdPostTask) CanAccept(ids []harmonytask.TaskID, te *harmonytask.TaskEng
} }
return res[spt].MaxMemory <= freeRAM return res[spt].MaxMemory <= freeRAM
}) })*/
if len(tasks) == 0 { if len(tasks) == 0 {
log.Infof("RAM too small for any WDPost task") log.Infof("RAM too small for any WDPost task")
return nil, nil return nil, nil