Browse Source

fix: backward compatibility with version 7.17.0 (#83715)

PR #83339 was meant to be included in version 7.17.0 but didn't happen.
It landed in version 7.17.1. As a result, version checks in the code are
incorrect. Instead of checking against version 7.17.0 we need to adjust
the code in such a way that it operates correctly with version 7.17.0.
Version 7.17.0 is released and, as as result, it represents the 'reference'
version we would like all following versions to interoperate with.

Unfortunately this means that interoperability between version 7.17.0 and
version 8.0.0 is broken.

In summary this fix needs to be backported to:
* 7.17.1: so to fix interoperability of version 7.17.1 with 7.17.0
* 8.0.1: so to fix interoperability of version 8.0.1 with 7.17.0
* 8.1.0 (currently BC): so to fix interoperability of version 8.1.0 with 7.17.0
* master (8.2): so to fix interoperability of version 8.2.0 with 7.17.0

Also, when reading and writing the range key, version 7.17.0 checks against
version 6.4.0 which is not possible right now. As a result, we just check
against the earliest possible version.
Salvatore Campagna 3 years ago
parent
commit
b09cd19fde

+ 5 - 0
docs/changelog/83715.yaml

@@ -0,0 +1,5 @@
+pr: 83715
+summary: "Fix: backward compatibility with version 7.17.0"
+area: Aggregations
+type: bug
+issues: []

+ 2 - 2
rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.aggregation/40_range.yml

@@ -142,8 +142,8 @@ setup:
 ---
 "Float range":
   - skip:
-      version: " - 7.16.99"
-      reason: Bug fixed in 8.1.0 and backported to 7.17.0
+      version: " - 7.17.0"
+      reason: Bug fixed in 8.1.0 and backported to 7.17.1
   - do:
       search:
         index: test

+ 12 - 2
server/src/main/java/org/elasticsearch/search/aggregations/bucket/range/InternalRange.java

@@ -266,11 +266,21 @@ public class InternalRange<B extends InternalRange.Bucket, R extends InternalRan
             String key = in.getVersion().onOrAfter(Version.V_7_17_1) ? in.readOptionalString() : in.readString();
             double from = in.readDouble();
             if (in.getVersion().onOrAfter(Version.V_7_17_0)) {
-                in.readOptionalDouble();
+                final Double originalFrom = in.readOptionalDouble();
+                if (originalFrom != null) {
+                    from = originalFrom;
+                } else {
+                    from = Double.NEGATIVE_INFINITY;
+                }
             }
             double to = in.readDouble();
             if (in.getVersion().onOrAfter(Version.V_7_17_0)) {
-                in.readOptionalDouble();
+                final Double originalTo = in.readOptionalDouble();
+                if (originalTo != null) {
+                    to = originalTo;
+                } else {
+                    to = Double.POSITIVE_INFINITY;
+                }
             }
             long docCount = in.readVLong();
             InternalAggregations aggregations = InternalAggregations.readFrom(in);