Skip to content

Commit

Permalink
Rewind cursor a bit before reconnection for some relay hosts to smoot…
Browse files Browse the repository at this point in the history
…h over reconnection (#825)

We see some jerk when the Relay restarts caused by high concurrency of
event processing for some high traffic hosts, where some in-progress
event handlers die while the cursor is advanced ahead of them and the
next event for that repo triggers a catch-up/resync of the repo. This
change rewinds the cursor a bit on reconnect to smooth out that process.
  • Loading branch information
whyrusleeping authored Nov 19, 2024
2 parents 65fa60b + fa1eb34 commit 966c093
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bgs/fedmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,11 @@ func (s *Slurper) subscribeWithRedialer(ctx context.Context, host *models.PDS, s
protocol = "wss"
}

// Special case `.host.bsky.network` PDSs to rewind cursor by 200 events to smooth over unclean shutdowns
if strings.HasSuffix(host.Host, ".host.bsky.network") && host.Cursor > 200 {
host.Cursor -= 200
}

cursor := host.Cursor

var backoff int
Expand Down

0 comments on commit 966c093

Please sign in to comment.