Azure VMs seems to kill long running MySql queries Azure VMs seems to kill long running MySql queries azure azure

Azure VMs seems to kill long running MySql queries


After some research I found a low level workaround which should always work, I inject a lib into any binary that makes all the sockets KEEP-ALIVE using LD_PRELOAD. The lib I inject is libdontdie, a fork of an older lib: libkeepalive.

After building the lib I run:date && time DD_DEBUG=1 DD_TCP_KEEPALIVE_TIME=4 DD_TCP_KEEPALIVE_INTVL=5 DD_TCP_KEEPALIVE_PROBES=6 LD_PRELOAD=/usr/lib/libdontdie.so mysql -h$SERVER -u$USER -D mydb -p$PASS -e "SELECT SLEEP(300);"

And it works as expected (tested on both a VM in azure and a docker image inside AKS).