Skip to content

Commit

Permalink
fix: Socket-timeout at bigquery.it.ITNightlyBigQueryTest: testForTabl…
Browse files Browse the repository at this point in the history
…eNotFound (#2260)

* Added query logging in testForTableNotFound

* Defaulted timeoutMs to 10s & Added additional logging
  • Loading branch information
prash-mi committed Sep 2, 2022
1 parent 5e30a04 commit a9b5fb2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,13 @@ public BigQueryResult executeSelect(String sql) throws BigQuerySQLException {
try {
// use jobs.query if all the properties of connectionSettings are supported
if (isFastQuerySupported()) {
logger.log(Level.INFO, "\n Using Fast Query Path");
String projectId = bigQueryOptions.getProjectId();
QueryRequest queryRequest = createQueryRequest(connectionSettings, sql, null, null);
return queryRpc(projectId, queryRequest, sql, false);
}
// use jobs.insert otherwise
logger.log(Level.INFO, "\n Not Using Fast Query Path, using jobs.insert");
com.google.api.services.bigquery.model.Job queryJob =
createQueryJob(sql, connectionSettings, null, null);
JobId jobId = JobId.fromPb(queryJob.getJobReference());
Expand Down Expand Up @@ -233,12 +235,14 @@ public BigQueryResult executeSelect(
try {
// use jobs.query if possible
if (isFastQuerySupported()) {
logger.log(Level.INFO, "\n Using Fast Query Path");
final String projectId = bigQueryOptions.getProjectId();
final QueryRequest queryRequest =
createQueryRequest(connectionSettings, sql, parameters, labelMap);
return queryRpc(projectId, queryRequest, sql, parameters != null);
}
// use jobs.insert otherwise
logger.log(Level.INFO, "\n Not Using Fast Query Path, using jobs.insert");
com.google.api.services.bigquery.model.Job queryJob =
createQueryJob(sql, connectionSettings, parameters, labelMap);
JobId jobId = JobId.fromPb(queryJob.getJobReference());
Expand Down Expand Up @@ -1003,8 +1007,7 @@ GetQueryResultsResponse getQueryResultsFirstPage(JobId jobId) {
// progress (a job won't get stuck in pending forever).
boolean jobComplete = false;
GetQueryResultsResponse results = null;
long timeoutMs =
60000; // defaulting to 60seconds. TODO(prashant): It should be made user configurable
long timeoutMs = 10000; // defaulting to 10seconds.

while (!jobComplete) {
try {
Expand Down Expand Up @@ -1032,6 +1035,7 @@ GetQueryResultsResponse getQueryResultsFirstPage(JobId jobId) {
throw new BigQueryException(bigQueryErrors);
}
} catch (BigQueryRetryHelper.BigQueryRetryHelperException e) {
logger.log(Level.WARNING, "\n Error occurred while calling getQueryResultsWithRowLimit", e);
throw BigQueryException.translateAndThrow(e);
}
jobComplete = results.getJobComplete();
Expand Down Expand Up @@ -1285,8 +1289,10 @@ com.google.api.services.bigquery.model.Job createQueryJob(
bigQueryOptions.getClock(),
retryConfig);
} catch (BigQueryRetryHelper.BigQueryRetryHelperException e) {
logger.log(Level.WARNING, "\n Error occurred while calling createJobForQuery", e);
throw BigQueryException.translateAndThrow(e);
}
logger.log(Level.INFO, "\n Query job created");
return queryJob;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ public void testForTableNotFound() throws SQLException {
String query =
String.format(
"SELECT * FROM `bigquery-samples.wikipedia_benchmark.Wiki10B` LIMIT %s", recordCnt);

logger.log(Level.INFO, "Query used: {0}", query);
String dataSet = RemoteBigQueryHelper.generateDatasetName();
String table = "TAB_" + UUID.randomUUID();
createDataset(dataSet);
Expand Down

0 comments on commit a9b5fb2

Please sign in to comment.