From 452bfc0d830e0e1d0e3dd28d6e007e51c386572e Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Wed, 14 Feb 2018 13:19:39 -0500 Subject: [PATCH] Backported synced-flush PR to v5.6.8 and v6.2.2 Relates #28464 --- .../indices/flush/SyncedFlushService.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java b/server/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java index eff6d7ab3b9..6a3618e6689 100644 --- a/server/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java +++ b/server/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java @@ -529,11 +529,19 @@ public class SyncedFlushService extends AbstractComponent implements IndexEventL return numDocs; } + boolean includeNumDocs(Version version) { + if (version.major == Version.V_5_6_8.major) { + return version.onOrAfter(Version.V_5_6_8); + } else { + return version.onOrAfter(Version.V_6_2_2); + } + } + @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); commitId = new Engine.CommitId(in); - if (in.getVersion().onOrAfter(Version.V_6_3_0)) { + if (includeNumDocs(in.getVersion())) { numDocs = in.readInt(); } else { numDocs = UNKNOWN_NUM_DOCS; @@ -544,7 +552,7 @@ public class SyncedFlushService extends AbstractComponent implements IndexEventL public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); commitId.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_6_3_0)) { + if (includeNumDocs(out.getVersion())) { out.writeInt(numDocs); } }