Skip to content

Commit

Permalink
add some extra logs for debugging sync issues (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping authored Sep 27, 2023
2 parents 5a4f71b + f554233 commit 0dbe63e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions bgs/bgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,8 +764,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 {
Expand All @@ -787,9 +791,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))
Expand Down
2 changes: 1 addition & 1 deletion indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,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
}
Expand Down

0 comments on commit 0dbe63e

Please sign in to comment.