From 7b1ab6f15b78b328b9698938c9712ac684a9a9c7 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Fri, 11 Sep 2020 08:53:57 -0400 Subject: [PATCH] Adjust BWC after backporting point in time to 7.10 (#62262) Relates #61062 --- build.gradle | 4 ++-- .../action/search/SearchResponse.java | 4 ++-- .../action/search/SearchTransportService.java | 2 +- .../search/builder/SearchSourceBuilder.java | 4 ---- .../elasticsearch/search/dfs/DfsSearchResult.java | 4 ++-- .../search/fetch/ShardFetchSearchRequest.java | 4 ++-- .../search/internal/ShardSearchRequest.java | 15 +++++---------- .../search/query/QuerySearchRequest.java | 4 ++-- .../search/query/QuerySearchResult.java | 4 ++-- .../test/async_search/20-with-poin-in-time.yml | 4 ++-- .../rest-api-spec/test/search/point_in_time.yml | 8 ++++---- 11 files changed, 24 insertions(+), 33 deletions(-) diff --git a/build.gradle b/build.gradle index f1dceaeb885b4..53a3a164c39de 100644 --- a/build.gradle +++ b/build.gradle @@ -174,8 +174,8 @@ tasks.register("verifyVersions") { * after the backport of the backcompat code is complete. */ -boolean bwc_tests_enabled = false -final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/61872" +boolean bwc_tests_enabled = true +final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */ if (bwc_tests_enabled == false) { if (bwc_tests_disabled_issue.isEmpty()) { throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false") diff --git a/server/src/main/java/org/elasticsearch/action/search/SearchResponse.java b/server/src/main/java/org/elasticsearch/action/search/SearchResponse.java index d832901be62bd..f1e4b7db68a52 100644 --- a/server/src/main/java/org/elasticsearch/action/search/SearchResponse.java +++ b/server/src/main/java/org/elasticsearch/action/search/SearchResponse.java @@ -96,7 +96,7 @@ public SearchResponse(StreamInput in) throws IOException { scrollId = in.readOptionalString(); tookInMillis = in.readVLong(); skippedShards = in.readVInt(); - if (in.getVersion().onOrAfter(Version.V_8_0_0)) { + if (in.getVersion().onOrAfter(Version.V_7_10_0)) { pointInTimeId = in.readOptionalString(); } else { pointInTimeId = null; @@ -408,7 +408,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(scrollId); out.writeVLong(tookInMillis); out.writeVInt(skippedShards); - if (out.getVersion().onOrAfter(Version.V_8_0_0)) { + if (out.getVersion().onOrAfter(Version.V_7_10_0)) { out.writeOptionalString(pointInTimeId); } } diff --git a/server/src/main/java/org/elasticsearch/action/search/SearchTransportService.java b/server/src/main/java/org/elasticsearch/action/search/SearchTransportService.java index dc2dee1203bd9..53425c3b0a3c6 100644 --- a/server/src/main/java/org/elasticsearch/action/search/SearchTransportService.java +++ b/server/src/main/java/org/elasticsearch/action/search/SearchTransportService.java @@ -281,7 +281,7 @@ public void writeTo(StreamOutput out) throws IOException { } static boolean keepStatesInContext(Version version) { - return version.before(Version.V_8_0_0); + return version.before(Version.V_7_10_0); } public static void registerRequestHandler(TransportService transportService, SearchService searchService) { diff --git a/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index 9da90c8873e8d..c9a42699a173e 100644 --- a/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -250,8 +250,6 @@ public SearchSourceBuilder(StreamInput in) throws IOException { if (in.readBoolean()) { fetchFields = in.readList(FieldAndFormat::new); } - } - if (in.getVersion().onOrAfter(Version.V_8_0_0)) { pointInTimeBuilder = in.readOptionalWriteable(PointInTimeBuilder::new); } } @@ -313,8 +311,6 @@ public void writeTo(StreamOutput out) throws IOException { if (fetchFields != null) { out.writeList(fetchFields); } - } - if (out.getVersion().onOrAfter(Version.V_8_0_0)) { out.writeOptionalWriteable(pointInTimeBuilder); } } diff --git a/server/src/main/java/org/elasticsearch/search/dfs/DfsSearchResult.java b/server/src/main/java/org/elasticsearch/search/dfs/DfsSearchResult.java index a7a3ff7085d2e..7cbd601180552 100644 --- a/server/src/main/java/org/elasticsearch/search/dfs/DfsSearchResult.java +++ b/server/src/main/java/org/elasticsearch/search/dfs/DfsSearchResult.java @@ -61,7 +61,7 @@ public DfsSearchResult(StreamInput in) throws IOException { fieldStatistics = readFieldStats(in); maxDoc = in.readVInt(); - if (in.getVersion().onOrAfter(Version.V_8_0_0)) { + if (in.getVersion().onOrAfter(Version.V_7_10_0)) { setShardSearchRequest(in.readOptionalWriteable(ShardSearchRequest::new)); } } @@ -115,7 +115,7 @@ public void writeTo(StreamOutput out) throws IOException { writeTermStats(out, termStatistics); writeFieldStats(out, fieldStatistics); out.writeVInt(maxDoc); - if (out.getVersion().onOrAfter(Version.V_8_0_0)) { + if (out.getVersion().onOrAfter(Version.V_7_10_0)) { out.writeOptionalWriteable(getShardSearchRequest()); } } diff --git a/server/src/main/java/org/elasticsearch/search/fetch/ShardFetchSearchRequest.java b/server/src/main/java/org/elasticsearch/search/fetch/ShardFetchSearchRequest.java index 8a91b88173835..83b9acfa0759d 100644 --- a/server/src/main/java/org/elasticsearch/search/fetch/ShardFetchSearchRequest.java +++ b/server/src/main/java/org/elasticsearch/search/fetch/ShardFetchSearchRequest.java @@ -57,7 +57,7 @@ public ShardFetchSearchRequest(OriginalIndices originalIndices, ShardSearchConte public ShardFetchSearchRequest(StreamInput in) throws IOException { super(in); originalIndices = OriginalIndices.readOriginalIndices(in); - if (in.getVersion().onOrAfter(Version.V_8_0_0)) { + if (in.getVersion().onOrAfter(Version.V_7_10_0)) { shardSearchRequest = in.readOptionalWriteable(ShardSearchRequest::new); rescoreDocIds = new RescoreDocIds(in); aggregatedDfs = in.readOptionalWriteable(AggregatedDfs::new); @@ -72,7 +72,7 @@ public ShardFetchSearchRequest(StreamInput in) throws IOException { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); OriginalIndices.writeOriginalIndices(originalIndices, out); - if (out.getVersion().onOrAfter(Version.V_8_0_0)) { + if (out.getVersion().onOrAfter(Version.V_7_10_0)) { out.writeOptionalWriteable(shardSearchRequest); rescoreDocIds.writeTo(out); out.writeOptionalWriteable(aggregatedDfs); diff --git a/server/src/main/java/org/elasticsearch/search/internal/ShardSearchRequest.java b/server/src/main/java/org/elasticsearch/search/internal/ShardSearchRequest.java index 15e5effa38fa4..166d434a9ac5f 100644 --- a/server/src/main/java/org/elasticsearch/search/internal/ShardSearchRequest.java +++ b/server/src/main/java/org/elasticsearch/search/internal/ShardSearchRequest.java @@ -204,16 +204,13 @@ public ShardSearchRequest(StreamInput in) throws IOException { if (in.getVersion().onOrAfter(Version.V_7_7_0)) { canReturnNullResponseIfMatchNoDocs = in.readBoolean(); bottomSortValues = in.readOptionalWriteable(SearchSortValuesAndFormats::new); + readerId = in.readOptionalWriteable(ShardSearchContextId::new); + keepAlive = in.readOptionalTimeValue(); } else { canReturnNullResponseIfMatchNoDocs = false; bottomSortValues = null; - } - if (in.getVersion().onOrAfter(Version.V_8_0_0)) { - this.readerId = in.readOptionalWriteable(ShardSearchContextId::new); - this.keepAlive = in.readOptionalTimeValue(); - } else { - this.readerId = null; - this.keepAlive = null; + readerId = null; + keepAlive = null; } originalIndices = OriginalIndices.readOriginalIndices(in); assert (readerId != null) == (keepAlive != null); @@ -271,11 +268,9 @@ protected final void innerWriteTo(StreamOutput out, boolean asKey) throws IOExce out.writeStringArray(indexRoutings); out.writeOptionalString(preference); } - if (out.getVersion().onOrAfter(Version.V_7_7_0) && asKey == false) { + if (asKey == false && out.getVersion().onOrAfter(Version.V_7_7_0)) { out.writeBoolean(canReturnNullResponseIfMatchNoDocs); out.writeOptionalWriteable(bottomSortValues); - } - if (out.getVersion().onOrAfter(Version.V_8_0_0) && asKey == false) { out.writeOptionalWriteable(readerId); out.writeOptionalTimeValue(keepAlive); } diff --git a/server/src/main/java/org/elasticsearch/search/query/QuerySearchRequest.java b/server/src/main/java/org/elasticsearch/search/query/QuerySearchRequest.java index efb9410b88a29..76ffcddf6f3e5 100644 --- a/server/src/main/java/org/elasticsearch/search/query/QuerySearchRequest.java +++ b/server/src/main/java/org/elasticsearch/search/query/QuerySearchRequest.java @@ -58,7 +58,7 @@ public QuerySearchRequest(StreamInput in) throws IOException { contextId = new ShardSearchContextId(in); dfs = new AggregatedDfs(in); originalIndices = OriginalIndices.readOriginalIndices(in); - if (in.getVersion().onOrAfter(Version.V_8_0_0)) { + if (in.getVersion().onOrAfter(Version.V_7_10_0)) { this.shardSearchRequest = in.readOptionalWriteable(ShardSearchRequest::new); } else { this.shardSearchRequest = null; @@ -71,7 +71,7 @@ public void writeTo(StreamOutput out) throws IOException { contextId.writeTo(out); dfs.writeTo(out); OriginalIndices.writeOriginalIndices(originalIndices, out); - if (out.getVersion().onOrAfter(Version.V_8_0_0)) { + if (out.getVersion().onOrAfter(Version.V_7_10_0)) { out.writeOptionalWriteable(shardSearchRequest); } } diff --git a/server/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java b/server/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java index b91cd98786fd1..ca1db258d08cf 100644 --- a/server/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java +++ b/server/src/main/java/org/elasticsearch/search/query/QuerySearchResult.java @@ -342,7 +342,7 @@ public void readFromWithId(ShardSearchContextId id, StreamInput in) throws IOExc hasProfileResults = profileShardResults != null; serviceTimeEWMA = in.readZLong(); nodeQueueSize = in.readInt(); - if (in.getVersion().onOrAfter(Version.V_8_0_0)) { + if (in.getVersion().onOrAfter(Version.V_7_10_0)) { setShardSearchRequest(in.readOptionalWriteable(ShardSearchRequest::new)); setRescoreDocIds(new RescoreDocIds(in)); } @@ -383,7 +383,7 @@ public void writeToNoId(StreamOutput out) throws IOException { out.writeOptionalWriteable(profileShardResults); out.writeZLong(serviceTimeEWMA); out.writeInt(nodeQueueSize); - if (out.getVersion().onOrAfter(Version.V_8_0_0)) { + if (out.getVersion().onOrAfter(Version.V_7_10_0)) { out.writeOptionalWriteable(getShardSearchRequest()); getRescoreDocIds().writeTo(out); } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/async_search/20-with-poin-in-time.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/async_search/20-with-poin-in-time.yml index e02ae478fc5f2..348f3bcd58433 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/async_search/20-with-poin-in-time.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/async_search/20-with-poin-in-time.yml @@ -1,8 +1,8 @@ --- "Async search with point in time": - skip: - version: " - 7.99.99" - reason: "point in time is introduced in 8.0" + version: " - 7.9.99" + reason: "point in time is introduced in 7.10" - do: indices.create: index: test-1 diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/search/point_in_time.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/search/point_in_time.yml index f6ff4d66f9a41..6aad33f059ddf 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/search/point_in_time.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/search/point_in_time.yml @@ -37,8 +37,8 @@ setup: --- "basic": - skip: - version: " - 7.99.99" - reason: "point in time is introduced in 8.0" + version: " - 7.9.99" + reason: "point in time is introduced in 7.10" - do: open_point_in_time: index: test @@ -137,8 +137,8 @@ setup: --- "wildcard": - skip: - version: " - 7.99.99" - reason: "point in time is introduced in 8.0" + version: " - 7.9.99" + reason: "point in time is introduced in 7.10" - do: open_point_in_time: index: "t*"