Skip to content

Commit

Permalink
Fix refresh optimization for realtime gets in mixed cluster (#48151)
Browse files Browse the repository at this point in the history
We might not have sequence numbers in a mixed cluster between 6.8 and 
5.6. In this case, we should refresh unconditionally; otherwise, we can
apply the refresh optimization. An alternative is to use translog
locations instead of the local checkpoint for this optimization.

Closes #48114
  • Loading branch information
dnhatn authored Oct 16, 2019
1 parent b9cc99d commit 269e9ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,15 @@ public void testUpdateDoc() throws Exception {
updates.put(docId, value);
}
}
client().performRequest(new Request("POST", index + "/_refresh"));
boolean refreshed = randomBoolean();
if (refreshed) {
client().performRequest(new Request("POST", index + "/_refresh"));
}
for (int docId : updates.keySet()) {
Request get = new Request("GET", index + "/test/" + docId);
if (refreshed && randomBoolean()) {
get.addParameter("realtime", "false");
}
Map<String, Object> doc = entityAsMap(client().performRequest(get));
assertThat(XContentMapValues.extractValue("_source.updated_field", doc), equalTo(updates.get(docId)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,8 +675,12 @@ public GetResult get(Get get, BiFunction<String, SearcherScope, Searcher> search
trackTranslogLocation.set(true);
}
}
assert versionValue.seqNo >= 0 : versionValue;
refreshIfNeeded("realtime_get", versionValue.seqNo);
if (versionValue.seqNo != SequenceNumbers.UNASSIGNED_SEQ_NO) {
assert versionValue.seqNo >= 0 : versionValue;
refreshIfNeeded("realtime_get", versionValue.seqNo);
} else {
refresh("realtime_get", SearcherScope.INTERNAL);
}
}
scope = SearcherScope.INTERNAL;
} else {
Expand Down

0 comments on commit 269e9ba

Please sign in to comment.