MySQL connection issues on hosted Azure MySQL

Hey man, how does the OSS build for drone work in terms of connection to databases?
I see that the non-OSS build does a bit more around actual detection of and configuration of db driver.

Main reason: You know how I was having those weird issues with drone keeling over for no reason and leaving builds in pending? I’ve been able to (hopefully) track it down with the trace logs.

We use hosted Azure MySQL which has a super low wait_timeout compared to normal MySQL defaults, which leads to the MySQL server killing idle connections without the go/mysql driver able to know.

I’m beginning to think that’s the issue I’m seeing here…
If I reload the drone homepage about 5 times, drone then manages to re-authenticate to MySQL and then starts the jobs that were backed up/stuck in pending.

I see the non-oss has one fix for this by setting db.SetMaxIdleConns(0) on the MySQL driver…
What we did for our services was to use db.SetConnMaxLifetime((serverTimeout - 2) * time.Second) where serverTimeout is pulled from the the value of wait_timeout.

What’s the best way around this?

The idle connection issues you are describing are mitigated by using SetMaxIdleConns to zero. When set to zero it ensures that Drone always creates a new connection for every database query. Thus a timeout would not be a problem since every connection is newly created.