google / google/certificate-transparency-go

Retriable errors and backoffs

Open
#898 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.2k
Forks
322
Avg merge
3d 4h
Merged PRs (30d)
5

Description

I'm [working on a tool that uses fetcher.go, and also calls GetProofByHash](https://github.com/aarongable/ctaudit/pull/1). I'd like to configure it to do backoffs and retries. I see that fetcher.go uses a `Backoff` struct provided internally:

https://github.com/google/certificate-transparency-go/blob/6ecca400d5e42ae3f26ad5c27cea9f907474024d/scanner/fetcher.go#L273-L292

But I think that usage might be broken. `Backoff` will only retry on grpc error codes that are retriable, plus the `RetriableError` struct. The GetRawEntries call I linked to is implemented by `jsonclient.GetAndParse`, which [returns RspErrors](https://github.com/google/certificate-transparency-go/blob/6ecca400d5e42ae3f26ad5c27cea9f907474024d/jsonclient/client.go#L169-L209). Those RspErrors don't match any of the conditions for retries.

I'd like to propose this: In addition to / instead of backoff.RetriableError, the backoff package should check for some interface, e.g. `Retryable() bool`. Then `jsonclient.RspError` can implement `Retryable()` as: a RspError is retryable if its wrapped error is a net.Timeout error OR the HTTP status code is >500.

What do you think?

Contributor guide

Open the contributing guide

Research direction

Start by reading scanner/fetcher.go around the Backoff usage and jsonclient/client.go around GetAndParse and RspError. Trace how retry decisions are made for gRPC errors, RetriableError, and RspErrors; done means the proposed retry behavior for timeout and HTTP status errors is defined and covered consistently across these entry points.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.