-
Notifications
You must be signed in to change notification settings - Fork 36
Improve failover mechanism for primary and secondary replica connections #243
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
Changes from 7 commits
7baefda
4cf0cfa
7f2207f
9a44e1e
d937287
2c8751f
af4c91d
268c884
fec34cc
f353ade
62c4368
c197c4a
2561b6b
01c7361
8f31ae6
b8d3aa5
641b576
5dd3a4d
3041170
8f7cf33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,15 +33,17 @@ public GraknClientException(String error) { | |
this.errorMessage = null; | ||
} | ||
|
||
public GraknClientException(ErrorMessage error) { | ||
super(error.toString()); | ||
public GraknClientException(ErrorMessage error, Object... parameters) { | ||
super(error.message(parameters)); | ||
assert !getMessage().contains("%s"); | ||
this.errorMessage = error; | ||
} | ||
|
||
public static GraknClientException of(StatusRuntimeException statusRuntimeException) { | ||
if (statusRuntimeException.getStatus().getCode() == Status.Code.UNAVAILABLE) { | ||
return new GraknClientException(ErrorMessage.Client.UNABLE_TO_CONNECT); | ||
} else if (statusRuntimeException.getStatus().getCode() == Status.Code.INTERNAL && statusRuntimeException.getStatus().getDescription().contains("[RFT01]")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this particular if block I want to check if the server throws an exception because there's no leader yet. The server will throw an exception of code "[RFT01]", and the only way to propagate that information about the exception is by embedding it in the message, hence the need for Is there a better way to propagate exceptions than this? Do you have better ideas? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The best alternatives that we have right now would be to either:
So in conclusion parsing the error message is the least bad option right now. There are plans, in the future, to implement a dedicated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've moved the hacky code into its own method and added a TODO: 268c884 |
||
return new GraknClientException(ErrorMessage.Client.CLUSTER_REPLICA_NOT_PRIMARY); | ||
} | ||
return new GraknClientException(statusRuntimeException.getStatus().getDescription()); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,8 +50,8 @@ def graknlabs_dependencies(): | |
def graknlabs_protocol(): | ||
git_repository( | ||
name = "graknlabs_protocol", | ||
remote = "https://github.com/graknlabs/protocol", | ||
tag = "2.0.0-alpha-6", # sync-marker: do not remove this comment, this is used for sync-dependencies by @graknlabs_protocol | ||
remote = "https://github.com/lolski/protocol", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert to |
||
commit = "125b3b88d817e84dcb83702eb557eb4d5bcea4a1", # sync-marker: do not remove this comment, this is used for sync-dependencies by @graknlabs_protocol | ||
) | ||
|
||
def graknlabs_behaviour(): | ||
|
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.
The reasoning to rename it to
READ_SECONDARY
is because it allows you to read from secondary replicas, whereasREAD
andWRITE
reads to the primary replica.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.
We agreed in a verbal discussion with Haikal to get rid of the
READ_SECONDARY
transaction type and replace it with a newOption
.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.
Fixed in fec34cc, 62c4368, 8f31ae6, and b8d3aa5 (I don't know why it took me 4 commits to do so :D )