1

I am using Go, Fiber web framework, mariadb 10.6, debian 11 and github.com/go-sql-driver/mysql to connection to mariadb. I have played with these settings

db.SetMaxOpenConns(25)
db.SetMaxIdleConns(25)
db.SetConnMaxLifetime(5 * time.Minute)

ie I increase the values, decrease values but still get like 1 or 2 waring

packets.go:123: closing bad idle connection: connection reset by peer

per minute. Any suggestion?

answar was I was having wait_timeout 20 second and interactive timeout 50 second I increased now its fixed thanks to @ysth for solution

  • 1
    The remote side of the connection is being closed, the client settings won't tell you why the server is closing the connections. – JimB Jan 03 '23 at 14:04
  • 1
    what do `select @@wait_timeout` and `select @@interactive_timeout` show? – ysth Jan 03 '23 at 19:04
  • wait is 20 and interactive is 50 @ysth – Ravyar Tahir Jan 03 '23 at 19:25
  • @JimB both running on same server using tcp connection, I am running other application on same server mostly python flask using pymysql none of them has this issue, I dont know where did I go wrong either in mysql or go setting or mismatcj between them – Ravyar Tahir Jan 03 '23 at 19:28
  • 1
    Those are super low values; they default to 28800 or something like that. Why is the server configured that way? – ysth Jan 03 '23 at 19:29
  • what recommended values for both of them ? I installed it with hestiacp ? it could be that or I messed it up in my.cnf setting when I tried to adjust for ram usage, I am using 1.2 gb ram of 2 gb vps for mariadb 10.6 @ysth – Ravyar Tahir Jan 03 '23 at 19:39
  • 1
    leave them at the default, unless you were having a problem with running out of connections (and even then, increasing max connections would be better) – ysth Jan 03 '23 at 19:45
  • @ysth I did that my ram usage dropped from 1.2 GB to 450 MB not sure about that caused by that change or restarting the service thank you, I will monitor server tomorrow when clients come online I try then see if that issue resolve or not, I tried using the phone and two pc to kinda simulate some load all look great so far – Ravyar Tahir Jan 03 '23 at 20:05
  • 1
    sounds like you had some other conf changes that you didn't restart after – ysth Jan 03 '23 at 20:09
  • doubtful, I made all the changes throw Hestia cp when you save it, it will automatically restart it for you, it's possible the setting could be so bad after a while it fills the ram like that, I am good with query optimization, normalization tables..etc. but I am not that good with the setting, I will monitor the server, and I have a backup server if any issue arises, so nothing to worry about @ysth i – Ravyar Tahir Jan 03 '23 at 20:18
  • Report this to go-sql-driver authors. The warning is nonsense. The connection to be closed is already closed. – Vladislav Vaintroub Jan 04 '23 at 12:07
  • no this was correct, it was my mistake, thanks to @ysth it's fixed now, MySQL timeout was only 20 seconds while if you look at the code its five minutes, so times out, and ytsh it's back to 1.2GB of ram, I need improve MySQL setting but that is another issue not related to this so thank you – Ravyar Tahir Jan 04 '23 at 13:02

1 Answers1

0

the answer was I was having wait_timeout 20 seconds and interactive timeout 50 seconds I increased now its fixed thanks to @ysth for the solution