Repository navigation
fix(bigquery-jdbc): stop producer and release resources on ResultSet.close #14712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |||||||||||||||||||||||||||||||||||||
| import com.google.api.core.InternalApi; | ||||||||||||||||||||||||||||||||||||||
| import com.google.api.gax.paging.Page; | ||||||||||||||||||||||||||||||||||||||
| import com.google.api.gax.rpc.ApiException; | ||||||||||||||||||||||||||||||||||||||
| import com.google.api.gax.rpc.ServerStream; | ||||||||||||||||||||||||||||||||||||||
| import com.google.api.gax.rpc.StatusCode; | ||||||||||||||||||||||||||||||||||||||
| import com.google.cloud.Tuple; | ||||||||||||||||||||||||||||||||||||||
| import com.google.cloud.bigquery.BigQuery; | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -62,7 +63,6 @@ | |||||||||||||||||||||||||||||||||||||
| import com.google.cloud.bigquery.storage.v1.ReadSession; | ||||||||||||||||||||||||||||||||||||||
| import com.google.cloud.bigquery.storage.v1.ReadSession.TableReadOptions; | ||||||||||||||||||||||||||||||||||||||
| import com.google.common.annotations.VisibleForTesting; | ||||||||||||||||||||||||||||||||||||||
| import com.google.common.util.concurrent.Uninterruptibles; | ||||||||||||||||||||||||||||||||||||||
| import io.grpc.Status; | ||||||||||||||||||||||||||||||||||||||
| import io.grpc.StatusRuntimeException; | ||||||||||||||||||||||||||||||||||||||
| import io.opentelemetry.api.common.AttributeKey; | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -104,6 +104,7 @@ public class BigQueryStatement extends BigQueryNoOpsStatement { | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| private final BigQueryJdbcCustomLogger LOG = new BigQueryJdbcCustomLogger(this.toString()); | ||||||||||||||||||||||||||||||||||||||
| public static final int DEFAULT_BUFFER_SIZE = BigQuerySettings.DEFAULT_NUM_BUFFERED_ROWS * 2; | ||||||||||||||||||||||||||||||||||||||
| static final int DEFAULT_ARROW_BUFFER_SIZE = 32; | ||||||||||||||||||||||||||||||||||||||
| private static final String DEFAULT_DATASET_NAME = "_google_jdbc"; | ||||||||||||||||||||||||||||||||||||||
| private static final String DEFAULT_TABLE_NAME = "temp_table_"; | ||||||||||||||||||||||||||||||||||||||
| private static final String JDBC_JOB_PREFIX = "google-jdbc-"; | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -534,6 +535,8 @@ private void closeStatementResources() throws SQLException { | |||||||||||||||||||||||||||||||||||||
| tmp.close(); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| this.batchQueries.clear(); | ||||||||||||||||||||||||||||||||||||||
| this.arrowBatchWrapperBlockingQueue = null; | ||||||||||||||||||||||||||||||||||||||
| this.bigQueryFieldValueListWrapperBlockingQueue = null; | ||||||||||||||||||||||||||||||||||||||
| this.currentUpdateCount = -1; | ||||||||||||||||||||||||||||||||||||||
| this.currentJobIdIndex = -1; | ||||||||||||||||||||||||||||||||||||||
| if (this.connection != null) { | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -931,7 +934,7 @@ ResultSet processArrowResultSet(TableResult results, Job job) throws SQLExceptio | |||||||||||||||||||||||||||||||||||||
| .setMaxStreamCount(1); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ReadSession readSession = getReadSession(builder.build()); | ||||||||||||||||||||||||||||||||||||||
| this.arrowBatchWrapperBlockingQueue = new LinkedBlockingDeque<>(getBufferSize()); | ||||||||||||||||||||||||||||||||||||||
| this.arrowBatchWrapperBlockingQueue = new LinkedBlockingDeque<>(getArrowBufferSize()); | ||||||||||||||||||||||||||||||||||||||
| // deserialize and populate the buffer async, so that the client isn't blocked | ||||||||||||||||||||||||||||||||||||||
| populateBufferWorker = | ||||||||||||||||||||||||||||||||||||||
| populateArrowBufferedQueue( | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -1004,6 +1007,8 @@ Future<?> populateArrowBufferedQueue( | |||||||||||||||||||||||||||||||||||||
| String streamName = readSession.getStreams(0).getName(); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| while (true) { | ||||||||||||||||||||||||||||||||||||||
| ServerStream<ReadRowsResponse> stream = null; | ||||||||||||||||||||||||||||||||||||||
| boolean streamCompleted = false; | ||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||
| ReadRowsRequest readRowsRequest = | ||||||||||||||||||||||||||||||||||||||
| ReadRowsRequest.newBuilder() | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -1013,19 +1018,23 @@ Future<?> populateArrowBufferedQueue( | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // Process each block of rows as they arrive and decode using our simple row | ||||||||||||||||||||||||||||||||||||||
| // reader. | ||||||||||||||||||||||||||||||||||||||
| com.google.api.gax.rpc.ServerStream<ReadRowsResponse> stream = | ||||||||||||||||||||||||||||||||||||||
| bqReadClient.readRowsCallable().call(readRowsRequest); | ||||||||||||||||||||||||||||||||||||||
| stream = bqReadClient.readRowsCallable().call(readRowsRequest); | ||||||||||||||||||||||||||||||||||||||
| for (ReadRowsResponse response : stream) { | ||||||||||||||||||||||||||||||||||||||
| if (Thread.currentThread().isInterrupted() || executor.isShutdown()) { | ||||||||||||||||||||||||||||||||||||||
| arrowBatchWrapperBlockingQueue.clear(); | ||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
1023
to
1026
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the newly introduced
Suggested change
References
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ArrowRecordBatch currentBatch = response.getArrowRecordBatch(); | ||||||||||||||||||||||||||||||||||||||
| Uninterruptibles.putUninterruptibly( | ||||||||||||||||||||||||||||||||||||||
| arrowBatchWrapperBlockingQueue, | ||||||||||||||||||||||||||||||||||||||
| arrowBatchWrapperBlockingQueue.put( | ||||||||||||||||||||||||||||||||||||||
| BigQueryArrowBatchWrapper.of(currentBatch)); | ||||||||||||||||||||||||||||||||||||||
| rowsRead += response.getRowCount(); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| if (!Thread.currentThread().isInterrupted() && !executor.isShutdown()) { | ||||||||||||||||||||||||||||||||||||||
| streamCompleted = true; | ||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||
| arrowBatchWrapperBlockingQueue.clear(); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1033
to
+1037
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
Suggested change
References
|
||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||
| } catch (ApiException e) { | ||||||||||||||||||||||||||||||||||||||
| if (e.getStatusCode().getCode() == StatusCode.Code.NOT_FOUND) { | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -1048,29 +1057,35 @@ Future<?> populateArrowBufferedQueue( | |||||||||||||||||||||||||||||||||||||
| "Connection interrupted during arrow stream read, retrying. attempt: %d", | ||||||||||||||||||||||||||||||||||||||
| retryCount); | ||||||||||||||||||||||||||||||||||||||
| Thread.sleep(RETRY_DELAY_MS); | ||||||||||||||||||||||||||||||||||||||
| } finally { | ||||||||||||||||||||||||||||||||||||||
| if (stream != null && !streamCompleted) { | ||||||||||||||||||||||||||||||||||||||
| stream.cancel(); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| } catch (InterruptedException e) { | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().interrupt(); | ||||||||||||||||||||||||||||||||||||||
| arrowBatchWrapperBlockingQueue.clear(); | ||||||||||||||||||||||||||||||||||||||
| LOG.log( | ||||||||||||||||||||||||||||||||||||||
| Level.WARNING, | ||||||||||||||||||||||||||||||||||||||
| "\n" | ||||||||||||||||||||||||||||||||||||||
| + Thread.currentThread().getName() | ||||||||||||||||||||||||||||||||||||||
| + " Interrupted @ arrowStreamProcessor", | ||||||||||||||||||||||||||||||||||||||
| e); | ||||||||||||||||||||||||||||||||||||||
| enqueueError(arrowBatchWrapperBlockingQueue, e); | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().interrupt(); | ||||||||||||||||||||||||||||||||||||||
| } catch (Exception e) { | ||||||||||||||||||||||||||||||||||||||
| if (e.getCause() instanceof InterruptedException | ||||||||||||||||||||||||||||||||||||||
| || Thread.currentThread().isInterrupted()) { | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().interrupt(); | ||||||||||||||||||||||||||||||||||||||
| arrowBatchWrapperBlockingQueue.clear(); | ||||||||||||||||||||||||||||||||||||||
| LOG.log( | ||||||||||||||||||||||||||||||||||||||
| Level.WARNING, | ||||||||||||||||||||||||||||||||||||||
| "\n" | ||||||||||||||||||||||||||||||||||||||
| + Thread.currentThread().getName() | ||||||||||||||||||||||||||||||||||||||
| + " Interrupted @ arrowStreamProcessor", | ||||||||||||||||||||||||||||||||||||||
| e); | ||||||||||||||||||||||||||||||||||||||
| enqueueError(arrowBatchWrapperBlockingQueue, e); | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().interrupt(); | ||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||
| LOG.log( | ||||||||||||||||||||||||||||||||||||||
| Level.WARNING, | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -1337,8 +1352,7 @@ Future<?> runNextPageTaskAsync( | |||||||||||||||||||||||||||||||||||||
| currentPageToken = currentResults.getNextPageToken(); | ||||||||||||||||||||||||||||||||||||||
| // this will be parsed asynchronously without blocking the current | ||||||||||||||||||||||||||||||||||||||
| // thread | ||||||||||||||||||||||||||||||||||||||
| Uninterruptibles.putUninterruptibly( | ||||||||||||||||||||||||||||||||||||||
| rpcResponseQueue, Tuple.of(currentResults, true)); | ||||||||||||||||||||||||||||||||||||||
| rpcResponseQueue.put(Tuple.of(currentResults, true)); | ||||||||||||||||||||||||||||||||||||||
| LOG.fine( | ||||||||||||||||||||||||||||||||||||||
| "Fetched %d results from the server in %d ms.", | ||||||||||||||||||||||||||||||||||||||
| querySettings.getMaxResultPerPage(), | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -1347,14 +1361,30 @@ Future<?> runNextPageTaskAsync( | |||||||||||||||||||||||||||||||||||||
| paginationSpan.end(); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } catch (InterruptedException ex) { | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().interrupt(); | ||||||||||||||||||||||||||||||||||||||
| LOG.warning( | ||||||||||||||||||||||||||||||||||||||
| "%s Interrupted @ runNextPageTaskAsync: %s", | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().getName(), ex.getMessage()); | ||||||||||||||||||||||||||||||||||||||
| } catch (Exception ex) { | ||||||||||||||||||||||||||||||||||||||
| Uninterruptibles.putUninterruptibly( | ||||||||||||||||||||||||||||||||||||||
| bigQueryFieldValueListWrapperBlockingQueue, | ||||||||||||||||||||||||||||||||||||||
| BigQueryFieldValueListWrapper.ofError(ex)); | ||||||||||||||||||||||||||||||||||||||
| if (ex.getCause() instanceof InterruptedException | ||||||||||||||||||||||||||||||||||||||
| || Thread.currentThread().isInterrupted()) { | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().interrupt(); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| enqueueBufferError(bigQueryFieldValueListWrapperBlockingQueue, ex); | ||||||||||||||||||||||||||||||||||||||
| } finally { | ||||||||||||||||||||||||||||||||||||||
| // this will stop the parseDataTask as well when the pagination | ||||||||||||||||||||||||||||||||||||||
| // completes | ||||||||||||||||||||||||||||||||||||||
| Uninterruptibles.putUninterruptibly(rpcResponseQueue, Tuple.of(null, false)); | ||||||||||||||||||||||||||||||||||||||
| Tuple<TableResult, Boolean> endOfRpcTuple = Tuple.of(null, false); | ||||||||||||||||||||||||||||||||||||||
| if (Thread.currentThread().isInterrupted() || executor.isShutdown()) { | ||||||||||||||||||||||||||||||||||||||
| rpcResponseQueue.offer(endOfRpcTuple); | ||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||
| rpcResponseQueue.put(endOfRpcTuple); | ||||||||||||||||||||||||||||||||||||||
| } catch (InterruptedException ie) { | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().interrupt(); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1379
to
+1387
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
Suggested change
References
|
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| // We cannot do queryTaskExecutor.shutdownNow() here as populate buffer method may | ||||||||||||||||||||||||||||||||||||||
| // not | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -1424,8 +1454,7 @@ Future<?> parseAndPopulateRpcDataAsync( | |||||||||||||||||||||||||||||||||||||
| // do not process further pages and shutdown (inner loop) | ||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| Uninterruptibles.putUninterruptibly( | ||||||||||||||||||||||||||||||||||||||
| bigQueryFieldValueListWrapperBlockingQueue, | ||||||||||||||||||||||||||||||||||||||
| bigQueryFieldValueListWrapperBlockingQueue.put( | ||||||||||||||||||||||||||||||||||||||
| BigQueryFieldValueListWrapper.of( | ||||||||||||||||||||||||||||||||||||||
| schema.getFields(), fieldValueList, isComplexColumn)); | ||||||||||||||||||||||||||||||||||||||
| results += 1; | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -1435,17 +1464,26 @@ Future<?> parseAndPopulateRpcDataAsync( | |||||||||||||||||||||||||||||||||||||
| results, (int) ((System.nanoTime() - startTime) / 1000000)); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| } catch (InterruptedException ex) { | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().interrupt(); | ||||||||||||||||||||||||||||||||||||||
| LOG.log( | ||||||||||||||||||||||||||||||||||||||
| Level.WARNING, | ||||||||||||||||||||||||||||||||||||||
| "\n" | ||||||||||||||||||||||||||||||||||||||
| + Thread.currentThread().getName() | ||||||||||||||||||||||||||||||||||||||
| + " Interrupted @ populateBufferAsync", | ||||||||||||||||||||||||||||||||||||||
| ex); | ||||||||||||||||||||||||||||||||||||||
| enqueueBufferError(bigQueryFieldValueListWrapperBlockingQueue, ex); | ||||||||||||||||||||||||||||||||||||||
| } catch (Exception ex) { | ||||||||||||||||||||||||||||||||||||||
| if (ex.getCause() instanceof InterruptedException | ||||||||||||||||||||||||||||||||||||||
| || Thread.currentThread().isInterrupted()) { | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().interrupt(); | ||||||||||||||||||||||||||||||||||||||
| LOG.log( | ||||||||||||||||||||||||||||||||||||||
| Level.WARNING, | ||||||||||||||||||||||||||||||||||||||
| "\n" | ||||||||||||||||||||||||||||||||||||||
| + Thread.currentThread().getName() | ||||||||||||||||||||||||||||||||||||||
| + " Interrupted @ populateBufferAsync", | ||||||||||||||||||||||||||||||||||||||
| ex); | ||||||||||||||||||||||||||||||||||||||
| enqueueBufferError(bigQueryFieldValueListWrapperBlockingQueue, ex); | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().interrupt(); | ||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||
| LOG.log( | ||||||||||||||||||||||||||||||||||||||
| Level.WARNING, | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -1512,6 +1550,10 @@ private int getBufferSize() { | |||||||||||||||||||||||||||||||||||||
| : Math.min(this.querySettings.getNumBufferedRows() * 2, 100000)); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| int getArrowBufferSize() { | ||||||||||||||||||||||||||||||||||||||
| return DEFAULT_ARROW_BUFFER_SIZE; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /** Returns the destinationTable from jobId by calling `jobs.get` API */ | ||||||||||||||||||||||||||||||||||||||
| TableId getDestinationTable(JobId jobId) { | ||||||||||||||||||||||||||||||||||||||
| Job job = this.bigQuery.getJob(jobId); | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -1928,20 +1970,68 @@ enum QueryDialectType { | |||||||||||||||||||||||||||||||||||||
| BIG_QUERY | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| private boolean isWorkerShuttingDown() { | ||||||||||||||||||||||||||||||||||||||
| if (Thread.currentThread().isInterrupted()) { | ||||||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| BigQueryConnection conn = this.connection; | ||||||||||||||||||||||||||||||||||||||
| if (conn == null) { | ||||||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| ExecutorService executor = conn.getExecutorService(); | ||||||||||||||||||||||||||||||||||||||
| return executor != null && executor.isShutdown(); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| private void enqueueError(BlockingQueue<BigQueryArrowBatchWrapper> queue, Exception e) { | ||||||||||||||||||||||||||||||||||||||
| Uninterruptibles.putUninterruptibly(queue, BigQueryArrowBatchWrapper.ofError(e)); | ||||||||||||||||||||||||||||||||||||||
| BigQueryArrowBatchWrapper errorWrapper = BigQueryArrowBatchWrapper.ofError(e); | ||||||||||||||||||||||||||||||||||||||
| if (isWorkerShuttingDown()) { | ||||||||||||||||||||||||||||||||||||||
| queue.offer(errorWrapper); | ||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||
| queue.put(errorWrapper); | ||||||||||||||||||||||||||||||||||||||
| } catch (InterruptedException ie) { | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().interrupt(); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| private void enqueueEndOfStream(BlockingQueue<BigQueryArrowBatchWrapper> queue) { | ||||||||||||||||||||||||||||||||||||||
| Uninterruptibles.putUninterruptibly(queue, BigQueryArrowBatchWrapper.of(null, true)); | ||||||||||||||||||||||||||||||||||||||
| BigQueryArrowBatchWrapper endWrapper = BigQueryArrowBatchWrapper.of(null, true); | ||||||||||||||||||||||||||||||||||||||
| if (isWorkerShuttingDown()) { | ||||||||||||||||||||||||||||||||||||||
| queue.offer(endWrapper); | ||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||
| queue.put(endWrapper); | ||||||||||||||||||||||||||||||||||||||
| } catch (InterruptedException ie) { | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().interrupt(); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| private void enqueueBufferError(BlockingQueue<BigQueryFieldValueListWrapper> queue, Exception e) { | ||||||||||||||||||||||||||||||||||||||
| Uninterruptibles.putUninterruptibly(queue, BigQueryFieldValueListWrapper.ofError(e)); | ||||||||||||||||||||||||||||||||||||||
| BigQueryFieldValueListWrapper errorWrapper = BigQueryFieldValueListWrapper.ofError(e); | ||||||||||||||||||||||||||||||||||||||
| if (isWorkerShuttingDown()) { | ||||||||||||||||||||||||||||||||||||||
| queue.offer(errorWrapper); | ||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||
| queue.put(errorWrapper); | ||||||||||||||||||||||||||||||||||||||
| } catch (InterruptedException ie) { | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().interrupt(); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| private void enqueueBufferEndOfStream(BlockingQueue<BigQueryFieldValueListWrapper> queue) { | ||||||||||||||||||||||||||||||||||||||
| Uninterruptibles.putUninterruptibly(queue, BigQueryFieldValueListWrapper.ofEndOfStream(null)); | ||||||||||||||||||||||||||||||||||||||
| BigQueryFieldValueListWrapper endWrapper = BigQueryFieldValueListWrapper.ofEndOfStream(null); | ||||||||||||||||||||||||||||||||||||||
| if (isWorkerShuttingDown()) { | ||||||||||||||||||||||||||||||||||||||
| queue.offer(endWrapper); | ||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||
| queue.put(endWrapper); | ||||||||||||||||||||||||||||||||||||||
| } catch (InterruptedException ie) { | ||||||||||||||||||||||||||||||||||||||
| Thread.currentThread().interrupt(); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| QueryStatistics describePositionalParameterQuery(String query) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap the custom resource cleanup in a
try-finallyblock to guarantee thatsuper.close()is always executed, even if an exception is thrown during the cleanup of these resources.References