What version of Go are you using (go version)?

1.10.3

Which database and its version are you using?

postgresql 9.6.3


// db   connection 
    conn = "host=localhost port=5432 dbname=postg sslmode=disable"
    db, err := gorm.Open("postgres", conn)

        db.DB().SetConnMaxLifetime(time.Minute * 5)
    db.DB().SetMaxIdleConns(5)
    db.DB().SetMaxOpenConns(7)

Originally, I did not set the following config

        db.DB().SetConnMaxLifetime(time.Minute * 5)
    db.DB().SetMaxIdleConns(5)
    db.DB().SetMaxOpenConns(7)

Occasionally, the following error comes up read tcp x.x.x.x:57752->x.x.x.x:5432: read: connection reset by peer .

I thought it is caused by the closed channel by postgresql server reused by gorm client again, so I add the above connection pool config. However, the above error comes up again.

Is there anything wrong when I set the connection pool? or anything am I missing?

Comment From: ceo0x

same here

Comment From: weters

I am also seeing this issue. I'm using Pg 11.1 and Go 1.11.2.

Comment From: ceth-x86

I have the same issue:

[2019-01-21 16:57:02]  [1.86ms]  SELECT ......
[1 rows affected or returned ]

(/go/src/web-services/datastore/techplace.go:81) 
[2019-01-21 18:20:04]  read tcp 10.81.74.132:51416->10.81.74.68:5432: read: connection reset by peer 

(/go/src/web-services/datastore/techplace.go:81) 
[2019-01-21 18:20:04]  [1.96ms]  SELECT .....  
[0 rows affected or returned ]

If I rerun the last query again I'll receive one row. It looks as if the connection is broken, but the driver does not return an error, but says that there are no rows.

Comment From: openkengboy

I have the same issue

Comment From: zuoRambo

vote for the issue

Comment From: efrengarcial

+1

Comment From: rafareyes7

+1

Comment From: rynslmns

+1

Comment From: quang-phan

+1

Comment From: github-actions[bot]

This issue will be automatically closed because it is marked as GORM V1 issue, we have released the public testing GORM V2 release and its documents https://v2.gorm.io/docs/ already, the testing release has been used in some production services for a while, and going to release the final version in following weeks, we are still actively collecting feedback before it, please open a new issue for any suggestion or problem, thank you

Also check out https://github.com/go-gorm/gorm/wiki/GORM-V2-Release-Note-Draft for how to use the public testing version and its changelog

Comment From: yangzj

same