Hey I'm getting an error message : conn busy
from pgx
I don't know how to solve this. Here is my function :
func (r *proverbRepo) SelectPendingProverbs(table string) (proverbs []domain.Proverb, err error) {
query := fmt.Sprintf("SELECT id, proverb literal FROM %s", table)
rows, err := r.Db.Query(context.Background(), query)
defer rows.Close()
if err != nil {
return
}
for rows.Next() {
var prov domain.Proverb
if err = rows.Scan(&prov.ID, &prov.Literal); err != nil {
return
}
proverbs = append(proverbs, prov)
}
return
}
r.Db
is pgx.Connect(context.Background(), os.Getenv("PSQL_URL"))
I'm fetching two different table in a very short interval from two separate front end requests.
The first request goes through, the other one returns the conn busy
error message.
I really don't know what to look for, would somebody help me ?
nil
rows instance. Not good practice. – Jegar