diff --git a/sda/internal/database/db_functions.go b/sda/internal/database/db_functions.go index 3b7975edf..f9cf2eb66 100644 --- a/sda/internal/database/db_functions.go +++ b/sda/internal/database/db_functions.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "errors" "math" + "strings" "time" log "github.com/sirupsen/logrus" @@ -671,7 +672,7 @@ func (dbs *SDAdb) GetCorrID(user, path string) (string, error) { // 2, 4, 8, 16, 32 seconds between each retry event. for count := 1; count <= RetryTimes; count++ { corrID, err = dbs.getCorrID(user, path) - if err == nil { + if err == nil || strings.Contains(err.Error(), "sql: no rows in result set") { break } time.Sleep(time.Duration(math.Pow(2, float64(count))) * time.Second) @@ -755,7 +756,7 @@ func (dbs *SDAdb) AddKeyHash(keyHash, keyDescription string) error { // 2, 4, 8, 16, 32 seconds between each retry event. for count := 1; count <= RetryTimes; count++ { err = dbs.addKeyHash(keyHash, keyDescription) - if err == nil { + if err == nil || strings.Contains(err.Error(), "key hash already exists") { break } time.Sleep(time.Duration(math.Pow(2, float64(count))) * time.Second)