Repository navigation
Conversation
…nd unify write-path data conversion
There was a problem hiding this comment.
Code Review
This pull request introduces support for the BigQuery Storage Write API in the JDBC driver, specifically optimizing single-row bulk INSERT statements with positional placeholders. It adds SQL parsing to identify eligible direct INSERT shapes, validates parameter compatibility, formats temporal and numeric types for the Write API, and manages the lifecycle of the stream writer asynchronously. Feedback on the changes suggests moving the ApiFutures.addCallback call inside the try block in BigQueryJdbcBulkInsertWriter to guarantee proper phaser deregistration and prevent potential hangs if callback registration fails.
| openRequestCount.register(); | ||
| ApiFuture<AppendRowsResponse> future; | ||
| try { | ||
| future = jsonStreamWriter.append(data, offset); | ||
| } catch (Throwable t) { | ||
| openRequestCount.arriveAndDeregister(); | ||
| throw t; | ||
| } | ||
| ApiFutures.addCallback( | ||
| future, new AppendCompleteCallback(this), MoreExecutors.directExecutor()); |
There was a problem hiding this comment.
Moving the ApiFutures.addCallback call inside the try block ensures that if any exception occurs during callback registration, the phaser is correctly deregistered in the catch block. This prevents a potential hang during cleanup where the main thread waits indefinitely for the leaked phaser party. Catching Throwable here is appropriate as it is at a Future boundary to ensure all failures are captured.
openRequestCount.register();
try {
ApiFuture<AppendRowsResponse> future = jsonStreamWriter.append(data, offset);
ApiFutures.addCallback(
future, new AppendCompleteCallback(this), MoreExecutors.directExecutor());
} catch (Throwable t) {
openRequestCount.arriveAndDeregister();
throw t;
}References
- Catching
Throwableinstead ofExceptionis acceptable at Future boundaries or during stream cleanup in asynchronous operations to ensure all failures are captured and propagated.
No description provided.