I believe the middleware commits at the end of the request, or rolls back if there was an exception.