Closed dschott68 closed 3 years ago
Have you tried using BigQueryClient::startQuery()
and polling the job status manually?
$job = $bigquery->startQuery();
// cache this in case you need to re-create the job object
// i.e. $bigquery->job($jobId);
$jobId = $job->id();
$results = $job->queryResults();
do {
$results->reload();
$complete = $results->isComplete();
if (!$complete) {
sleep(10);
}
} while (!$complete);
// Use job results.
The main advantage here would be that you could get more insight into what the problem may be, and you could cache the Job ID so if you needed to restart the script you could gain a job reference.
We switched to startQuery with ExponentialBackoff per https://github.com/GoogleCloudPlatform/php-docs-samples/blob/master/bigquery/api/src/run_query_as_job.php a few days ago and it never freezes up anymore. We will use that long term. Just super interested into why runQuery logic was freezing up on a few random calls. The implementation looks straightforward and we had both timeoutMs and maxRetries set.
I've opened https://github.com/googleapis/google-cloud-php/pull/3626 to add a note about preferring startQuery
for more rigorous queries. I'm going to close this out, but if you're running into issues here as well we can re-open to look deeper. Providing some sample data for us to reproduce would be greatly appreciated.
Issue summary: runQuery freezes never returning results Affected timeframe: 2020-08-14 06:04:09 to 2020-08-14 06:10:03 Steps to reproduce: Execute a MERGE command using PHP API library BigQueryClient->runQuery. What is the business impact you are facing?:
This type of frozen runQuery command happens about 5-10 times per day out of several hundred MERGE statements per day.
Note we call with the following options set: 'timeoutMs' => 600000, 'maxRetries' => 6
Here is a job that successfully completed in 6 minutes, yet that runQuery call never returned so code is stuck.