Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Issue with "Page token is not valid" error when using Paginated queries

Good afternoon,

I encountered an issue when trying to execute a paginated query using a page token in two queries. Specifically, I receive the following error:
"Page token is not valid for results from job *:US.*.".

This was working fine until early Friday morning, but now I'm seeing the error. I have several other tables in the project using the same method, and all of them are working fine except for one.

I also verified that when executing the query in parallel, there are no changes to the data. Additionally, since new tables are created daily, I tried querying older tables (for example, from last week), but the error persists.

There have been no updates to the libraries I am using (I rely on google/cloud, which uses google/cloud-bigquery: 1.29.1 for PHP), and no changes have been made to the code.

Could you please help me investigate this issue?

Thank you in advance.

1 3 531
3 REPLIES 3

I'd be tempted to suggest creating a sample that illustrates the puzzle.  For example a sample CSV files that can be loaded as a BQ table and then an example application that uses the paging that fails in your environment.  Ideally we want to look at the area of logic that us using/calling the APIs to retrieve subsequent pages and then see if anything obvious comes to light.

I tried it on any tables in my project, even newly created ones, and the result is the same. Let's assume we have a table with the following structure:

id (number)
name (string)

20 records.
And also, pseudocode for retrieving these records.


<?php
$bqClient = new BigQueryClient([
'projectId' => '***',
'keyFilePath' => '***',
]);

$rawSql = "SELECT name FROM ***.Test.test_table";

$pageToken = null;

do {

$queryConfig = $bqClient->query($rawSql);
$queryResults = $bqClient->runQuery($queryConfig, [
'useLegacySql' => false,
'maxResults' => 1,
'pageToken' => $pageToken,
]);

foreach ($queryResults->rows() as $row) {
echo $row['name'] . PHP_EOL;
}

$pageToken = $queryResults->info()['pageToken'] ?? null;
} while ($pageToken !== null);

In the first request, everything works as expected, I get a seemingly normal pageToken. However, upon making the second request, I immediately get an error. The only thing I've noticed during debugging is that in the first request, a job is created with a job id, and in the second request, a new job is created with a different job id, which is shown in the error (I can't compare this to the working method, so I can't confirm that this is not standard behavior). Also, when searching the Cloud logs for jobs, I can find the first request, but I can't locate the second one.

We're seeing the same issue, since the 9th Jan. We are using the node client library (@Google-cloud/bigquery). We have never seen the error before and haven't changed anything from our side. Updating from 5.10.0 to latest version 7.9.1 made no difference.