DEV Community

Discussion on: Go sql.DB Periodic Error: invalid connection

Collapse
 
plutov profile image
Alex Pliutau

I don't think it's a good workaround. What happens if you lost connection but your goroutine is still waiting for next run?

Also, instead of for+sleep you can use time.NewTicker

Collapse
 
aaronellington profile image
Aaron Ellington

I don't think it's a good workaround. What happens if you lost connection but your goroutine is still waiting for next run?

So would the suggestion here be to retry faster if the connection is lost?

Also, instead of for+sleep you can use time.NewTicker

Thanks, I'll look into that!