Skip to content

Commit

Permalink
Add retires on blob-archiver startup
Browse files Browse the repository at this point in the history
  • Loading branch information
danyalprout committed Feb 17, 2024
1 parent 20cf2d4 commit 6de7b7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions archiver/service/archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import (
"github.com/ethereum/go-ethereum/log"
)

const maxLiveAttempts = 10
const liveFetchBlobMaximumRetries = 10
const startupFetchBlobMaximumRetries = 3
const backfillErrorRetryInterval = 5 * time.Second

var ErrAlreadyStopped = errors.New("already stopped")
Expand Down Expand Up @@ -77,7 +78,10 @@ func (a *ArchiverService) Start(ctx context.Context) error {

a.log.Info("Archiver API server started", "address", srv.Addr().String())

currentBlob, _, err := a.persistBlobsForBlockToS3(ctx, "head")
currentBlob, _, err := retry.Do2(ctx, startupFetchBlobMaximumRetries, retry.Exponential(), func() (*v1.BeaconBlockHeader, bool, error) {
return a.persistBlobsForBlockToS3(ctx, "head")
})

if err != nil {
a.log.Error("failed to seed archiver with initial block", "err", err)
return err
Expand Down Expand Up @@ -225,7 +229,7 @@ func (a *ArchiverService) processBlocksUntilKnownBlock(ctx context.Context) {
currentBlockId := "head"

for {
current, alreadyExisted, err := retry.Do2(ctx, maxLiveAttempts, retry.Exponential(), func() (*v1.BeaconBlockHeader, bool, error) {
current, alreadyExisted, err := retry.Do2(ctx, liveFetchBlobMaximumRetries, retry.Exponential(), func() (*v1.BeaconBlockHeader, bool, error) {
return a.persistBlobsForBlockToS3(ctx, currentBlockId)
})

Expand Down
4 changes: 2 additions & 2 deletions archiver/service/archiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ func TestArchiver_LatestHaltsOnPersistentError(t *testing.T) {
fs.CheckNotExistsOrFail(t, blobtest.Four)
fs.CheckExistsOrFail(t, blobtest.Three)

// One failure is retried
fs.WritesFailTimes(maxLiveAttempts + 1)
// Retries the maximum number of times, then fails and will not write the blobs
fs.WritesFailTimes(liveFetchBlobMaximumRetries + 1)
svc.processBlocksUntilKnownBlock(context.Background())

fs.CheckNotExistsOrFail(t, blobtest.Five)
Expand Down

0 comments on commit 6de7b7b

Please sign in to comment.