fixed mysql connection issue

seemed to be related to async access of connection. fixed by making a
thread local connection.