bug fix mysql write connection release outside of transaction