Skip to content

Commit

Permalink
Set timeout of master requests on follower to unbounded (#60070)
Browse files Browse the repository at this point in the history
Today, a follow task will fail if the master node of the follower
cluster is temporarily overloaded and unable to process master node
requests (such as update mapping, setting, or alias) from a follow-task
within the default timeout. This error is transient, and follow-tasks
should not abort. We can avoid this problem by setting the timeout of
master node requests on the follower cluster to unbounded.

Closes #56891
  • Loading branch information
dnhatn committed Jul 27, 2020
1 parent 8f26836 commit 370d261
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class TimeValue implements Comparable<TimeValue> {

public static final TimeValue MINUS_ONE = timeValueMillis(-1);
public static final TimeValue ZERO = timeValueMillis(0);
public static final TimeValue MAX_VALUE = TimeValue.timeValueNanos(Long.MAX_VALUE);

public static TimeValue timeValueNanos(long nanos) {
return new TimeValue(nanos, TimeUnit.NANOSECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static PutMappingRequest putMappingRequest(String followerIndex, MappingM
putMappingRequest.origin("ccr");
putMappingRequest.type(mappingMetaData.type());
putMappingRequest.source(mappingMetaData.source().string(), XContentType.JSON);
putMappingRequest.masterNodeTimeout(TimeValue.MAX_VALUE);
return putMappingRequest;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,27 +218,27 @@ private void closeIndexUpdateSettingsAndOpenIndex(String followIndex,
Settings updatedSettings,
Runnable handler,
Consumer<Exception> onFailure) {
CloseIndexRequest closeRequest = new CloseIndexRequest(followIndex);
CheckedConsumer<AcknowledgedResponse, Exception> onResponse = response -> {
updateSettingsAndOpenIndex(followIndex, updatedSettings, handler, onFailure);
};
CloseIndexRequest closeRequest = new CloseIndexRequest(followIndex).masterNodeTimeout(TimeValue.MAX_VALUE);
followerClient.admin().indices().close(closeRequest, ActionListener.wrap(onResponse, onFailure));
}

private void updateSettingsAndOpenIndex(String followIndex,
Settings updatedSettings,
Runnable handler,
Consumer<Exception> onFailure) {
final UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(followIndex);
updateSettingsRequest.settings(updatedSettings);
final UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(followIndex)
.masterNodeTimeout(TimeValue.MAX_VALUE).settings(updatedSettings);
CheckedConsumer<AcknowledgedResponse, Exception> onResponse = response -> openIndex(followIndex, handler, onFailure);
followerClient.admin().indices().updateSettings(updateSettingsRequest, ActionListener.wrap(onResponse, onFailure));
}

private void openIndex(String followIndex,
Runnable handler,
Consumer<Exception> onFailure) {
OpenIndexRequest openIndexRequest = new OpenIndexRequest(followIndex);
OpenIndexRequest openIndexRequest = new OpenIndexRequest(followIndex).masterNodeTimeout(TimeValue.MAX_VALUE);
CheckedConsumer<OpenIndexResponse, Exception> onResponse = response -> handler.run();
followerClient.admin().indices().open(openIndexRequest, ActionListener.wrap(onResponse, onFailure));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,7 @@ private void updateMappings(Client leaderClient, Index leaderIndex, long leaderM
leaderIndexMetadata.getMappings().size() + "]";
MappingMetaData mappingMetaData = leaderIndexMetadata.getMappings().iterator().next().value;
if (mappingMetaData != null) {
final PutMappingRequest putMappingRequest = CcrRequests.putMappingRequest(followerIndex.getName(), mappingMetaData)
.masterNodeTimeout(TimeValue.timeValueMinutes(30));
final PutMappingRequest putMappingRequest = CcrRequests.putMappingRequest(followerIndex.getName(), mappingMetaData);
followerClient.admin().indices().putMapping(putMappingRequest).actionGet(ccrSettings.getRecoveryActionTimeout());
}
}
Expand Down

0 comments on commit 370d261

Please sign in to comment.