Skip to content

Commit

Permalink
Merge pull request #46 from milanbhagwat/master
Browse files Browse the repository at this point in the history
Adding err nil check
  • Loading branch information
vijaynalawade authored May 30, 2022
2 parents 45f6005 + f7910b2 commit c75336e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions flow-state/store/postgres/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,10 @@ func (s *StepStore) GetAppState(metadata *metadata.Metadata) (string, error) {

func (s *StepStore) SaveAppState(metadata *metadata.Metadata) error {
_, err := s.db.InsertAppState(metadata)
if err == driver.ErrBadConn || strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "network is unreachable") ||
if err != nil && (err == driver.ErrBadConn || strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "network is unreachable") ||
strings.Contains(err.Error(), "connection reset by peer") || strings.Contains(err.Error(), "dial tcp: lookup") ||
strings.Contains(err.Error(), "timeout") || strings.Contains(err.Error(), "timedout") ||
strings.Contains(err.Error(), "timed out") || strings.Contains(err.Error(), "net.Error") || strings.Contains(err.Error(), "i/o timeout") {
strings.Contains(err.Error(), "timed out") || strings.Contains(err.Error(), "net.Error") || strings.Contains(err.Error(), "i/o timeout")) {
if retryErr := s.RetryDBConnection(); retryErr == nil {
logCache.Debug("Retrying from SaveAppState after successful connection retry ")
_, err = s.db.InsertAppState(metadata)
Expand All @@ -590,10 +590,10 @@ func (s *StepStore) SaveAppState(metadata *metadata.Metadata) error {

func (s *StepStore) SaveStep(step *state.Step) error {
_, err := s.db.InsertSteps(step)
if err == driver.ErrBadConn || strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "network is unreachable") ||
if err != nil && (err == driver.ErrBadConn || strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "network is unreachable") ||
strings.Contains(err.Error(), "connection reset by peer") || strings.Contains(err.Error(), "dial tcp: lookup") ||
strings.Contains(err.Error(), "timeout") || strings.Contains(err.Error(), "timedout") ||
strings.Contains(err.Error(), "timed out") || strings.Contains(err.Error(), "net.Error") || strings.Contains(err.Error(), "i/o timeout") {
strings.Contains(err.Error(), "timed out") || strings.Contains(err.Error(), "net.Error") || strings.Contains(err.Error(), "i/o timeout")) {
if retryErr := s.RetryDBConnection(); retryErr == nil {
logCache.Debugf("Retrying from SaveStep after successful connection retry ")
_, err = s.db.InsertSteps(step)
Expand All @@ -611,10 +611,10 @@ func (s *StepStore) SaveStep(step *state.Step) error {

func (s *StepStore) DeleteSteps(flowId string, stepId string) error {
_, err := s.db.DeleteSteps(flowId, stepId)
if err == driver.ErrBadConn || strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "network is unreachable") ||
if err != nil && (err == driver.ErrBadConn || strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "network is unreachable") ||
strings.Contains(err.Error(), "connection reset by peer") || strings.Contains(err.Error(), "dial tcp: lookup") ||
strings.Contains(err.Error(), "timeout") || strings.Contains(err.Error(), "timedout") ||
strings.Contains(err.Error(), "timed out") || strings.Contains(err.Error(), "net.Error") || strings.Contains(err.Error(), "i/o timeout") {
strings.Contains(err.Error(), "timed out") || strings.Contains(err.Error(), "net.Error") || strings.Contains(err.Error(), "i/o timeout")) {
if retryErr := s.RetryDBConnection(); retryErr == nil {
logCache.Debugf("Retrying from DeleteSteps after successful connection retry ")
_, err = s.db.DeleteSteps(flowId, stepId)
Expand Down Expand Up @@ -993,10 +993,10 @@ func (s *StepStore) GetSnapshot(flowId string) *state.Snapshot {

func (s *StepStore) RecordStart(flowState *state.FlowState) error {
_, err := s.db.InsertFlowState(flowState)
if err == driver.ErrBadConn || strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "network is unreachable") ||
if err != nil && (err == driver.ErrBadConn || strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "network is unreachable") ||
strings.Contains(err.Error(), "connection reset by peer") || strings.Contains(err.Error(), "dial tcp: lookup") ||
strings.Contains(err.Error(), "timeout") || strings.Contains(err.Error(), "timedout") ||
strings.Contains(err.Error(), "timed out") || strings.Contains(err.Error(), "net.Error") || strings.Contains(err.Error(), "i/o timeout") {
strings.Contains(err.Error(), "timed out") || strings.Contains(err.Error(), "net.Error") || strings.Contains(err.Error(), "i/o timeout")) {
if retryErr := s.RetryDBConnection(); retryErr == nil {
logCache.Debug("Retrying from RecordStart after successful connection retry ")
_, err = s.db.InsertFlowState(flowState)
Expand All @@ -1014,10 +1014,10 @@ func (s *StepStore) RecordStart(flowState *state.FlowState) error {

func (s *StepStore) RecordEnd(flowState *state.FlowState) error {
_, err := s.db.UpdateFlowState(flowState)
if err == driver.ErrBadConn || strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "network is unreachable") ||
if err != nil && (err == driver.ErrBadConn || strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "network is unreachable") ||
strings.Contains(err.Error(), "connection reset by peer") || strings.Contains(err.Error(), "dial tcp: lookup") ||
strings.Contains(err.Error(), "timeout") || strings.Contains(err.Error(), "timedout") ||
strings.Contains(err.Error(), "timed out") || strings.Contains(err.Error(), "net.Error") || strings.Contains(err.Error(), "i/o timeout") {
strings.Contains(err.Error(), "timed out") || strings.Contains(err.Error(), "net.Error") || strings.Contains(err.Error(), "i/o timeout")) {
if retryErr := s.RetryDBConnection(); retryErr == nil {
logCache.Debug("Retrying to call RecordEnd after successful connection retry ")
_, err = s.db.UpdateFlowState(flowState)
Expand Down

0 comments on commit c75336e

Please sign in to comment.