From 97f4c6e3dfc65e91126371c597da41c296ccd902 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Fri, 16 Aug 2024 13:43:54 +0100 Subject: [PATCH] feat_: Flush hystrix on going back online When going offline, all the rpc calls fail making hystrix open all the circuits. This commit changes the behavior so that when we go back online, we close all the circuits. We should also avoid making rpc requests while offline, but this should work for release. --- api/geth_backend.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/geth_backend.go b/api/geth_backend.go index 63af9436a..91c85fcdf 100644 --- a/api/geth_backend.go +++ b/api/geth_backend.go @@ -15,6 +15,7 @@ import ( "go.uber.org/zap" + "github.com/afex/hystrix-go/hystrix" "github.com/pkg/errors" "github.com/imdario/mergo" @@ -2434,6 +2435,12 @@ func (b *GethStatusBackend) ConnectionChange(typ string, expensive bool) { b.log.Info("Network state change", "old", b.connectionState, "new", state) + if b.connectionState.Offline && !state.Offline { + // flush hystrix if we are going again online, since it doesn't behave + // well when offline + hystrix.Flush() + } + b.connectionState = state b.statusNode.ConnectionChanged(state)