Retry on wait_for_metada_version timeout (#38521)

Closes #37807
Backport of #38521
This commit is contained in:
Nhat Nguyen 2019-02-09 19:51:58 -05:00 committed by GitHub
parent 5b112b1d9d
commit c202900915
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 15 deletions

View File

@ -57,22 +57,29 @@ public final class CcrRequests {
}
client.admin().cluster().state(request, ActionListener.wrap(
response -> {
if (response.getState() == null) {
if (response.getState() == null) { // timeout on wait_for_metadata_version
assert metadataVersion > 0 : metadataVersion;
throw new IllegalStateException("timeout to get cluster state with" +
" metadata version [" + metadataVersion + "], mapping version [" + mappingVersion + "]");
if (timeoutSupplier.get().nanos() < 0) {
listener.onFailure(new IllegalStateException("timeout to get cluster state with" +
" metadata version [" + metadataVersion + "], mapping version [" + mappingVersion + "]"));
} else {
getIndexMetadata(client, index, mappingVersion, metadataVersion, timeoutSupplier, listener);
}
} else {
final MetaData metaData = response.getState().metaData();
final IndexMetaData indexMetaData = metaData.getIndexSafe(index);
if (indexMetaData.getMappingVersion() >= mappingVersion) {
listener.onResponse(indexMetaData);
return;
}
if (timeoutSupplier.get().nanos() < 0) {
listener.onFailure(new IllegalStateException(
"timeout to get cluster state with mapping version [" + mappingVersion + "]"));
} else {
// ask for the next version.
getIndexMetadata(client, index, mappingVersion, metaData.version() + 1, timeoutSupplier, listener);
}
}
final MetaData metaData = response.getState().metaData();
final IndexMetaData indexMetaData = metaData.getIndexSafe(index);
if (indexMetaData.getMappingVersion() >= mappingVersion) {
listener.onResponse(indexMetaData);
return;
}
if (timeoutSupplier.get().nanos() < 0) {
throw new IllegalStateException("timeout to get cluster state with mapping version [" + mappingVersion + "]");
}
// ask for the next version.
getIndexMetadata(client, index, mappingVersion, metaData.version() + 1, timeoutSupplier, listener);
},
listener::onFailure
));

View File

@ -235,7 +235,6 @@ public class FollowerFailOverIT extends CcrIntegTestCase {
pauseFollow("follower-index");
}
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/37807")
public void testReadRequestsReturnLatestMappingVersion() throws Exception {
InternalTestCluster leaderCluster = getLeaderCluster();
Settings nodeAttributes = Settings.builder().put("node.attr.box", "large").build();