Hey Josh,
Thanks for the clarification!
Francis
On 20/07/2017 4:30 AM, Josh Elser wrote:
On 7/17/17 8:04 AM, F21 wrote:
I am investigating HA support for the Go Avatica driver.
Let's assume a scenario where we have multiple Avatica servers behind
a load balancer and do not want to use sticky sessions.
Currently, these are some of the questions I have:
1. A connection with an id "123" opened. A server handles the request
and then fails immediately after. We then call a
PrepareAndExecuteRequest using the connection_id of "123". In this
case, what happens? ExecuteResponse does not appear to have a field
telling us the connection_id is invalid.
I don't recall the exact context, but there is information passed back
to definitively know that either a connection or statement do not
exist server-side. I can dig into the Java source if you're unable to
find it :)
2. A connection with an id "456" is opened. A server handles the
request and we call PrepareAndExecuteRequest. This returns a
resultset. The server fails at this point. We then call a
FetchRequest to fetch more rows, but the server has no record of this
query. If missing_statement is true, we recreate the statement on a
new connection. What is the expected corrective action if
missing_results is true? I am assuming we use a SyncResultsRequest to
sync the results, and if SyncResultResponse has missing_statement set
to true, because the server failed, we recreate the statement and
retry. Are there any cases where missing_statement is false but
missing_results is true (what causes this scenario)? Also, how about
missing_statement = true and missing_results = false?
I don't think that missing_statement=false/missing_results=true would
ever happen as server failure would be the only possible way (the
avatica server would have crashed and the statement would be lost
anyways).
A missing statement without missing results may happen (same scenario
as the first question). I believe it is a true statement that we would
only be missing results if we were not missing a statement (as the
results are created by the statement). Similarly, we would never have
results if we were missing a statement.
If it helps to visualize in code, in JDBC:
Connection conn = getConnection(conn_id); // missing_connection
Statement stmt = getStatement(conn, stmt_id); // missing_statement
ResultSet results = getResults(conn, stmt); // missing_results
We never get to the further point if we miss context earlier.
3. I noticed that with ExecuteRequest, FetchRequest and
ExecuteBatchRequest, there is sufficient information in the
statement_handle and other fields to allow Avatica to automatically
recreate the statement or result set on the server if it is missing.
Is there any reason why this is not being automatically handled by
Avatica?
Presently, the server doesn't hold on to that information. For the HA
case, the server you're currently talking to never saw the creation of
a connection, statement, results. That's why it has to be client-driven.
We could try to make the Avatica server smart enough to re-create the
objects when they were automatically expired (after 10mins: default),
but the common case is that the previous server died and the new
server just doesn't know.
Cheers,
Francis