Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove immediate operation retry after mapping update #38873

Merged
merged 1 commit into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -483,26 +483,16 @@ private static <T extends Engine.Result> void executeOnPrimaryWhileHandlingMappi
throws IOException {
T result = toExecute.get();
if (result.getResultType() == Engine.Result.Type.MAPPING_UPDATE_REQUIRED) {
// try to update the mappings and try again.
// try to update the mappings and mark the context as needing to try again.
try {
mappingUpdater.accept(result.getRequiredMappingUpdate());
context.markAsRequiringMappingUpdate();
} catch (Exception e) {
// failure to update the mapping should translate to a failure of specific requests. Other requests
// still need to be executed and replicated.
onComplete.accept(exceptionToResult.apply(e));
return;
}

// TODO - we can fall back to a wait for cluster state update but I'm keeping the logic the same for now
result = toExecute.get();

if (result.getResultType() == Engine.Result.Type.MAPPING_UPDATE_REQUIRED) {
// double mapping update. We assume that the successful mapping update wasn't yet processed on the node
// and retry the entire request again.
context.markAsRequiringMappingUpdate();
} else {
onComplete.accept(result);
}
} else {
onComplete.accept(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ public void testExecuteBulkIndexRequestWithMappingUpdates() throws Exception {

assertThat("mappings were \"updated\" once", updateCalled.get(), equalTo(1));

// Verify that the shard "executed" the operation twice
verify(shard, times(2)).applyIndexOperationOnPrimary(anyLong(), any(), any(), anyLong(), anyLong(), anyLong(), anyBoolean());
// Verify that the shard "executed" the operation once
verify(shard, times(1)).applyIndexOperationOnPrimary(anyLong(), any(), any(), anyLong(), anyLong(), anyLong(), anyBoolean());

when(shard.applyIndexOperationOnPrimary(anyLong(), any(), any(), anyLong(), anyLong(), anyLong(), anyBoolean()))
.thenReturn(success);
Expand All @@ -295,9 +295,9 @@ public void testExecuteBulkIndexRequestWithMappingUpdates() throws Exception {
(update, shardId, type) -> fail("should not have had to update the mappings"), () -> {});


// Verify that the shard "executed" the operation only once (2 for previous invocations plus
// Verify that the shard "executed" the operation only once (1 for previous invocations plus
// 1 for this execution)
verify(shard, times(3)).applyIndexOperationOnPrimary(anyLong(), any(), any(), anyLong(), anyLong(), anyLong(), anyBoolean());
verify(shard, times(2)).applyIndexOperationOnPrimary(anyLong(), any(), any(), anyLong(), anyLong(), anyLong(), anyBoolean());


BulkItemResponse primaryResponse = bulkShardRequest.items()[0].getPrimaryResponse();
Expand Down