satellite/metainfo: log if replacing pieces in pointer goes wrong

Every now and then we see the repair error, "piece to add already exists".
With these new logs we should be able to verify if it is due to a change in
the pointer. These logs are only temporary

Change-Id: I029390cc4816668707546df14ed2cfe7ca192b0b
This commit is contained in:
Cameron Ayer 2020-05-20 16:18:43 -04:00 committed by Cameron
parent 427bfc13fb
commit 9edb363558

View File

@ -5,6 +5,7 @@ package metainfo
import (
"context"
"fmt"
"time"
"github.com/zeebo/errs"
@ -131,7 +132,7 @@ func (s *Service) UpdatePiecesCheckDuplicates(ctx context.Context, path string,
}
}
// remove the toRemove pieces from the map
// only if all piece number, node id and hash match
// only if piece number and node id match
for _, piece := range toRemove {
if piece == nil {
continue
@ -147,8 +148,15 @@ func (s *Service) UpdatePiecesCheckDuplicates(ctx context.Context, path string,
if piece == nil {
continue
}
piece.Hash = nil
_, exists := pieceMap[piece.PieceNum]
if exists {
// temporary logging to get some insight into this error
s.logger.Info("temporary logging around error: 'piece to add already exists'",
zap.String("old pointer", fmt.Sprintf("%v", ref.GetRemote().GetRemotePieces())),
zap.String("latest pointer", fmt.Sprintf("%v", pointer.GetRemote().GetRemotePieces())),
zap.String("nodes to remove", fmt.Sprintf("%v", toRemove)),
zap.String("nodes to add", fmt.Sprintf("%v", toAdd)))
return nil, Error.New("piece to add already exists (piece no: %d)", piece.PieceNum)
}
pieceMap[piece.PieceNum] = piece