2021年1月23日星期六

Race-condition with errgroup?

g.Go(func() error {      result, err := makeDBCall()      if err != nil {          fmt.Println("Error 1")          return err      }      return nil  }    g.Go(func() error {      result, err := makeAnotherDBCall()      if err != nil {          fmt.Println("Error 2")          return err      }      return nil  }    g.Go(func() error {      result, err := makeAnotherAnotherDBCall()      if err != nil {          fmt.Println("Error 3")          return err      }      return nil  }    err := g.Wait()  if err != nil {      return  }    fmt.Println("Done with error Group")  

I intentionally make one of the dbCall() functions to return an error. Out of 10 requests made, maybe 3-5 have an output of:

Starting err group

Error 1

Done with error Group

https://stackoverflow.com/questions/65866317/race-condition-with-errgroup January 24, 2021 at 09:28AM

没有评论:

发表评论