Commit 341e51a
authored
feat(bigquery-jdbc): migrate statement execution thread tracking to connection-scoped executor (#13454)
b/519201498
This PR migrates the asynchronous processing tasks of the JDBC driver
away from the legacy static global thread pool (`queryTaskExecutor`) to
the modern, connection-scoped `ExecutorService`
(`connection.getExecutorService()`).
### Key Changes
1. **Statement & Stream Refactoring**:
- Removed the static `queryTaskExecutor` from `BigQueryStatement`.
- Updated `populateArrowBufferedQueue` to submit streaming and buffering
tasks to the connection-scoped executor pool.
- Converted background thread tracking in `BigQueryStatement` and
`BigQueryArrowResultSet` from raw `Thread` references to modern,
cancelable `Future<?>` task handles.
2. **Isolated Backward-Compatibility Wrapper**:
- Isolated the legacy raw thread wrapping to `BigQueryDatabaseMetaData`
(which is still pending future refactoring to the executor pool).
- Implemented a temporary `wrapThread(Thread)` helper method inside
`BigQueryDatabaseMetaData` to wrap raw background threads into
cancelable `Future<?>` adapters on the fly before passing them to the
result set.
- Hardened the anonymous `Future` wrapper state tracking to strictly
satisfy the `Future` specification contract (handling `cancel`,
`isCancelled`, and `isDone` correctly using a volatile boolean flag to
prevent duplicate cancellation triggers).1 parent 06d0cde commit 341e51a
16 files changed
Lines changed: 270 additions & 181 deletions
File tree
- java-bigquery-jdbc/src
- main/java/com/google/cloud/bigquery/jdbc
- test/java/com/google/cloud/bigquery/jdbc
Lines changed: 13 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | | - | |
84 | | - | |
| 84 | + | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
96 | | - | |
| 97 | + | |
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
| |||
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
108 | | - | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
130 | | - | |
| 131 | + | |
131 | 132 | | |
132 | 133 | | |
133 | | - | |
| 134 | + | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| |||
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
142 | | - | |
| 143 | + | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
| |||
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
156 | | - | |
| 157 | + | |
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
| |||
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
168 | | - | |
| 169 | + | |
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
| |||
484 | 485 | | |
485 | 486 | | |
486 | 487 | | |
487 | | - | |
488 | | - | |
489 | | - | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
490 | 491 | | |
491 | 492 | | |
492 | 493 | | |
| |||
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
350 | | - | |
351 | | - | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
352 | 359 | | |
353 | 360 | | |
354 | 361 | | |
| |||
Lines changed: 12 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
945 | 945 | | |
946 | 946 | | |
947 | 947 | | |
948 | | - | |
| 948 | + | |
949 | 949 | | |
950 | 950 | | |
951 | 951 | | |
| |||
1207 | 1207 | | |
1208 | 1208 | | |
1209 | 1209 | | |
1210 | | - | |
| 1210 | + | |
1211 | 1211 | | |
1212 | 1212 | | |
1213 | 1213 | | |
| |||
1878 | 1878 | | |
1879 | 1879 | | |
1880 | 1880 | | |
1881 | | - | |
| 1881 | + | |
1882 | 1882 | | |
1883 | 1883 | | |
1884 | 1884 | | |
| |||
2018 | 2018 | | |
2019 | 2019 | | |
2020 | 2020 | | |
2021 | | - | |
| 2021 | + | |
| 2022 | + | |
2022 | 2023 | | |
2023 | 2024 | | |
2024 | 2025 | | |
| |||
2050 | 2051 | | |
2051 | 2052 | | |
2052 | 2053 | | |
2053 | | - | |
| 2054 | + | |
2054 | 2055 | | |
2055 | 2056 | | |
2056 | 2057 | | |
| |||
2204 | 2205 | | |
2205 | 2206 | | |
2206 | 2207 | | |
2207 | | - | |
| 2208 | + | |
2208 | 2209 | | |
2209 | 2210 | | |
2210 | 2211 | | |
| |||
2719 | 2720 | | |
2720 | 2721 | | |
2721 | 2722 | | |
2722 | | - | |
| 2723 | + | |
2723 | 2724 | | |
2724 | 2725 | | |
2725 | 2726 | | |
| |||
3714 | 3715 | | |
3715 | 3716 | | |
3716 | 3717 | | |
3717 | | - | |
| 3718 | + | |
3718 | 3719 | | |
3719 | 3720 | | |
3720 | 3721 | | |
| |||
3833 | 3834 | | |
3834 | 3835 | | |
3835 | 3836 | | |
3836 | | - | |
| 3837 | + | |
3837 | 3838 | | |
3838 | 3839 | | |
3839 | 3840 | | |
| |||
4008 | 4009 | | |
4009 | 4010 | | |
4010 | 4011 | | |
4011 | | - | |
| 4012 | + | |
4012 | 4013 | | |
4013 | 4014 | | |
4014 | 4015 | | |
| |||
4262 | 4263 | | |
4263 | 4264 | | |
4264 | 4265 | | |
4265 | | - | |
| 4266 | + | |
4266 | 4267 | | |
4267 | 4268 | | |
4268 | 4269 | | |
| |||
Lines changed: 22 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | | - | |
| 72 | + | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 77 | + | |
| 78 | + | |
81 | 79 | | |
82 | 80 | | |
83 | 81 | | |
84 | 82 | | |
85 | 83 | | |
86 | 84 | | |
87 | | - | |
| 85 | + | |
88 | 86 | | |
| 87 | + | |
89 | 88 | | |
90 | 89 | | |
91 | 90 | | |
92 | 91 | | |
93 | 92 | | |
94 | | - | |
| 93 | + | |
95 | 94 | | |
96 | 95 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 96 | + | |
| 97 | + | |
103 | 98 | | |
104 | 99 | | |
105 | 100 | | |
106 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
107 | 105 | | |
108 | | - | |
| 106 | + | |
109 | 107 | | |
| 108 | + | |
110 | 109 | | |
111 | 110 | | |
112 | 111 | | |
| |||
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
128 | 129 | | |
129 | 130 | | |
| 131 | + | |
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
| 139 | + | |
137 | 140 | | |
138 | 141 | | |
139 | 142 | | |
| |||
149 | 152 | | |
150 | 153 | | |
151 | 154 | | |
152 | | - | |
153 | | - | |
| 155 | + | |
| 156 | + | |
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
0 commit comments