sectors: Handle sector state reload errors more gracefully
This commit is contained in:
parent
e6dd471103
commit
613bb25297
@ -22,7 +22,7 @@ const (
|
||||
MajorOnlyMask = 0xff0000
|
||||
MinorOnlyMask = 0x00ff00
|
||||
PatchOnlyMask = 0x0000ff
|
||||
c)
|
||||
)
|
||||
|
||||
// VersionInts returns (major, minor, patch) versions
|
||||
func VersionInts(version uint32) (uint32, uint32, uint32) {
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/ipfs/go-datastore"
|
||||
"github.com/ipfs/go-datastore/query"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"go.uber.org/multierr"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
@ -139,6 +140,8 @@ func (st *StateStore) List(out interface{}) error {
|
||||
outT := reflect.TypeOf(out).Elem().Elem()
|
||||
rout := reflect.ValueOf(out)
|
||||
|
||||
var errs error
|
||||
|
||||
for {
|
||||
res, ok := res.NextSync()
|
||||
if !ok {
|
||||
@ -151,7 +154,8 @@ func (st *StateStore) List(out interface{}) error {
|
||||
elem := reflect.New(outT)
|
||||
err := cborutil.ReadCborRPC(bytes.NewReader(res.Value), elem.Interface())
|
||||
if err != nil {
|
||||
return err
|
||||
errs = multierr.Append(errs, xerrors.Errorf("decoding state for key '%s': %w", res.Key, err))
|
||||
continue
|
||||
}
|
||||
|
||||
rout.Elem().Set(reflect.Append(rout.Elem(), elem.Elem()))
|
||||
|
@ -65,7 +65,7 @@ func (m *Miner) UpdateSectorState(ctx context.Context, sector uint64, snonce uin
|
||||
func (m *Miner) sectorStateLoop(ctx context.Context) error {
|
||||
trackedSectors, err := m.ListSectors()
|
||||
if err != nil {
|
||||
return xerrors.Errorf("loading sector list: %w", err)
|
||||
log.Errorf("loading sector list: %+v", err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
56
storage/sectors_test.go
Normal file
56
storage/sectors_test.go
Normal file
@ -0,0 +1,56 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"gotest.tools/assert"
|
||||
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
)
|
||||
|
||||
func TestSectorInfoSelialization(t *testing.T) {
|
||||
si := &SectorInfo{
|
||||
State: 123,
|
||||
SectorID: 234,
|
||||
Nonce: 345,
|
||||
Pieces: []Piece{{
|
||||
DealID: 1234,
|
||||
Size: 5,
|
||||
CommP: []byte{3},
|
||||
}},
|
||||
CommD: []byte{32, 4},
|
||||
CommR: nil,
|
||||
Proof: nil,
|
||||
Ticket: SealTicket{
|
||||
BlockHeight: 345,
|
||||
TicketBytes: []byte{87, 78, 7, 87},
|
||||
},
|
||||
PreCommitMessage: nil,
|
||||
Seed: SealSeed{},
|
||||
CommitMessage: nil,
|
||||
FaultReportMsg: nil,
|
||||
LastErr: "hi",
|
||||
}
|
||||
|
||||
b, err := cborutil.Dump(si)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var si2 SectorInfo
|
||||
if err := cborutil.ReadCborRPC(bytes.NewReader(b), &si); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
assert.Equal(t, si.State, si2.State)
|
||||
assert.Equal(t, si.Nonce, si2.Nonce)
|
||||
assert.Equal(t, si.SectorID, si2.SectorID)
|
||||
|
||||
assert.Equal(t, si.Pieces, si2.Pieces)
|
||||
assert.Equal(t, si.CommD, si2.CommD)
|
||||
assert.Equal(t, si.Ticket, si2.Ticket)
|
||||
|
||||
assert.Equal(t, si, si2)
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user