Persist sector sealing errors

This commit is contained in:
Łukasz Magiera 2019-12-04 01:44:29 +01:00
parent 13c39452c1
commit d112fd18b1
8 changed files with 36 additions and 4 deletions

View File

@ -82,6 +82,7 @@ type SectorInfo struct {
Deals []uint64 Deals []uint64
Ticket sectorbuilder.SealTicket Ticket sectorbuilder.SealTicket
Seed sectorbuilder.SealSeed Seed sectorbuilder.SealSeed
LastErr string
} }
type SealedRef struct { type SealedRef struct {

View File

@ -5,7 +5,7 @@ import (
"io" "io"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen" cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors" xerrors "golang.org/x/xerrors"
) )

View File

@ -5,7 +5,7 @@ import (
"io" "io"
"math" "math"
"github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen" cbg "github.com/whyrusleeping/cbor-gen"
xerrors "golang.org/x/xerrors" xerrors "golang.org/x/xerrors"
) )

View File

@ -70,6 +70,9 @@ var sectorsStatusCmd = &cli.Command{
fmt.Printf("SeedH:\t\t%d\n", status.Seed.BlockHeight) fmt.Printf("SeedH:\t\t%d\n", status.Seed.BlockHeight)
fmt.Printf("Proof:\t\t%x\n", status.Proof) fmt.Printf("Proof:\t\t%x\n", status.Proof)
fmt.Printf("Deals:\t\t%v\n", status.Deals) fmt.Printf("Deals:\t\t%v\n", status.Deals)
if status.LastErr != "" {
fmt.Printf("Last Error:\t\t%s\n", status.LastErr)
}
return nil return nil
}, },
} }

View File

@ -60,6 +60,8 @@ func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid uint64) (api.S
Deals: deals, Deals: deals,
Ticket: info.Ticket.SB(), Ticket: info.Ticket.SB(),
Seed: info.Seed.SB(), Seed: info.Seed.SB(),
LastErr: info.LastErr,
}, nil }, nil
} }

View File

@ -239,7 +239,7 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error {
_, err := w.Write(cbg.CborNull) _, err := w.Write(cbg.CborNull)
return err return err
} }
if _, err := w.Write([]byte{140}); err != nil { if _, err := w.Write([]byte{141}); err != nil {
return err return err
} }
@ -337,6 +337,13 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error {
} }
} }
// t.t.LastErr (string) (string)
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.LastErr)))); err != nil {
return err
}
if _, err := w.Write([]byte(t.LastErr)); err != nil {
return err
}
return nil return nil
} }
@ -351,7 +358,7 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
return fmt.Errorf("cbor input should be of type array") return fmt.Errorf("cbor input should be of type array")
} }
if extra != 12 { if extra != 13 {
return fmt.Errorf("cbor input had wrong number of fields") return fmt.Errorf("cbor input had wrong number of fields")
} }
@ -552,5 +559,15 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
} }
} }
// t.t.LastErr (string) (string)
{
sval, err := cbg.ReadString(br)
if err != nil {
return err
}
t.LastErr = string(sval)
}
return nil return nil
} }

View File

@ -69,6 +69,9 @@ type SectorInfo struct {
// Committing // Committing
CommitMessage *cid.Cid CommitMessage *cid.Cid
// Debug
LastErr string
} }
func (t *SectorInfo) upd() *sectorUpdate { func (t *SectorInfo) upd() *sectorUpdate {

View File

@ -2,6 +2,7 @@ package storage
import ( import (
"context" "context"
"fmt"
"io" "io"
xerrors "golang.org/x/xerrors" xerrors "golang.org/x/xerrors"
@ -154,6 +155,11 @@ func (m *Miner) onSectorUpdated(ctx context.Context, update sectorUpdate) {
var sector SectorInfo var sector SectorInfo
err := m.sectors.Mutate(update.id, func(s *SectorInfo) error { err := m.sectors.Mutate(update.id, func(s *SectorInfo) error {
s.State = update.newState s.State = update.newState
s.LastErr = ""
if update.err != nil {
s.LastErr = fmt.Sprintf("%+v", update.err)
}
if update.mut != nil { if update.mut != nil {
update.mut(s) update.mut(s)
} }