Skip to content

Commit

Permalink
Merge pull request #438 from insolar/mn-399-move-panic-to-the-untilCo…
Browse files Browse the repository at this point in the history
…nnectionError

MN-399: move panic to the until connection error
  • Loading branch information
pavlushev committed Sep 17, 2020
2 parents d482cee + 5674046 commit c59176a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
11 changes: 1 addition & 10 deletions component/storer.go
Expand Up @@ -43,7 +43,7 @@ func makeStorer(
var stat *observer.Statistic

cycle.UntilConnectionError(func() error {
err := db.RunInTransaction(func(tx *pg.Tx) error {
return db.RunInTransaction(func(tx *pg.Tx) error {
// plain records
pulses := postgres.NewPulseStorage(log, tx)
err := pulses.Insert(b.pulse)
Expand Down Expand Up @@ -75,15 +75,6 @@ func makeStorer(
platformNodes.Set(float64(nodes))
return nil
})
if err != nil {
if strings.Contains(err.Error(), "connection refused") ||
strings.Contains(err.Error(), "EOF") {
log.Errorf("Connection refused... %s", err.Error())
return err
}
panic(err)
}
return nil
}, cfg.DB.AttemptInterval, cfg.DB.Attempts, log)

log.Info("items successfully stored")
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Expand Up @@ -14,8 +14,8 @@ require (
github.com/google/uuid v1.1.1
github.com/hashicorp/golang-lru v0.5.3
github.com/insolar/insconfig v0.0.0-20200227134411-011eca6dc866
github.com/insolar/insolar v1.8.1
github.com/insolar/mainnet v1.11.2
github.com/insolar/insolar v1.8.2
github.com/insolar/mainnet v1.11.3
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/labstack/echo/v4 v4.1.11
github.com/mitchellh/mapstructure v1.1.2
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Expand Up @@ -169,8 +169,12 @@ github.com/insolar/insconfig v0.0.0-20200227134411-011eca6dc866 h1:821agB4jwkceJ
github.com/insolar/insconfig v0.0.0-20200227134411-011eca6dc866/go.mod h1:zB9bawcGFKS4hwXcu6yH4rYH06EZnGlFfhl0+KMKM9k=
github.com/insolar/insolar v1.8.1 h1:aQjWMHDgHfatzTWDDn5Xbau202FkGL65x6llLJkEGkw=
github.com/insolar/insolar v1.8.1/go.mod h1:vBRQccV1Uuao6tRxD8Ek45CDp+15LMz15gELb2Qgn34=
github.com/insolar/insolar v1.8.2 h1:d1bZyPvU5z6otUYDpb4JQ7NC2X01gOSYN687Yc+vTNA=
github.com/insolar/insolar v1.8.2/go.mod h1:vBRQccV1Uuao6tRxD8Ek45CDp+15LMz15gELb2Qgn34=
github.com/insolar/mainnet v1.11.2 h1:GZv0IkJdBDjwCbO6MKuEsmR87j4fqIkvUNnvtWFYNqs=
github.com/insolar/mainnet v1.11.2/go.mod h1:07KeBiurhBYvxdhC1MqCcpXdMXDAkJ3v8/VaficAYIA=
github.com/insolar/mainnet v1.11.3 h1:ClIbO/4iKxj3hkxqA8mXcIlEf54dsRgo4F3inlXKPVU=
github.com/insolar/mainnet v1.11.3/go.mod h1:Ob3JpozS3MtAyWN06tk/ztU9WLvRZJ6C1MYsOriT+TM=
github.com/insolar/ratelimiter v1.0.0/go.mod h1:tdN/LjBmGJt5/dfwAQk+0GXVtv2f+mGKvXpnt2FBpfs=
github.com/insolar/rpc v1.2.2-0.20200331123021-db57b8833f82/go.mod h1:BZcTsPtQu8QG8RqqQdAnuNAG8n6TOrdNxIHro0h99Ik=
github.com/insolar/x-crypto v0.0.0-20191031140942-75fab8a325f6 h1:WS4a7qw+P1pcnviyxyMTA/aR+T51wJok1IC9rJkHrTg=
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/cycle/until.go
Expand Up @@ -27,7 +27,7 @@ func UntilConnectionError(f func() error, interval time.Duration, attempts Limit
for {
err := f()
if err != nil {
if !strings.Contains(err.Error(), "connection") || counter >= attempts {
if (!strings.Contains(err.Error(), "connection") && !strings.Contains(err.Error(), "EOF")) || counter >= attempts {
panic(err)
}
log.Errorf("Connection error, try again (attempt %d, totalAttempts %d) %+v", counter, attempts, err)
Expand Down
2 changes: 2 additions & 0 deletions vendor/github.com/insolar/insolar/configuration/exporter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Expand Up @@ -96,7 +96,7 @@ github.com/hashicorp/hcl/json/token
github.com/insolar/gls
# github.com/insolar/insconfig v0.0.0-20200227134411-011eca6dc866
github.com/insolar/insconfig
# github.com/insolar/insolar v1.8.1
# github.com/insolar/insolar v1.8.2
github.com/insolar/insolar/api/requester
github.com/insolar/insolar/application
github.com/insolar/insolar/application/appfoundation
Expand Down Expand Up @@ -150,7 +150,7 @@ github.com/insolar/insolar/platformpolicy/internal/hash
github.com/insolar/insolar/platformpolicy/internal/sign
github.com/insolar/insolar/pulse
github.com/insolar/insolar/reference
# github.com/insolar/mainnet v1.11.2
# github.com/insolar/mainnet v1.11.3
github.com/insolar/mainnet/application
github.com/insolar/mainnet/application/appfoundation
github.com/insolar/mainnet/application/builtin/contract/account
Expand Down

0 comments on commit c59176a

Please sign in to comment.