TransportUnfollowAction should increase settings version (#37859)
The TransportUnfollowAction updates the index settings but does not increase the settings version to reflect that change. This issue has been caught while working on the replication of closed indices (#33888). The IndexFollowingIT.testUnfollowIndex() started to fail and this specific assertion tripped. It does not happen on master branch today because index metadata for closed indices are never updated in IndexService instances, but this is something that is going to change with the replication of closed indices.
This commit is contained in:
parent
85acc11ef7
commit
f1f54e0f61
|
@ -105,18 +105,19 @@ public class TransportUnfollowAction extends TransportMasterNodeAction<UnfollowA
|
|||
}
|
||||
}
|
||||
|
||||
IndexMetaData.Builder newIMD = IndexMetaData.builder(followerIMD);
|
||||
// Remove index.xpack.ccr.following_index setting
|
||||
Settings.Builder builder = Settings.builder();
|
||||
builder.put(followerIMD.getSettings());
|
||||
builder.remove(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey());
|
||||
|
||||
newIMD.settings(builder);
|
||||
final IndexMetaData.Builder newIndexMetaData = IndexMetaData.builder(followerIMD);
|
||||
newIndexMetaData.settings(builder);
|
||||
newIndexMetaData.settingsVersion(followerIMD.getSettingsVersion() + 1);
|
||||
// Remove ccr custom metadata
|
||||
newIMD.removeCustom(Ccr.CCR_CUSTOM_METADATA_KEY);
|
||||
newIndexMetaData.removeCustom(Ccr.CCR_CUSTOM_METADATA_KEY);
|
||||
|
||||
MetaData newMetaData = MetaData.builder(current.metaData())
|
||||
.put(newIMD)
|
||||
.put(newIndexMetaData)
|
||||
.build();
|
||||
return ClusterState.builder(current)
|
||||
.metaData(newMetaData)
|
||||
|
|
|
@ -30,8 +30,10 @@ import static org.hamcrest.Matchers.nullValue;
|
|||
public class TransportUnfollowActionTests extends ESTestCase {
|
||||
|
||||
public void testUnfollow() {
|
||||
final long settingsVersion = randomNonNegativeLong();
|
||||
IndexMetaData.Builder followerIndex = IndexMetaData.builder("follow_index")
|
||||
.settings(settings(Version.CURRENT).put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true))
|
||||
.settingsVersion(settingsVersion)
|
||||
.numberOfShards(1)
|
||||
.numberOfReplicas(0)
|
||||
.state(IndexMetaData.State.CLOSE)
|
||||
|
@ -47,6 +49,7 @@ public class TransportUnfollowActionTests extends ESTestCase {
|
|||
IndexMetaData resultIMD = result.metaData().index("follow_index");
|
||||
assertThat(resultIMD.getSettings().get(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey()), nullValue());
|
||||
assertThat(resultIMD.getCustomData(Ccr.CCR_CUSTOM_METADATA_KEY), nullValue());
|
||||
assertThat(resultIMD.getSettingsVersion(), equalTo(settingsVersion + 1));
|
||||
}
|
||||
|
||||
public void testUnfollowIndexOpen() {
|
||||
|
|
Loading…
Reference in New Issue