Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public class BigQueryConnection extends BigQueryNoOpsConnection {
Boolean reqGoogleDriveScope;
private final Properties clientInfo = new Properties();
private boolean isReadOnlyTokenUsed = false;
private final ExecutorService metadataExecutor;
private ExecutorService metadataExecutor;
Comment thread
keshavdandeva marked this conversation as resolved.
Comment thread
keshavdandeva marked this conversation as resolved.
Comment thread
keshavdandeva marked this conversation as resolved.
private final ExecutorService queryExecutor;

BigQueryConnection(String url) throws IOException {
Expand Down Expand Up @@ -362,11 +362,6 @@ public class BigQueryConnection extends BigQueryNoOpsConnection {

this.headerProvider = createHeaderProvider();
this.bigQuery = getBigQueryConnection();
// Fixed thread pool queues tasks to limit concurrent metadata calls and prevent API
// throttling.
this.metadataExecutor =
BigQueryJdbcMdc.newFixedThreadPool(
String.format("BQ-Metadata-%s", connectionId), metadataFetchThreadCount);
// Cached pool executes queries immediately without queueing and reclaims all idle threads
// when inactive, minimizing resources.
this.queryExecutor =
Expand Down Expand Up @@ -954,7 +949,7 @@ public void setHoldability(int holdability) throws SQLException {
* @see Connection#close()
*/
@Override
public void close() throws SQLException {
public synchronized void close() throws SQLException {
if (isClosed()) {
return;
}
Expand Down Expand Up @@ -1067,7 +1062,14 @@ ExecutorService getExecutorService() {
return this.queryExecutor;
}

ExecutorService getMetadataExecutor() {
synchronized ExecutorService getMetadataExecutor() {
Comment thread
keshavdandeva marked this conversation as resolved.
if (this.metadataExecutor != null) {
return this.metadataExecutor;
}
checkClosed();
this.metadataExecutor =
BigQueryJdbcMdc.newFixedThreadPool(
String.format("BQ-Metadata-%s", connectionId), metadataFetchThreadCount);
return this.metadataExecutor;
}

Expand Down
Loading
Loading