diff --git a/core/block/editor/archive.go b/core/block/editor/archive.go index fad1e3bab..0071b936a 100644 --- a/core/block/editor/archive.go +++ b/core/block/editor/archive.go @@ -1,6 +1,9 @@ package editor import ( + "errors" + + "github.com/anyproto/any-sync/commonspace/spacestorage" "github.com/gogo/protobuf/types" "github.com/anyproto/anytype-heart/core/block/editor/collection" @@ -115,7 +118,7 @@ func (p *Archive) updateInStore(archivedIds []string) error { current.Fields[bundle.RelationKeyIsArchived.String()] = pbtypes.Bool(false) return current, nil }); err != nil { - log.Errorf("archive: can't set detail to object: %v", err) + logArchiveError(err) } }(removedId) } @@ -130,9 +133,16 @@ func (p *Archive) updateInStore(archivedIds []string) error { current.Fields[bundle.RelationKeyIsArchived.String()] = pbtypes.Bool(true) return current, nil }); err != nil { - log.Errorf("archive: can't set detail to object: %v", err) + logArchiveError(err) } }(addedId) } return nil } + +func logArchiveError(err error) { + if errors.Is(err, spacestorage.ErrTreeStorageAlreadyDeleted) { + return + } + log.Errorf("archive: can't set detail to object: %v", err) +} diff --git a/core/files/fileobject/fileindex.go b/core/files/fileobject/fileindex.go index 4f82bc24a..c6c280c81 100644 --- a/core/files/fileobject/fileindex.go +++ b/core/files/fileobject/fileindex.go @@ -2,13 +2,16 @@ package fileobject import ( "context" + "errors" "fmt" "strings" "sync" "time" + "github.com/anyproto/any-sync/commonspace/object/tree/treestorage" "github.com/cheggaaa/mb/v3" "github.com/gogo/protobuf/types" + format "github.com/ipfs/go-ipld-format" "github.com/anyproto/anytype-heart/core/block/editor/smartblock" "github.com/anyproto/anytype-heart/core/block/editor/state" @@ -17,6 +20,7 @@ import ( fileblock "github.com/anyproto/anytype-heart/core/block/simple/file" "github.com/anyproto/anytype-heart/core/domain" "github.com/anyproto/anytype-heart/core/files" + "github.com/anyproto/anytype-heart/core/filestorage/rpcstore" "github.com/anyproto/anytype-heart/pkg/lib/bundle" "github.com/anyproto/anytype-heart/pkg/lib/database" "github.com/anyproto/anytype-heart/pkg/lib/localstore/objectstore" @@ -182,11 +186,24 @@ func (ind *indexer) runIndexingWorker() { default: } if err := ind.indexNext(ind.indexCtx); err != nil { - log.Errorf("index loop: %v", err) + logIndexLoop(err) } } } +func logIndexLoop(err error) { + if errors.Is(err, treestorage.ErrUnknownTreeId) { + return + } + if errors.Is(err, format.ErrNotFound{}) { + return + } + if errors.Is(err, rpcstore.ErrNoConnectionToAnyFileClient) { + return + } + log.Errorf("index loop: %v", err) +} + func (ind *indexer) indexNext(ctx context.Context) error { req, err := ind.indexQueue.NewCond().WaitOne(ctx) if err != nil { diff --git a/core/files/files.go b/core/files/files.go index eea4446f1..d13662b94 100644 --- a/core/files/files.go +++ b/core/files/files.go @@ -643,7 +643,6 @@ func (s *service) FileByHash(ctx context.Context, id domain.FullFileId) (File, e // info from ipfs fileList, err = s.fileIndexInfo(ctx, id, false) if err != nil { - log.With("fileId", id.FileId.String()).Errorf("FileByHash: failed to retrieve from IPFS: %s", err) return nil, err } ok, err := s.fileStore.IsFileImported(id.FileId) diff --git a/core/filestorage/filesync/upload.go b/core/filestorage/filesync/upload.go index b6d99215c..6dfb1d056 100644 --- a/core/filestorage/filesync/upload.go +++ b/core/filestorage/filesync/upload.go @@ -14,6 +14,7 @@ import ( "github.com/anyproto/any-sync/net/peer" blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" + format "github.com/ipfs/go-ipld-format" "github.com/samber/lo" "go.uber.org/zap" @@ -163,10 +164,12 @@ func (s *fileSync) retryingHandler(ctx context.Context, it *QueueItem) (persiste } } if limitErr == nil || !limitErrorIsLogged { - log.Error("retry uploading file error", - zap.String("fileId", fileId.String()), zap.Error(err), - zap.String("objectId", it.ObjectId), - ) + if !format.IsNotFound(err) && !strings.Contains(err.Error(), "failed to fetch all nodes") { + log.Error("retry uploading file error", + zap.String("fileId", fileId.String()), zap.Error(err), + zap.String("objectId", it.ObjectId), + ) + } } return persistentqueue.ActionRetry, nil diff --git a/core/filestorage/rpcstore/client.go b/core/filestorage/rpcstore/client.go index e97a507a4..57307192c 100644 --- a/core/filestorage/rpcstore/client.go +++ b/core/filestorage/rpcstore/client.go @@ -9,10 +9,12 @@ import ( "time" "github.com/anyproto/any-sync/commonfile/fileproto" + "github.com/anyproto/any-sync/commonfile/fileproto/fileprotoerr" "github.com/anyproto/any-sync/net/pool" "github.com/anyproto/any-sync/net/rpc/rpcerr" "github.com/cheggaaa/mb/v3" "github.com/ipfs/go-cid" + format "github.com/ipfs/go-ipld-format" "go.uber.org/zap" "golang.org/x/exp/slices" "storj.io/drpc" @@ -183,7 +185,11 @@ func (c *client) get(ctx context.Context, spaceID string, cd cid.Cid) (data []by Cid: cd.Bytes(), }) if err != nil { - return rpcerr.Unwrap(err) + err = rpcerr.Unwrap(err) + if errors.Is(err, fileprotoerr.ErrCIDNotFound) { + return format.ErrNotFound{Cid: cd} + } + return err } log.Debug("get cid", zap.String("cid", cd.String())) c.stat.Add(st, len(resp.Data)) diff --git a/core/filestorage/rpcstore/clientmgr.go b/core/filestorage/rpcstore/clientmgr.go index ba51aa430..b85da308e 100644 --- a/core/filestorage/rpcstore/clientmgr.go +++ b/core/filestorage/rpcstore/clientmgr.go @@ -2,6 +2,7 @@ package rpcstore import ( "context" + "errors" "fmt" "math/rand" "time" @@ -28,7 +29,8 @@ type operationNameKeyType string const operationNameKey operationNameKeyType = "operationName" var ( - clientCreateTimeout = 1 * time.Minute + clientCreateTimeout = 1 * time.Minute + ErrNoConnectionToAnyFileClient = errors.New("no connection to any file client") ) func newClientManager(pool pool.Pool, peerStore peerstore.PeerStore, peerUpdateCh chan struct{}) *clientManager { @@ -199,7 +201,7 @@ func (m *clientManager) checkPeers(ctx context.Context, needClient bool) (err er addPeer(peerId) } if m.ocache.Len() == 0 { - return fmt.Errorf("no connection to any file client") + return ErrNoConnectionToAnyFileClient } return nil } diff --git a/core/filestorage/rpcstore/store_test.go b/core/filestorage/rpcstore/store_test.go index 8e946b533..228541444 100644 --- a/core/filestorage/rpcstore/store_test.go +++ b/core/filestorage/rpcstore/store_test.go @@ -9,7 +9,6 @@ import ( "github.com/anyproto/any-sync/accountservice/mock_accountservice" "github.com/anyproto/any-sync/app" - "github.com/anyproto/any-sync/commonfile/fileblockstore" "github.com/anyproto/any-sync/commonfile/fileproto" "github.com/anyproto/any-sync/commonfile/fileproto/fileprotoerr" "github.com/anyproto/any-sync/commonspace/object/accountdata" @@ -18,6 +17,7 @@ import ( "github.com/anyproto/any-sync/nodeconf/mock_nodeconf" blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" + format "github.com/ipfs/go-ipld-format" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" @@ -77,7 +77,7 @@ func TestStore_Get(t *testing.T) { } b, err := fx.Get(ctx, bs[0].Cid()) assert.Nil(t, b) - assert.ErrorIs(t, err, fileblockstore.ErrCIDNotFound) + assert.ErrorIs(t, err, format.ErrNotFound{}) }) } diff --git a/metrics/client.go b/metrics/client.go index d6ad30ca7..062dc9c9c 100644 --- a/metrics/client.go +++ b/metrics/client.go @@ -132,9 +132,6 @@ func (c *client) sendNextBatch(info anymetry.AppInfoProvider, batcher *mb.MB[any err = c.telemetry.SendEvents(msgs, info) if err != nil { - clientMetricsLog. - With("unsent messages", len(msgs)+clientBatcher.Len()). - Error("failed to send messages") if batcher != nil { _ = batcher.TryAdd(msgs...) //nolint:errcheck }