Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exponential backoff retry on EthBroadcaster send transaction timeout #6948

Merged
merged 2 commits into from
Jul 12, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions core/chains/evm/txmgr/eth_broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

gethCommon "github.com/ethereum/go-ethereum/common"
"github.com/jackc/pgconn"
"github.com/jpillora/backoff"
"github.com/pkg/errors"
"gopkg.in/guregu/null.v4"

Expand Down Expand Up @@ -204,20 +205,37 @@ func (eb *EthBroadcaster) ethTxInsertTriggerer() {
}
}

func (eb *EthBroadcaster) newResendBackoff() backoff.Backoff {
return backoff.Backoff{
Min: 1 * time.Second,
Max: 15 * time.Second,
Jitter: true,
}
}

func (eb *EthBroadcaster) monitorEthTxs(k ethkey.State, triggerCh chan struct{}) {
ctx, cancel := utils.ContextFromChan(eb.chStop)
defer cancel()

// errorRetryCh allows retry on exponential backoff in case of timeout or
// other unknown error
var errorRetryCh <-chan time.Time
bf := eb.newResendBackoff()

defer eb.wg.Done()
for {
pollDBTimer := time.NewTimer(utils.WithJitter(eb.config.TriggerFallbackDBPollInterval()))

if err := eb.ProcessUnstartedEthTxs(ctx, k); err != nil {
errorRetryCh = time.After(bf.Duration())
if errors.Is(err, context.DeadlineExceeded) {
eb.logger.Errorw("Timed out while handling eth_tx queue in ProcessUnstartedEthTxs", "err", err)
} else {
eb.logger.Criticalw("Unknown error occurred while handling eth_tx queue in ProcessUnstartedEthTxs. This chain/RPC client may not be supported", "err", err)
}
} else {
bf = eb.newResendBackoff()
errorRetryCh = nil
}

select {
Expand All @@ -236,6 +254,9 @@ func (eb *EthBroadcaster) monitorEthTxs(k ethkey.State, triggerCh chan struct{})
case <-pollDBTimer.C:
// DB poller timed out
continue
case <-errorRetryCh:
// Error backoff period reached
continue
}
}
}
Expand Down