Skip to content

Commit a6e2a25

Browse files
committed
[CCR] AutoFollowCoordinator should tolerate that auto follow patterns may be removed
AutoFollowCoordinator should take into account that after auto following an index and while updating that a leader index has been followed, that the auto follow pattern may have been removed via delete auto follow patters api. Closes elastic#35480
1 parent 4a3d66c commit a6e2a25

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/CCRIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ public void testIndexFollowing() throws Exception {
128128
assertThat(unfollowResponse.isAcknowledged(), is(true));
129129
}
130130

131-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/35937")
132131
public void testAutoFollowing() throws Exception {
133132
CcrClient ccrClient = highLevelClient().ccr();
134133
PutAutoFollowPatternRequest putAutoFollowPatternRequest =

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinator.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,13 @@ static Function<ClusterState, ClusterState> recordLeaderIndexAsFollowFunction(St
394394
return currentState -> {
395395
AutoFollowMetadata currentAutoFollowMetadata = currentState.metaData().custom(AutoFollowMetadata.TYPE);
396396
Map<String, List<String>> newFollowedIndexUUIDS = new HashMap<>(currentAutoFollowMetadata.getFollowedLeaderIndexUUIDs());
397+
if (newFollowedIndexUUIDS.containsKey(name) == false) {
398+
// A delete auto follow pattern request can have removed the auto follow pattern while we want to update
399+
// the auto follow metadata with the fact that an index was successfully auto followed. If this
400+
// happens, we can just skip this step.
401+
return currentState;
402+
}
403+
397404
newFollowedIndexUUIDS.compute(name, (key, existingUUIDs) -> {
398405
assert existingUUIDs != null;
399406
List<String> newUUIDs = new ArrayList<>(existingUUIDs);

0 commit comments

Comments
 (0)