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
PHOENIX-5636: Improve the error message when client connects to server with higher major version #676
Conversation
f0d9879
to
0866ad8
Compare
if (systemCatalogTimestamp < MIN_SYSTEM_TABLE_TIMESTAMP) { | ||
throw new UpgradeRequiredException(systemCatalogTimestamp); | ||
} | ||
} | ||
|
||
private String displayClientandServerVersions(long serverJarVersion) { | ||
String clientVersion = PHOENIX_MAJOR_VERSION + "." + PHOENIX_MINOR_VERSION + "." + PHOENIX_PATCH_NUMBER; |
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 is already present , you can probably just use it : https://github.com/apache/phoenix/blob/master/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java#L151
if (isIncompatible) { | ||
buf.setLength(buf.length()-1); | ||
throw new SQLExceptionInfo.Builder(SQLExceptionCode.OUTDATED_JARS).setMessage(buf.toString()).build().buildException(); | ||
if (!(errorCode.toString().equals(new StringBuilder().toString()))) { |
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.
is this doing an empty string comparision ?
e775f86
to
ea39d9d
Compare
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.
Overall looks good. I have some feedback, please take a look @christinefeng.
return VersionUtil.encodeMinPatchVersion(clientMajorVersion, clientMinorVersion) <= serverVersion && // Minor major and minor cannot be ahead of server | ||
VersionUtil.encodeMaxMinorVersion(clientMajorVersion) >= serverVersion; // Major version must at least be up to server version | ||
boolean isCompatible = true; | ||
if (!(VersionUtil.encodeMinPatchVersion(clientMajorVersion, clientMinorVersion) <= serverVersion)) { |
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.
nit: simplify this condition to >
if (!(VersionUtil.encodeMinPatchVersion(clientMajorVersion, clientMinorVersion) <= serverVersion)) { | ||
isCompatible = false; | ||
buf.append(SQLExceptionCode.OUTDATED_JARS.getErrorCode()); | ||
} else if (!(VersionUtil.encodeMaxMinorVersion(clientMajorVersion) >= serverVersion)) { |
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.
same here. Change !>=
to <
@@ -1487,20 +1487,17 @@ private static boolean hasIndexWALCodec(Long serverVersion) { | |||
return MetaDataUtil.decodeHasIndexWALCodec(serverVersion); | |||
} | |||
|
|||
private static boolean isCompatible(Long serverVersion) { | |||
private static boolean isCompatible(Long serverVersion, StringBuilder buf) { |
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 might be out of scope of your JIRA, but it's a potentially small change. The method isCompatible
looks pretty useless to me. Can't all the logic be moved down to MetaDataUtil.areClientAndServerCompatible
?
if (serverVersion == null) { | ||
return false; | ||
} | ||
return MetaDataUtil.areClientAndServerCompatible(serverVersion); | ||
return MetaDataUtil.areClientAndServerCompatible(serverVersion, buf); |
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'm also not a big fan of passing the StringBuilder param everywhere. It might be just cleaner to have a small inner class to represent clientServerCompatibility and which contains perhaps the following:
- client version
- server version
- an is compatible check based on the above 2 values
- error message and/or code if there is an incompatibility
- getters/setters of error message/code and versions
That also makes it obvious what the class does and what the buffer contains.
It shouldn't be too much work to add this small inner class. At least, we should rename "buf" to "errorString" or something.
phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
Outdated
Show resolved
Hide resolved
e5c2ede
to
6bd7d99
Compare
phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
Outdated
Show resolved
Hide resolved
phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
Outdated
Show resolved
Hide resolved
phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
Outdated
Show resolved
Hide resolved
phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
Outdated
Show resolved
Hide resolved
f7713fe
to
5af0e6b
Compare
|
||
if (compatibility.getErrorCode() != 0) { | ||
if (compatibility.getErrorCode() == SQLExceptionCode.OUTDATED_JARS.getErrorCode()) { | ||
errorMessage.setLength(errorMessage.length()-1); |
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.
Do we need to setLength on the StringBuilder object? We can just directly call toString right?
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 setLength(length-1) gets rid of a trailing semicolon if there are multiple outdated jars error messages strung together (for loop at line 1540)
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.
If there aren't multiple messages, and the loop runs just once, does it print the correct thing still or leave out the last character?
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.
@christinefeng ping on this one^
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.
If it runs just once, there's still that trailing semicolon from line 1559, so the set length-1 gets rid of that semicolon
Not sure if I should add something similar to the incompatible_client_server_jar error message in case of multiple messages?
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.
That's more for cases when we have SYSCAT on more than 1 region. Your change should be fine.
phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
Outdated
Show resolved
Hide resolved
phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
Outdated
Show resolved
Hide resolved
phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
Outdated
Show resolved
Hide resolved
phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
Outdated
Show resolved
Hide resolved
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.
Small nit. Almost there @christinefeng !
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.
+1, please squash all your commits into 1 and let's get a Hadoop QA run on your changes. Thanks @christinefeng !
067bfb7
to
75af7e8
Compare
…r with higher major version
75af7e8
to
fa0c3a6
Compare
Already merged. |
No description provided.