Skip to content

Commit

Permalink
Ignore "connection reset" errors while initializing the targets with …
Browse files Browse the repository at this point in the history
…queue store enabled (minio#8185)

Fixes minio#8178
  • Loading branch information
Praveenrajmani authored and harshavardhana committed Sep 5, 2019
1 parent 259a5d8 commit 428836d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/event/target/amqp.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func NewAMQPTarget(id string, args AMQPArgs, doneCh <-chan struct{}) (*AMQPTarge

conn, err = amqp.Dial(args.URL.String())
if err != nil {
if store == nil || !IsConnRefusedErr(err) {
if store == nil || !(IsConnRefusedErr(err) || IsConnResetErr(err)) {
return nil, err
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/event/target/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func NewMySQLTarget(id string, args MySQLArgs, doneCh <-chan struct{}) (*MySQLTa

err = target.db.Ping()
if err != nil {
if target.store == nil || !IsConnRefusedErr(err) {
if target.store == nil || !(IsConnRefusedErr(err) || IsConnResetErr(err)) {
return nil, err
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/event/target/nsq.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func NewNSQTarget(id string, args NSQArgs, doneCh <-chan struct{}) (*NSQTarget,

if err := target.producer.Ping(); err != nil {
// To treat "connection refused" errors as errNotConnected.
if target.store == nil || !IsConnRefusedErr(err) {
if target.store == nil || !(IsConnRefusedErr(err) || IsConnResetErr(err)) {
return nil, err
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/event/target/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func NewPostgreSQLTarget(id string, args PostgreSQLArgs, doneCh <-chan struct{})

err = target.db.Ping()
if err != nil {
if target.store == nil || !IsConnRefusedErr(err) {
if target.store == nil || !(IsConnRefusedErr(err) || IsConnResetErr(err)) {
return nil, err
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/event/target/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func NewRedisTarget(id string, args RedisArgs, doneCh <-chan struct{}) (*RedisTa

_, pingErr := conn.Do("PING")
if pingErr != nil {
if target.store == nil || !IsConnRefusedErr(pingErr) {
if target.store == nil || !(IsConnRefusedErr(pingErr) || IsConnResetErr(pingErr)) {
return nil, pingErr
}
} else {
Expand Down
10 changes: 7 additions & 3 deletions pkg/event/target/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ func IsConnRefusedErr(err error) bool {
return false
}

// isConnResetErr - Checks for connection reset errors.
func isConnResetErr(err error) bool {
// IsConnResetErr - Checks for connection reset errors.
func IsConnResetErr(err error) bool {
if strings.Contains(err.Error(), "connection reset by peer") {
return true
}
// incase if error message is wrapped.
if opErr, ok := err.(*net.OpError); ok {
if syscallErr, ok := opErr.Err.(*os.SyscallError); ok {
if syscallErr.Err == syscall.ECONNRESET {
Expand All @@ -117,7 +121,7 @@ func sendEvents(target event.Target, eventKeyCh <-chan string, doneCh <-chan str
break
}

if err != errNotConnected && !isConnResetErr(err) {
if err != errNotConnected && !IsConnResetErr(err) {
panic(fmt.Errorf("target.Send() failed with '%v'", err))
}

Expand Down

0 comments on commit 428836d

Please sign in to comment.