Pagination problem

The function redirect_canonical() is ‘responsible’ for your problem.

Your default WordPress pagination (with core functions) is not gonna work if you do this, but you can filter out the pagination for your particular custom url:

add_filter( 'redirect_canonical', 'wp230913_canonical', 10, 2 );

function wp230913_canonical( $redirect_url, $requested_url ) {
    if ( preg_match( "#foo/bar/[0-9]+/page/[0-9]+#", $redirect_url ) ) {
        return $requested_url;
    }

    return $redirect_url;
}

My recomandation is to change the pagination base for the whole site, changing $wp_rewrite->pagination_base