-
Notifications
You must be signed in to change notification settings - Fork 1
perf: Native Flight SQL prepared statements, statement caching, and transport tuning (v0.7.0) #50
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4cff1f6
perf: Native Flight SQL prepared statements, statement caching, and t…
lukekim 237b5e3
Merge branch 'trunk' into perf/flight-sql-prepared-statements
lukekim c79a6fd
fix: address CodeQL review comments and add HikariCP interop verifica…
lukekim 4c66900
Merge branch 'perf/flight-sql-prepared-statements' of github.com:spic…
lukekim 43b2d63
fix: address Copilot review — guard empty-endpoint FlightInfo, docume…
lukekim 884caa1
fix: retire channels gracefully on reset() instead of closing them in…
lukekim 26ab9e2
refactor: make FlightInfoReader constructor catch clause explicit
lukekim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Spice Java SDK v0.7.0 | ||
|
|
||
| ## Highlights | ||
|
|
||
| This release is a **performance overhaul**. Parameterized queries move off ADBC onto native Arrow Flight SQL prepared statements running on the same tuned connection as regular queries, prepared statements are cached and reused, retries use real exponential backoff, and the Netty/gRPC dependency stack is aligned onto supported versions. | ||
|
|
||
| ## What's New | ||
|
|
||
| ### ⚡ Native Flight SQL Prepared Statements (ADBC removed) | ||
|
|
||
| `queryWithParams` is now implemented directly on Arrow Flight SQL prepared statements instead of the ADBC driver. This is a pure win with no API change — the method still returns an `ArrowReader`: | ||
|
|
||
| - **One connection instead of two.** Parameterized queries previously ran on a separate ADBC-managed gRPC channel that had none of the SDK's transport tuning. They now share the primary channels, inheriting DNS re-resolution (`dns:///`), HTTP/2 keep-alive, and — new in this release for parameterized queries — **mTLS/custom CA support**. | ||
| - **Prepared statement caching.** Statements are cached per SQL string and reused across executions, removing the `CreatePreparedStatement` and `ClosePreparedStatement` round trips from every repeated query (5 → 3 round trips per call). Configure with `withPreparedStatementCacheSize(n)` (default 64, `0` disables). | ||
| - **Transparent recovery.** If the server no longer recognizes a cached statement handle (e.g. after a server restart), the SDK re-prepares and retries automatically. | ||
| - **Multi-endpoint results.** The `ArrowReader` consumes every endpoint of a partitioned result. | ||
| - Two dependencies removed (`adbc-driver-flight-sql`, `adbc-core`). | ||
|
|
||
| ### 🚀 Performance Tuning Options | ||
|
|
||
| ```java | ||
| SpiceClient client = SpiceClient.builder() | ||
| .withChannelCount(4) // round-robin gRPC connection pool | ||
| .withQueryTimeout(Duration.ofSeconds(30)) // deadline for query planning RPCs | ||
| .withPreparedStatementCacheSize(128) // prepared statement reuse | ||
| .build(); | ||
| ``` | ||
|
|
||
| - **`withChannelCount(n)`** — opens `n` gRPC connections and distributes queries round-robin, lifting the single-connection ceiling (server `MAX_CONCURRENT_STREAMS`, single-TCP throughput) for highly concurrent workloads. Default 1. | ||
| - **`withQueryTimeout(d)`** — bounds query planning, statement preparation, and parameter binding RPCs. Result streaming is intentionally not limited; dead connections during streaming are detected by keep-alive. Default: no timeout. | ||
| - **`withPreparedStatementCacheSize(n)`** — see above. | ||
|
|
||
| ### 🔁 Real Retry Backoff | ||
|
|
||
| Retries previously waited 1–2ms between attempts — useless against real outages. They now use exponential backoff with jitter (~250ms, 500ms, 1s, … capped at 10s), so the default 3 retries cover ~2s outages such as load-balancer failovers. | ||
|
|
||
| ### 🔐 Automatic Re-Authentication | ||
|
|
||
| If the server reports `UNAUTHENTICATED` (e.g. an expired handshake bearer token on a long-lived client), the SDK re-handshakes once and retries the query automatically. Previously this required a manual `reset()`. | ||
|
|
||
| ### 🧹 Smaller Fixes | ||
|
|
||
| - Fixed a race where `reset()` concurrent with `queryWithParams` could throw `NullPointerException`. | ||
| - Parameter bind roots are sized for their single row instead of Arrow's ~3970-slot default (~48KB saved per string parameter per query). | ||
| - `refreshDataset` now sets a 60s request timeout (previously it could hang forever) and the HTTP client is created lazily. | ||
| - The user agent string is computed once instead of per request; fixed the OS version reported on Windows. | ||
| - `query()` logs a warning if the server returns a multi-endpoint result (only the first endpoint is consumed by the `FlightStream` API; use `queryWithParams` to consume all). | ||
|
|
||
| ## Dependency Changes | ||
|
|
||
| | Dependency | v0.6.0 | v0.7.0 | | ||
| | ----------------------------------- | ------------- | ------------ | | ||
| | Apache Arrow ADBC Driver Flight SQL | 0.23.0 | **removed** | | ||
| | Apache Arrow ADBC Core | 0.23.0 | **removed** | | ||
| | netty-all | 4.2.12.Final | **removed** | | ||
| | Netty (via netty-bom) | 4.2.12.Final (forced) | 4.1.130.Final | | ||
| | gRPC (via grpc-bom) | 1.79.0 | 1.79.0 (pinned) | | ||
| | netty-transport-native-epoll | — | 4.1.130.Final (Linux runtime) | | ||
| | BouncyCastle (bcprov/bcpkix) | transitive | 1.80 (explicit) | | ||
|
|
||
| The `netty-all 4.2.12` pin forced every Netty module to the 4.2 line, which `grpc-netty 1.79` (built against Netty 4.1.130) does not support, and dragged unused codecs (HTTP/3, MQTT, SMTP, Redis, …) onto consumers' classpaths. The stack is now aligned on Netty 4.1.130.Final via `netty-bom`, with native epoll transports added for Linux. BouncyCastle (used for mTLS PEM parsing) is now an explicit dependency instead of riding on ADBC's transitives. | ||
|
|
||
| ### 🐝 HikariCP / JDBC Interop | ||
|
|
||
| `SpiceClient` is thread-safe and needs no external pool (use `withChannelCount`), but applications with JDBC infrastructure can pool connections to Spice with HikariCP via the Arrow Flight SQL JDBC driver. This combination — including authentication and prepared statements — is now verified by `HikariCpCompatTest`, and the README documents the recommended configuration. | ||
|
|
||
| ## Testing | ||
|
|
||
| - New in-process mock Flight SQL server (`TestFlightSqlServer`) with per-RPC counters and failure injection — the full query, prepared-statement, retry, timeout, re-auth, and multi-endpoint behavior is now covered without an external runtime. | ||
| - New test suites: `LocalFlightServerTest`, `StatementCacheTest`, `ResilienceTest`, `FlightInfoReaderTest`, `ParamRootTest`, `RefreshHttpTest`, `HikariCpCompatTest`. | ||
| - New `PerfBenchmarkTest` printing latency percentiles and asserting the round-trip contract (cached path: zero prepares per query; uncached: one prepare + one close per query). | ||
|
|
||
| ## Compatibility | ||
|
|
||
| - Public API unchanged: `query`, `queryWithParams`, `refreshDataset`, `reset`, `close`, and all existing builder methods behave as before. | ||
| - `queryWithParams` error causes are now `FlightRuntimeException` instead of `AdbcException` (both surfaced inside `ExecutionException`). | ||
| - To restore the previous prepare-per-query behavior: `withPreparedStatementCacheSize(0)`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.