Your Question
Hi,
I am trying to create a *gorm.DB connection using jinzhu/gorm repo. Here is how i am creating the connection:
dbDSN := fmt.Sprintf("host=%v user=%v password=%v dbname=%v port=%v sslmode=%v", os.Getenv("PGHOST"), os.Getenv("PGUSER"), os.Getenv("PGPASSWORD"), os.Getenv("PGDATABASE"), os.Getenv("PGPORT"), os.Getenv("PGSSLMODE"))
DBConn, err = gorm.Open("postgres, dbDSN);
We are running a http server which on coming up keeps this DBConn and keep it till the lifecylce of the server. I see that intermittently on invoking any kind of queries (insert/select) we get :write tcp xx.xx.xx.xx:40968->xx.xx.xx.xx:5432: write: broken pipe errors.
This http server is running on a k8 pod. the container has psql installed and we can connect to psql commandline but when we server http requests we get this error. Could you please let us know if this have been seen earlier or not?
The document you expected this should be explained
Expected answer
Comment From: ghost
@AnkitNassa If this issue is happening in your server environment, you need to see if there are network connectivity issues. refer here
Comment From: ankit-nassa
@AnkitNassa If this issue is happening in your server environment, you need to see if there are network connectivity issues. refer here
Thanks @jinzhu . You were right there were issues in our DB server which was getting restarted. Sorry for the trouble.
Comment From: tuwid
Keep in mind that transient issues can also be mitigated by setting this parameter SetConnMaxLifetime to make sure the connections are recycled