better logging

This commit is contained in:
aarshkshah1992 2021-05-21 15:16:20 +05:30
parent 85f2ac8789
commit 40642b2cad
3 changed files with 9 additions and 2 deletions

View File

@ -80,6 +80,9 @@ func (p *pieceProvider) ReadPiece(ctx context.Context, sector storage.SectorRef,
}
r, unlock, err := p.tryReadUnsealedPiece(ctx, sector, offset, size)
log.Infof("tryReadUnsealedPiece result: r=%+v, err=%s", r, err)
if xerrors.Is(err, storiface.ErrSectorNotFound) {
log.Debugf("no unsealed sector file with unsealed piece, sector=%+v, offset=%d, size=%d", sector, offset, size)
err = nil

View File

@ -513,12 +513,14 @@ func (r *Remote) Reader(ctx context.Context, s storage.SectorRef, offset, size a
log.Debugf("failed to get sectorsize: %s", err)
return nil, err
}
log.Infof("fetched sector size %s (+%d,%d)", path, offset, size)
// open the unsealed sector file for the given sector size located at the given path.
pf, err := r.pfHandler.OpenPartialFile(abi.PaddedPieceSize(ssize), path)
if err != nil {
return nil, xerrors.Errorf("opening partial file: %w", err)
}
log.Infof("partial file opened %s (+%d,%d)", path, offset, size)
// even though we have an unsealed file for the given sector, we still need to determine if we have the unsealed piece
// in the unsealed sector file. That is what `HasAllocated` checks for.
@ -526,16 +528,17 @@ func (r *Remote) Reader(ctx context.Context, s storage.SectorRef, offset, size a
if err != nil {
return nil, xerrors.Errorf("has allocated: %w", err)
}
log.Infof("partial file is allocated %s (+%d,%d)", path, offset, size)
if !has {
log.Infof("miner has unsealed file but not unseal piece, %s (+%d,%d)", path, offset, size)
if err := r.pfHandler.Close(pf); err != nil {
return nil, xerrors.Errorf("close partial file: %w", err)
}
log.Debugf("miner has unsealed file but not unseal piece, %s (+%d,%d)", path, offset, size)
return nil, nil
}
log.Debugf("returning piece reader for local unsealed piece sector=%+v, (offset=%d, size=%d)", s.ID, offset, size)
log.Infof("returning piece reader for local unsealed piece sector=%+v, (offset=%d, size=%d)", s.ID, offset, size)
return r.pfHandler.Reader(pf, storiface.PaddedByteIndex(offset), size)
}

View File

@ -428,6 +428,7 @@ func (l *LocalWorker) UnsealPiece(ctx context.Context, sector storage.SectorRef,
}
return l.asyncCall(ctx, sector, UnsealPiece, func(ctx context.Context, ci storiface.CallID) (interface{}, error) {
log.Debugf("worker will unseal piece now, sector=%+v", sector.ID)
if err = sb.UnsealPiece(ctx, sector, index, size, randomness, cid); err != nil {
return nil, xerrors.Errorf("unsealing sector: %w", err)
}