From 5fa0eb83201ca8449839d7bdff2959369a6488f7 Mon Sep 17 00:00:00 2001 From: David Roberts Date: Tue, 8 Dec 2020 11:47:46 +0000 Subject: [PATCH] [ML] Fix serialization order for model_size_stats Due to a backporting mistake, master and 7.x were serializing the members of model_size_stats in different orders. This led to BWC test failures on master. This change makes the ordering in 7.x the same as the ordering in master. It will be tested when the mute done in #65895 is reverted on the master branch. Fixes #65893 --- .../autodetect/state/ModelSizeStats.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSizeStats.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSizeStats.java index 68a792c835c8a..fbdadd8f50f27 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSizeStats.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSizeStats.java @@ -226,6 +226,15 @@ public ModelSizeStats(StreamInput in) throws IOException { totalPartitionFieldCount = in.readVLong(); bucketAllocationFailuresCount = in.readVLong(); memoryStatus = MemoryStatus.readFromStream(in); + if (in.getVersion().onOrAfter(Version.V_7_11_0)) { + if (in.readBoolean()) { + assignmentMemoryBasis = AssignmentMemoryBasis.readFromStream(in); + } else { + assignmentMemoryBasis = null; + } + } else { + assignmentMemoryBasis = null; + } if (in.getVersion().onOrAfter(Version.V_7_7_0)) { categorizedDocCount = in.readVLong(); totalCategoryCount = in.readVLong(); @@ -247,15 +256,6 @@ public ModelSizeStats(StreamInput in) throws IOException { failedCategoryCount = 0; categorizationStatus = CategorizationStatus.OK; } - if (in.getVersion().onOrAfter(Version.V_7_11_0)) { - if (in.readBoolean()) { - assignmentMemoryBasis = AssignmentMemoryBasis.readFromStream(in); - } else { - assignmentMemoryBasis = null; - } - } else { - assignmentMemoryBasis = null; - } logTime = new Date(in.readVLong()); timestamp = in.readBoolean() ? new Date(in.readVLong()) : null; } @@ -286,6 +286,14 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVLong(totalPartitionFieldCount); out.writeVLong(bucketAllocationFailuresCount); memoryStatus.writeTo(out); + if (out.getVersion().onOrAfter(Version.V_7_11_0)) { + if (assignmentMemoryBasis != null) { + out.writeBoolean(true); + assignmentMemoryBasis.writeTo(out); + } else { + out.writeBoolean(false); + } + } if (out.getVersion().onOrAfter(Version.V_7_7_0)) { out.writeVLong(categorizedDocCount); out.writeVLong(totalCategoryCount); @@ -297,14 +305,6 @@ public void writeTo(StreamOutput out) throws IOException { } categorizationStatus.writeTo(out); } - if (out.getVersion().onOrAfter(Version.V_7_11_0)) { - if (assignmentMemoryBasis != null) { - out.writeBoolean(true); - assignmentMemoryBasis.writeTo(out); - } else { - out.writeBoolean(false); - } - } out.writeVLong(logTime.getTime()); boolean hasTimestamp = timestamp != null; out.writeBoolean(hasTimestamp);