posts_per_page => -1 is a promise you cannot keep

An unbounded query works on the development database with four hundred rows and takes the site down at forty thousand.

// the shape to grep for
'posts_per_page' => -1

// what to write instead, when you genuinely need all of them
$paged = 1;

do {
    $batch = get_posts( array(
        'posts_per_page' => 200,
        'paged'          => $paged++,
        'fields'         => 'ids',
    ) );

    foreach ( $batch as $id ) { /* ... */ }
} while ( count( $batch ) === 200 );

fields => 'ids' is the other half and is frequently enough on its own: it skips hydrating every post object and priming the meta cache, which is most of the memory. The failure is memory exhaustion partway through, so the request dies with no output and the log says only that the memory limit was reached. Grepping for -1 across a codebase is a five-minute audit that finds real problems on most sites.