Skip to content
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

Make more error codes fail fast during the rediscovery #1354

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ public class RediscoveryImpl implements Rediscovery {
"Received a recoverable discovery error with server '%s', "
+ "will continue discovery with other routing servers if available. "
+ "Complete failure is reported separately from this entry.";
private static final String INVALID_BOOKMARK_CODE = "Neo.ClientError.Transaction.InvalidBookmark";
private static final String INVALID_BOOKMARK_MIXTURE_CODE = "Neo.ClientError.Transaction.InvalidBookmarkMixture";
private static final String TRANSACTION_INVALID_BOOKMARK_CODE = "Neo.ClientError.Transaction.InvalidBookmark";
private static final String TRANSACTION_INVALID_BOOKMARK_MIXTURE_CODE =
"Neo.ClientError.Transaction.InvalidBookmarkMixture";
private static final String STATEMENT_ARGUMENT_ERROR_CODE = "Neo.ClientError.Statement.ArgumentError";
private static final String REQUEST_INVALID_CODE = "Neo.ClientError.Request.Invalid";
private static final String STATEMENT_TYPE_ERROR_CODE = "Neo.ClientError.Statement.TypeError";

private final BoltServerAddress initialRouter;
private final Logger log;
Expand Down Expand Up @@ -294,7 +298,13 @@ private boolean mustAbortDiscovery(Throwable throwable) {
abort = true;
} else if (throwable instanceof ClientException) {
String code = ((ClientException) throwable).code();
abort = INVALID_BOOKMARK_CODE.equals(code) || INVALID_BOOKMARK_MIXTURE_CODE.equals(code);
abort = switch (code) {
case TRANSACTION_INVALID_BOOKMARK_CODE,
TRANSACTION_INVALID_BOOKMARK_MIXTURE_CODE,
STATEMENT_ARGUMENT_ERROR_CODE,
REQUEST_INVALID_CODE,
STATEMENT_TYPE_ERROR_CODE -> true;
default -> false;};
}

return abort;
Expand Down