From f554233358e8b527f14e6dfb6bb127aecde01d89 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 27 Sep 2023 10:11:13 -0700 Subject: [PATCH] add some extra logs for debugging sync issues --- bgs/bgs.go | 12 ++++++++---- indexer/indexer.go | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bgs/bgs.go b/bgs/bgs.go index bc2a9972f..8d92f9a12 100644 --- a/bgs/bgs.go +++ b/bgs/bgs.go @@ -744,8 +744,12 @@ func (bgs *BGS) handleFedEvent(ctx context.Context, host *models.PDS, env *event return nil } + if evt.Rebase { + return fmt.Errorf("rebase was true in event seq:%d,host:%s", evt.Seq, host.Host) + } + // skip the fast path for rebases or if the user is already in the slow path - if evt.Rebase || bgs.Index.Crawler.RepoInSlowPath(ctx, host, u.ID) { + if bgs.Index.Crawler.RepoInSlowPath(ctx, host, u.ID) { rebasesCounter.WithLabelValues(host.Host).Add(1) ai, err := bgs.Index.LookupUser(ctx, u.ID) if err != nil { @@ -767,9 +771,9 @@ func (bgs *BGS) handleFedEvent(ctx context.Context, host *models.PDS, env *event log.Warnw("failed handling event", "err", err, "host", host.Host, "seq", evt.Seq, "repo", u.Did, "prev", stringLink(evt.Prev), "commit", evt.Commit.String()) if errors.Is(err, carstore.ErrRepoBaseMismatch) || ipld.IsNotFound(err) { - ai, err := bgs.Index.LookupUser(ctx, u.ID) - if err != nil { - return fmt.Errorf("failed to look up user (err case): %w", err) + ai, lerr := bgs.Index.LookupUser(ctx, u.ID) + if lerr != nil { + return fmt.Errorf("failed to look up user %s (%d) (err case: %s): %w", u.Did, u.ID, err, lerr) } span.SetAttributes(attribute.Bool("catchup_queue", true)) diff --git a/indexer/indexer.go b/indexer/indexer.go index 711b6d182..95a258cad 100644 --- a/indexer/indexer.go +++ b/indexer/indexer.go @@ -454,7 +454,7 @@ func (ix *Indexer) FetchAndIndexRepo(ctx context.Context, job *crawlWork) error for i, j := range job.catchup { catchupEventsProcessed.Inc() if err := ix.repomgr.HandleExternalUserEvent(ctx, pds.ID, ai.Uid, ai.Did, j.evt.Since, j.evt.Rev, j.evt.Blocks, j.evt.Ops); err != nil { - log.Errorw("buffered event catchup failed", "error", err, "did", ai.Did, "i", i, "jobCount", len(job.catchup)) + log.Errorw("buffered event catchup failed", "error", err, "did", ai.Did, "i", i, "jobCount", len(job.catchup), "seq", j.evt.Seq) resync = true // fall back to a repo sync break }