thread safety fix for MySQL scenario