-
Notifications
You must be signed in to change notification settings - Fork 34
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
Split client construction and connection validation #422
Split client construction and connection validation #422
Conversation
PR Review ChecklistDo not edit the content of this comment. The PR reviewer should simply update this comment by ticking each review item below, as they get completed. Trivial Change
Code
Architecture
|
…tion separately again
connection/TypeDBClientImpl.java
Outdated
|
||
@Override | ||
public boolean isOpen() { | ||
return !channel().isShutdown() && connectionValidated; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"open" now means the channel is available and the connection has been validated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should be in different accessors now. There's currently no way to check whether the client is in a "destroyed" state (i.e. .close()
was explicitly called), or if it's in a "not yet validated" state where it can be reopened.
connection/TypeDBClientImpl.java
Outdated
transmitter.close(); | ||
} catch (InterruptedException e) { | ||
Thread.currentThread().interrupt(); | ||
if (isOpen()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this "Close" method can ever only be called once by the user, and does not auto-recover the way that a network interrupt does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my previous comment. If the client has been opened but not validated (network error, whatever else) the channel will not be shut down.
@@ -320,6 +322,12 @@ private void waitForPrimaryReplicaSelection() { | |||
} | |||
} | |||
|
|||
private ClusterServerClient fetchOpenServerClient(String address) { | |||
ClusterServerClient serverClient = clusterServerClient(address); | |||
if (!serverClient.isOpen()) serverClient.validateConnection(); // may throw exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we can't use clients until we validate the connection, we attempt to validate until the validation succeeds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too, isOpen()
represents both transient network failures, for which we want to reattempt a handshake, and a forcibly closed client, for which we don't.
connection/TypeDBClientImpl.java
Outdated
|
||
@Override | ||
public boolean isOpen() { | ||
return !channel().isShutdown() && connectionValidated; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these should be in different accessors now. There's currently no way to check whether the client is in a "destroyed" state (i.e. .close()
was explicitly called), or if it's in a "not yet validated" state where it can be reopened.
connection/TypeDBClientImpl.java
Outdated
transmitter.close(); | ||
} catch (InterruptedException e) { | ||
Thread.currentThread().interrupt(); | ||
if (isOpen()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my previous comment. If the client has been opened but not validated (network error, whatever else) the channel will not be shut down.
@@ -320,6 +322,12 @@ private void waitForPrimaryReplicaSelection() { | |||
} | |||
} | |||
|
|||
private ClusterServerClient fetchOpenServerClient(String address) { | |||
ClusterServerClient serverClient = clusterServerClient(address); | |||
if (!serverClient.isOpen()) serverClient.validateConnection(); // may throw exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too, isOpen()
represents both transient network failures, for which we want to reattempt a handshake, and a forcibly closed client, for which we don't.
## What is the goal of this PR? We update the Rust driver to support the features introduced in driver Java since v2.19 in effort to preserve the feature set when transitioning from the JVM-native implementation to the Rust JNI implementation. ## What are the changes implemented in this PR? Changes in master since branching (#417): Reimplemented in Rust and made available in Java over JNI: - #409 - #421 - 1f396a6 Improve method unavailable error message - #430 - #431: partial, since `tonic` does not report SSL errors to the same granularity Cherry-picked directly: - #415 - 42800e7 Update VERSION to 2.18.1 - 7cd0a5a Add eclipsesource-minimal-json to maven dependencies (#423) - 63614ec Update CODEOWNERS - #424 Dropped entirely (Java-specific or obsolete): - #422 - 8c0caa1 Update VERSION and release notes --------- Co-authored-by: Benjamin Small <benjaminasmall@gmail.com> Co-authored-by: joshua <joshua@vaticle.com> Co-authored-by: Krishnan Govindraj <krishnangovindraj@users.noreply.github.com>
What is the goal of this PR?
To prevent null pointer errors during failover tasks being executed, we go back to the previous model of first creating a client, then opening and validating the connection.
What are the changes implemented in this PR?