googleapis / googleapis/google-cloud-java

[java-bigquery] BigQuery: Multiple queries with a single Connection

未关闭
#12,156 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
api: bigquery priority: p3
主要语言
Java
星标
2.1k
派生
1.2k
平均合并
1 天 23 小时
30 天内合并 PR
157

描述

I'm trying to run multiple queries using the same instance of Connection, but it fails with `RejectedExecutionException`.

#### Environment details

1. API: BigQuery
2. OS type and version: Linux Ubuntu 22.04
3. Java version: 17
4. version(s): google-cloud-bigquery:2.39.1

#### Steps to reproduce

1. Run the code example

#### Code example

```kotlin
import com.google.cloud.bigquery.BigQueryOptions

fun main() {
val count = 3
println("Start")
val connection = BigQueryOptions.getDefaultInstance().service.createConnection()

repeat(count) {
val result = connection.executeSelect("SELECT RAND() as random_value$it")
val resultSet = result.resultSet
while (resultSet.next()) {
println(resultSet.getDouble(0))
}
println("Result for $it: $result")
}
}
```

#### Output and stack trace
```
Start
Jun 04, 2024 4:28:30 PM com.google.cloud.bigquery.ConnectionImpl getExecuteSelectResponse
INFO:
Using Fast Query Path
0.4408623091866403
Result for 0: com.google.cloud.bigquery.BigQueryResultImpl@24ba9639
Jun 04, 2024 4:28:32 PM com.google.cloud.bigquery.ConnectionImpl getExecuteSelectResponse
INFO:
Using Fast Query Path
Exception in thread "main" java.util.concurrent.RejectedExecutionException: Task com.google.cloud.bigquery.ConnectionImpl$$Lambda$100/0x0000000801191b18@8c3619e rejected from java.util.concurrent.ThreadPoolExecutor@4331d187[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 3]
at java.base/java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2065)
at java.base/java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:833)
at java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1365)
at com.google.cloud.bigquery.ConnectionImpl.runNextPageTaskAsync(ConnectionImpl.java:628)
at com.google.cloud.bigquery.ConnectionImpl.processQueryResponseResults(ConnectionImpl.java:579)
at com.google.cloud.bigquery.ConnectionImpl.queryRpc(ConnectionImpl.java:474)
at com.google.cloud.bigquery.ConnectionImpl.getExecuteSelectResponse(ConnectionImpl.java:239)
at com.google.cloud.bigquery.ConnectionImpl.executeSelect(ConnectionImpl.java:198)
at org.example.MainKt.main(Main.kt:12)
at org.example.MainKt.main(Main.kt)
```

#### External references such as API reference guides

- https://cloud.google.com/blog/topics/developers-practitioners/introducing-executeselect-client-library-method-and-how-use-it/

Does this mean that for each query a new connection needs to be created?

贡献指南

打开贡献指南

调研方向

首先针对 google-cloud-bigquery 2.39.1 运行 Kotlin 示例,并通过 queryRpc、processQueryResponseResults 和 runNextPageTaskAsync 跟踪 ConnectionImpl.executeSelect。确认在一个 Connection 上重复调用 executeSelect 不会拒绝任务,并使用提供的堆栈跟踪和输出验证该行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
java, kotlin
领域
databases
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。