Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some fsm issues #3350

Merged
merged 27 commits into from
Aug 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
15191ff
storagefsm: Allow removing sectors in all states
magik6k Aug 27, 2020
e236173
miner: Print (pre)commit message cids in sector status
magik6k Aug 27, 2020
51ca460
miner: Fix sorting of some sector states in miner-info
magik6k Aug 27, 2020
99ecef8
gofmt
magik6k Aug 27, 2020
788c7db
storagefsm: Separate satte for submitting commit message
magik6k Aug 27, 2020
df63557
storagefsm: Handle sectors with expired deals better
magik6k Aug 27, 2020
8a45148
docsgen
magik6k Aug 27, 2020
29078aa
storagefsm: Retry sending messages on out-of-gas errors
magik6k Aug 27, 2020
7806a98
storagefsm: Record publish deals message CID
magik6k Aug 27, 2020
489d523
storagefsm: Attempt to auto-recover from reorged DealIDs
magik6k Aug 27, 2020
15204a9
storagefsm: fix tests
magik6k Aug 27, 2020
6c7874c
Merge remote-tracking branch 'origin/master' into fix/some-fsm-issues
magik6k Aug 27, 2020
d8e58e6
storagefsm: Treat PackingFailed sectors as expired
magik6k Aug 27, 2020
59f554b
sealing sched: Show waiting tasks assigned to workers in sealing jobs…
magik6k Aug 27, 2020
f2bd680
gofmt
magik6k Aug 27, 2020
7fdffc0
sealing sched: Give more priority to tasks (re)moving data
magik6k Aug 27, 2020
59d2034
sealing sched: Wait a bit for tasks to come in on restart
magik6k Aug 27, 2020
a6492b1
storagefsm: Auto-retry failed remove
magik6k Aug 27, 2020
1097d29
sealing sched: Call trySched less when there are many tasks
magik6k Aug 27, 2020
398cbd7
deps: Update markets
magik6k Aug 27, 2020
6d1682a
storagefsm: wire up RecoverDealIDs fully
magik6k Aug 28, 2020
5ee85dc
sectorstorage: Fix tests
magik6k Aug 28, 2020
20ffce5
Merge remote-tracking branch 'origin/master' into fix/some-fsm-issues
magik6k Aug 28, 2020
11b11e4
sectorstorage: Compact assigned windows
magik6k Aug 28, 2020
4a75e1e
sectorstorage: Don't require tasks within a window to run in order
magik6k Aug 28, 2020
9d0c8ae
sectorstorage: update sched tests for new logic
magik6k Aug 28, 2020
a62e44c
Fix lint
magik6k Aug 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ type FullNode interface {
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
// StateSectorPreCommitInfo returns the PreCommit info for the specified miner's sector
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
// StateSectorGetInfo returns the on-chain info for the specified miner's sector
// StateSectorGetInfo returns the on-chain info for the specified miner's sector. Returns null in case the sector info isn't found
// NOTE: returned info.Expiration may not be accurate in some cases, use StateSectorExpiration to get accurate
// expiration epoch
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
Expand Down
22 changes: 12 additions & 10 deletions api/api_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,18 @@ type SectorLog struct {
}

type SectorInfo struct {
SectorID abi.SectorNumber
State SectorState
CommD *cid.Cid
CommR *cid.Cid
Proof []byte
Deals []abi.DealID
Ticket SealTicket
Seed SealSeed
Retries uint64
ToUpgrade bool
SectorID abi.SectorNumber
State SectorState
CommD *cid.Cid
CommR *cid.Cid
Proof []byte
Deals []abi.DealID
Ticket SealTicket
Seed SealSeed
PreCommitMsg *cid.Cid
CommitMsg *cid.Cid
Retries uint64
ToUpgrade bool

LastErr string

Expand Down
4 changes: 4 additions & 0 deletions chain/beacon/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ func ValidateBlockValues(b RandomBeacon, h *types.BlockHeader, prevEntry types.B
return nil
}

if len(h.BeaconEntries) == 0 {
return xerrors.Errorf("expected to have beacon entries in this block, but didn't find any")
}

last := h.BeaconEntries[len(h.BeaconEntries)-1]
if last.Round != maxRound {
return xerrors.Errorf("expected final beacon entry in block to be at round %d, got %d", maxRound, last.Round)
Expand Down
2 changes: 1 addition & 1 deletion chain/stmgr/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func MinerSectorInfo(ctx context.Context, sm *StateManager, maddr address.Addres
return nil, err
}
if !ok {
return nil, xerrors.New("sector not found")
return nil, nil
}

return sectorInfo, nil
Expand Down
11 changes: 10 additions & 1 deletion cmd/lotus-storage-miner/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,24 @@ var stateList = []stateMeta{
{col: 39, state: "Total"},
{col: color.FgGreen, state: sealing.Proving},

{col: color.FgBlue, state: sealing.Empty},
{col: color.FgBlue, state: sealing.WaitDeals},

{col: color.FgRed, state: sealing.UndefinedSectorState},
{col: color.FgYellow, state: sealing.Empty},
{col: color.FgYellow, state: sealing.Packing},
{col: color.FgYellow, state: sealing.PreCommit1},
{col: color.FgYellow, state: sealing.PreCommit2},
{col: color.FgYellow, state: sealing.PreCommitting},
{col: color.FgYellow, state: sealing.PreCommitWait},
{col: color.FgYellow, state: sealing.WaitSeed},
{col: color.FgYellow, state: sealing.Committing},
{col: color.FgYellow, state: sealing.SubmitCommit},
{col: color.FgYellow, state: sealing.CommitWait},
{col: color.FgYellow, state: sealing.FinalizeSector},

{col: color.FgCyan, state: sealing.Removing},
{col: color.FgCyan, state: sealing.Removed},

{col: color.FgRed, state: sealing.FailedUnrecoverable},
{col: color.FgRed, state: sealing.SealPreCommit1Failed},
{col: color.FgRed, state: sealing.SealPreCommit2Failed},
Expand All @@ -259,6 +265,9 @@ var stateList = []stateMeta{
{col: color.FgRed, state: sealing.Faulty},
{col: color.FgRed, state: sealing.FaultReported},
{col: color.FgRed, state: sealing.FaultedFinal},
{col: color.FgRed, state: sealing.RemoveFailed},
{col: color.FgRed, state: sealing.DealsExpired},
{col: color.FgRed, state: sealing.RecoverDealIDs},
}

func init() {
Expand Down
11 changes: 9 additions & 2 deletions cmd/lotus-storage-miner/sealing.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ var sealingJobsCmd = &cli.Command{

// oldest first
sort.Slice(lines, func(i, j int) bool {
if lines[i].RunWait != lines[j].RunWait {
return lines[i].RunWait < lines[j].RunWait
}
return lines[i].Start.Before(lines[j].Start)
})

Expand All @@ -170,10 +173,14 @@ var sealingJobsCmd = &cli.Command{
}

tw := tabwriter.NewWriter(os.Stdout, 2, 4, 2, ' ', 0)
_, _ = fmt.Fprintf(tw, "ID\tSector\tWorker\tHostname\tTask\tTime\n")
_, _ = fmt.Fprintf(tw, "ID\tSector\tWorker\tHostname\tTask\tState\tTime\n")

for _, l := range lines {
_, _ = fmt.Fprintf(tw, "%d\t%d\t%d\t%s\t%s\t%s\n", l.ID, l.Sector.Number, l.wid, workerHostnames[l.wid], l.Task.Short(), time.Now().Sub(l.Start).Truncate(time.Millisecond*100))
state := "running"
if l.RunWait != 0 {
state = fmt.Sprintf("assigned(%d)", l.RunWait-1)
}
_, _ = fmt.Fprintf(tw, "%d\t%d\t%d\t%s\t%s\t%s\t%s\n", l.ID, l.Sector.Number, l.wid, workerHostnames[l.wid], l.Task.Short(), state, time.Now().Sub(l.Start).Truncate(time.Millisecond*100))
}

return tw.Flush()
Expand Down
2 changes: 2 additions & 0 deletions cmd/lotus-storage-miner/sectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ var sectorsStatusCmd = &cli.Command{
fmt.Printf("TicketH:\t%d\n", status.Ticket.Epoch)
fmt.Printf("Seed:\t\t%x\n", status.Seed.Value)
fmt.Printf("SeedH:\t\t%d\n", status.Seed.Epoch)
fmt.Printf("Precommit:\t%s\n", status.PreCommitMsg)
fmt.Printf("Commit:\t\t%s\n", status.CommitMsg)
fmt.Printf("Proof:\t\t%x\n", status.Proof)
fmt.Printf("Deals:\t\t%v\n", status.Deals)
fmt.Printf("Retries:\t%d\n", status.Retries)
Expand Down
2 changes: 1 addition & 1 deletion documentation/en/api-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -3603,7 +3603,7 @@ Response:
```

### StateSectorGetInfo
StateSectorGetInfo returns the on-chain info for the specified miner's sector
StateSectorGetInfo returns the on-chain info for the specified miner's sector. Returns null in case the sector info isn't found
NOTE: returned info.Expiration may not be accurate in some cases, use StateSectorExpiration to get accurate
expiration epoch

Expand Down
30 changes: 12 additions & 18 deletions extern/sector-storage/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
"io"
"net/http"

"github.com/filecoin-project/lotus/extern/sector-storage/fsutil"

"github.com/hashicorp/go-multierror"
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
"github.com/mitchellh/go-homedir"
Expand All @@ -17,6 +16,7 @@ import (
"github.com/filecoin-project/specs-storage/storage"

"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
"github.com/filecoin-project/lotus/extern/sector-storage/fsutil"
"github.com/filecoin-project/lotus/extern/sector-storage/sealtasks"
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
Expand Down Expand Up @@ -463,25 +463,19 @@ func (m *Manager) Remove(ctx context.Context, sector abi.SectorID) error {
return xerrors.Errorf("acquiring sector lock: %w", err)
}

unsealed := stores.FTUnsealed
{
unsealedStores, err := m.index.StorageFindSector(ctx, sector, stores.FTUnsealed, 0, false)
if err != nil {
return xerrors.Errorf("finding unsealed sector: %w", err)
}
var err error

if len(unsealedStores) == 0 { // can be already removed
unsealed = stores.FTNone
}
if rerr := m.storage.Remove(ctx, sector, stores.FTSealed, true); rerr != nil {
err = multierror.Append(err, xerrors.Errorf("removing sector (sealed): %w", rerr))
}
if rerr := m.storage.Remove(ctx, sector, stores.FTCache, true); rerr != nil {
err = multierror.Append(err, xerrors.Errorf("removing sector (cache): %w", rerr))
}
if rerr := m.storage.Remove(ctx, sector, stores.FTUnsealed, true); rerr != nil {
err = multierror.Append(err, xerrors.Errorf("removing sector (unsealed): %w", rerr))
}

selector := newExistingSelector(m.index, sector, stores.FTCache|stores.FTSealed, false)

return m.sched.Schedule(ctx, sector, sealtasks.TTFinalize, selector,
schedFetch(sector, stores.FTCache|stores.FTSealed|unsealed, stores.PathStorage, stores.AcquireMove),
func(ctx context.Context, w Worker) error {
return w.Remove(ctx, sector)
})
return err
}

func (m *Manager) StorageLocal(ctx context.Context) (map[stores.ID]string, error) {
Expand Down
5 changes: 5 additions & 0 deletions extern/sector-storage/request_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ type requestQueue []*workerRequest
func (q requestQueue) Len() int { return len(q) }

func (q requestQueue) Less(i, j int) bool {
oneMuchLess, muchLess := q[i].taskType.MuchLess(q[j].taskType)
if oneMuchLess {
return muchLess
}

if q[i].priority != q[j].priority {
return q[i].priority > q[j].priority
}
Expand Down
12 changes: 6 additions & 6 deletions extern/sector-storage/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ func (r Resources) MultiThread() bool {

var ResourceTable = map[sealtasks.TaskType]map[abi.RegisteredSealProof]Resources{
sealtasks.TTAddPiece: {
abi.RegisteredSealProof_StackedDrg64GiBV1: Resources{ // This is probably a bit conservative
MaxMemory: 64 << 30,
MinMemory: 64 << 30,
abi.RegisteredSealProof_StackedDrg64GiBV1: Resources{
MaxMemory: 8 << 30,
MinMemory: 8 << 30,

Threads: 1,

BaseMinMemory: 1 << 30,
},
abi.RegisteredSealProof_StackedDrg32GiBV1: Resources{ // This is probably a bit conservative
MaxMemory: 32 << 30,
MinMemory: 32 << 30,
abi.RegisteredSealProof_StackedDrg32GiBV1: Resources{
MaxMemory: 4 << 30,
MinMemory: 4 << 30,

Threads: 1,

Expand Down
Loading