Skip to content

Commit

Permalink
Make soft-deletes settings final (#33172)
Browse files Browse the repository at this point in the history
For now, we do not support changing the soft-deletes setting even with
closed indices. Therefore we should make it a final setting.

Relates #29530
  • Loading branch information
dnhatn committed Aug 28, 2018
1 parent 1956ecc commit 3e879b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public final class IndexSettings {
* Specifies if the index should use soft-delete instead of hard-delete for update/delete operations.
*/
public static final Setting<Boolean> INDEX_SOFT_DELETES_SETTING =
Setting.boolSetting("index.soft_deletes.enabled", true, Property.IndexScope);
Setting.boolSetting("index.soft_deletes.enabled", true, Property.IndexScope, Property.Final);

/**
* Controls how many soft-deleted documents will be kept around before being merged away. Keeping more deleted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,4 +607,12 @@ public void testQueryDefaultField() {
);
assertThat(index.getDefaultFields(), equalTo(Arrays.asList("body", "title")));
}

public void testUpdateSoftDeletesFails() {
IndexScopedSettings settings = new IndexScopedSettings(Settings.EMPTY, IndexScopedSettings.BUILT_IN_INDEX_SETTINGS);
IllegalArgumentException error = expectThrows(IllegalArgumentException.class, () ->
settings.updateSettings(Settings.builder().put("index.soft_deletes.enabled", randomBoolean()).build(),
Settings.builder(), Settings.builder(), "index"));
assertThat(error.getMessage(), equalTo("final index setting [index.soft_deletes.enabled], not updateable"));
}
}

0 comments on commit 3e879b4

Please sign in to comment.