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

PHOENIX-5636: Improve the error message when client connects to server with higher major version #676

Closed
wants to merge 1 commit into from

Conversation

christinefeng
Copy link
Contributor

No description provided.

@christinefeng
Copy link
Contributor Author

@christinefeng christinefeng force-pushed the PHOENIX-5636 branch 2 times, most recently from f0d9879 to 0866ad8 Compare January 16, 2020 00:12
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()))) {

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 ?

@christinefeng christinefeng force-pushed the PHOENIX-5636 branch 4 times, most recently from e775f86 to ea39d9d Compare January 31, 2020 22:33
Copy link
Contributor

@ChinmaySKulkarni ChinmaySKulkarni left a 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)) {
Copy link
Contributor

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)) {
Copy link
Contributor

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) {
Copy link
Contributor

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);
Copy link
Contributor

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.

@christinefeng christinefeng force-pushed the PHOENIX-5636 branch 4 times, most recently from e5c2ede to 6bd7d99 Compare February 19, 2020 22:24
@christinefeng christinefeng force-pushed the PHOENIX-5636 branch 2 times, most recently from f7713fe to 5af0e6b Compare February 24, 2020 23:47

if (compatibility.getErrorCode() != 0) {
if (compatibility.getErrorCode() == SQLExceptionCode.OUTDATED_JARS.getErrorCode()) {
errorMessage.setLength(errorMessage.length()-1);
Copy link
Contributor

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?

Copy link
Contributor Author

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)

Copy link
Contributor

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?

Copy link
Contributor

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^

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor

@ChinmaySKulkarni ChinmaySKulkarni left a 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 !

Copy link
Contributor

@ChinmaySKulkarni ChinmaySKulkarni left a 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 !

@stoty
Copy link
Contributor

stoty commented Aug 1, 2023

Already merged.

@stoty stoty closed this Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants