Updated the MySQL api to work with deferred handlers