From baf6d23fa87534d036d5dffadf21d5c9d1270203 Mon Sep 17 00:00:00 2001 From: Amogh Bharadwaj Date: Mon, 22 Jan 2024 18:49:03 +0530 Subject: [PATCH] Nexus bq: refactor run tracked (#1114) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We close the tracker after getting the result set but if we error while obtaining the result set, the token wouldn't get closed. This PR fixes that. --------- Co-authored-by: Philip Dubé --- nexus/peer-bigquery/src/lib.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nexus/peer-bigquery/src/lib.rs b/nexus/peer-bigquery/src/lib.rs index e0f9fa99f3..880219661c 100644 --- a/nexus/peer-bigquery/src/lib.rs +++ b/nexus/peer-bigquery/src/lib.rs @@ -82,18 +82,17 @@ impl BigQueryQueryExecutor { .client .job() .query(&self.project_id, query_req) - .await - .map_err(|err| { - tracing::error!("error running query: {}", err); - PgWireError::ApiError(err.into()) - })?; + .await; token.end().await.map_err(|err| { tracing::error!("error closing tracking token: {}", err); PgWireError::ApiError(err.into()) })?; - Ok(result_set) + result_set.map_err(|err| { + tracing::error!("error running query: {}", err); + PgWireError::ApiError(err.into()) + }) } }