You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
…ng sent twice (#34358)
### Rationale for this change
The `AvaticaConnection` class within the Calcite library [executes](https://github.com/apache/calcite-avatica/blob/b57eb7cd31a90d3f46b65c13832b398be5b0dad9/core/src/main/java/org/apache/calcite/avatica/AvaticaConnection.java#L357) the `prepareStatement(...)` function on a DB connection in the following order:
1. Calls `prepare()` on the `MetaImpl` class, which in our case is `ArrowFlightMetaImpl`. This function executes a command and returns a prepared statement.
2. Calls `newPreparedStatement` on the JDBC factory class, which in our case is `ArrowFlightJdbcFactory`. This function today creates an entirely new `PreparedStatement` without checking the statement cache, thereby causing 2 executions.
This PR fixes the issue by checking whether or not the `StatementHandle` has been recorded before, and if so, uses the results of the previously executed command. If not, it creates a brand new `PreparedStatement`.
My understanding is that `ConcurrentHashMap` (which is what is being used to keep a mapping of statement handles to prepared statements) is eventually consistent, so there _may_ be cases where the prepared statement execution runs twice.
### What changes are included in this PR?
Check to see if the `PreparedStatement` has run before, and if so, use that instead of executing the command to contact the server again.
### Are these changes tested?
Existing tests should cover this case. Namely, `ArrowFlightPreparedStatementTest` I _think_ should cover all cases.
### Are there any user-facing changes?
There are no user facing changes.
* Closes: #34284
Authored-by: Ramasai <ramasai.tadepalli+3108@gmail.com>
Signed-off-by: David Li <li.davidm96@gmail.com>
Describe the bug, including details regarding any error messages, version, and platform.
From user@:
Component(s)
FlightRPC, Java
The text was updated successfully, but these errors were encountered: