-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
backwards compatible deserialization of SqlQueryResponse and fix SQL bwc tests #78467
Conversation
I've also already created the backport PR #78465 to ensure the 7.x bwc tests turn green as well. |
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.
Lgtm, thanks.
import org.elasticsearch.xpack.ql.async.QlStatusResponse; | ||
import org.elasticsearch.xpack.sql.proto.ColumnInfo; | ||
import org.elasticsearch.xpack.sql.proto.Mode; | ||
import org.elasticsearch.xpack.sql.proto.Protocol; | ||
import org.elasticsearch.xpack.sql.proto.SqlVersion; | ||
import org.elasticsearch.xpack.sql.proto.StringUtils; | ||
|
||
import java.io.IOException; |
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.
have these been reordered automatically by the editor?
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.
yes. I think that follows the default imports layout.
} | ||
} | ||
|
||
private Map<String, Object> dropDisplaySizes(Map<String, Object> response) { | ||
// if JDBC mode is used, display_size will also be part of the response, remove it because it's not part of the expected response |
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 JDBC mode is used, display_size will also be part of the response, remove it because it's not part of the expected response | |
// in JDBC mode, display_size will be part of the response, so remove it because it's not part of the expected response |
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.
👍 thx
Map<String, Object> actualResponse = dropDisplaySizes(runSql(client, request)); | ||
assertResponse(expectedResponse, actualResponse); |
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.
optional nit: actualResponse
could be inlined.
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.
Left some comments.
...n/sql/qa/mixed-node/src/test/java/org/elasticsearch/xpack/sql/qa/mixed_node/SqlCompatIT.java
Show resolved
Hide resolved
String intervalYearMonth = "INTERVAL '150' YEAR AS interval_year, "; | ||
String intervalDayTime = "INTERVAL '163' MINUTE AS interval_minute, "; |
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 find this style to be more "visible" and easier to read. Can you, please, keep the original version?
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.
sure, I inlined it because I thought it was a leftover from using a conditional here in earlier revisions.
if (in.getVersion().onOrAfter(Version.V_7_14_0)) { | ||
columnar = in.readBoolean(); | ||
asyncExecutionId = in.readOptionalString(); | ||
isPartial = in.readBoolean(); | ||
isRunning = in.readBoolean(); | ||
} else { | ||
asyncExecutionId = null; | ||
isPartial = false; | ||
isRunning = false; | ||
} |
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.
Why this change and why is columnar
included there (it seems you grouped together the async specific settings)?
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.
It hadn't been serialised before the given version: https://github.com/elastic/elasticsearch/pull/73991/files#diff-3c77d10764f4a72e650dfabe508e5d372bf024a776ca17b81c2f4666f859fe01R187 , which was probably an oversight.
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 fact that we discovered this in a BWC test and not when the async search was introduced is troubling. At some point in future we will need a set of tests that should cover the serialization differences between bwc versions for both the request and response objects. I did something similar for EQL here: #68339. @Luegg please open an issue for improving the tests coverage in this area.
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.
My initial question still stands.
To clarify a bit: columnar
has been added in 7.2.0 (#39287). If we should handle it differently depending on the version it shouldn't be 7.14, since that's not the version that added it. Or I am missing something.
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.
it shouldn't be 7.14, since that's not the version that added it.
True, but that's the version that added it to the serialisation.
If not mistaking, between (and before) 7.2 and 7.14, a serialised SqlQueryResponse
didn't contain the columnar
field. So trying to deserialise a SqlQueryResponse
and read the columnar
field would eventually fail.
A 7.14+ serialised SqlQueryResponse
will otoh contain it and needs to be read.
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.
Thanks @bpintea, I was getting confused myself.
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.
Looks good in general but the original question I had about columnar
still stands.
if (in.getVersion().onOrAfter(Version.V_7_14_0)) { | ||
columnar = in.readBoolean(); | ||
asyncExecutionId = in.readOptionalString(); | ||
isPartial = in.readBoolean(); | ||
isRunning = in.readBoolean(); | ||
} else { | ||
asyncExecutionId = null; | ||
isPartial = false; | ||
isRunning = false; | ||
} |
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.
My initial question still stands.
To clarify a bit: columnar
has been added in 7.2.0 (#39287). If we should handle it differently depending on the version it shouldn't be 7.14, since that's not the version that added it. Or I am missing something.
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.
LGTM
@@ -22,7 +22,7 @@ testClusters.configureEach { | |||
tasks.named("integTest").configure{ enabled = false} | |||
|
|||
// A bug (https://github.com/elastic/elasticsearch/issues/68439) limits us to perform tests with versions from 7.10.3 onwards | |||
for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible.findAll { it.onOrAfter('7.10.0') }) { | |||
for (Version bwcVersion : BuildParams.bwcVersions.wireCompatible.findAll { it.onOrAfter('7.10.3') }) { |
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 but a comment would help on what changed in 7.10.3 vs 7.10.0 to make this version being considered.
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.
Using 7.10.0 was a bug. As the comment on line 24 says the version should always have been 7.10.3. But accidentally, the tests also worked with 7.10.0 until I introduced missing_order.
Resolves #78424
With the merge of #78363, it's the first time in a while that the bwc tests run cases where upgraded nodes redirect SQL queries to older nodes. Unfortunately, the upgraded nodes were not able to redirect the response from the old nodes to the client due to a bug in deserialization of
SqlQueryResponse
.This PR fixes the deserialization issue. I also had to work around some follow up issues with
SqlSearchIT
because the new query redirect triggers some new code paths that were not yet correct in all wire compatible versions.