Skip to content

Enable soft-deletes by default for 7.0+ indices #38929

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

Merged
merged 4 commits into from
Feb 25, 2019

Conversation

dnhatn
Copy link
Member

@dnhatn dnhatn commented Feb 14, 2019

Today when users upgrade to 7.0, existing indices will automatically switch to soft-deletes without an opt-out option. With this change, we only enable soft-deletes by default for new indices.

Relates #36141

@dnhatn dnhatn added >enhancement v7.0.0 :Distributed Indexing/Distributed A catch all label for anything in the Distributed Indexing Area. Please avoid if you can. v8.0.0 v7.2.0 labels Feb 14, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

Copy link
Member

@jasontedor jasontedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left a nit. Thanks for picking this up.

Copy link
Contributor

@ywelsch ywelsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IndexSettings defines softDeleteEnabled using softDeleteEnabled = version.onOrAfter(Version.V_6_5_0) && scopedSettings.get(INDEX_SOFT_DELETES_SETTING);. Can you move that version check to the same place here?

Can you also rewrite the soft-deletes check in TransportPutFollowAction.createFollowerIndex to something like

if (IndexSettings.INDEX_SOFT_DELETES_SETTING.get(leaderIndexMetaData.getSettings()) == false) {

and check all usages of the soft-deletes setting (this seems to be a bit of a mess, there's another one in AutoFollowCoordinator as well). Thank you.

public static final Setting<Boolean> INDEX_SOFT_DELETES_SETTING =
Setting.boolSetting("index.soft_deletes.enabled", true, Property.IndexScope, Property.Final);
public static final Setting<Boolean> INDEX_SOFT_DELETES_SETTING = Setting.boolSetting("index.soft_deletes.enabled",
settings -> Boolean.toString(IndexMetaData.SETTING_INDEX_VERSION_CREATED.get(settings).onOrAfter(Version.V_7_0_0)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if all unit tests are setting this correctly. If the setting is absent, we could perhaps assume that soft-deletes are enabled, instead of disabled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we create IndexMetadata without this setting I think it will barf. so I think we are good.

@dnhatn
Copy link
Member Author

dnhatn commented Feb 15, 2019

@ywelsch Thanks for looking.

IndexSettings defines softDeleteEnabled using softDeleteEnabled = version.onOrAfter(Version.V_6_5_0) && scopedSettings.get(INDEX_SOFT_DELETES_SETTING);. Can you move that version check to the same place here?

This requires a follow-up because we don't pass the Settings instance while parsing the value. However, I will add a Setting Validator to ensure that only 6.5+ indices have this setting true.

Can you also rewrite the soft-deletes check in TransportPutFollowAction.createFollowerIndex to something like

if (IndexSettings.INDEX_SOFT_DELETES_SETTING.get(leaderIndexMetaData.getSettings()) == false) {

and check all usages of the soft-deletes setting (this seems to be a bit of a mess, there's another one in AutoFollowCoordinator as well)

Sorry, this was on my check-list when I was working on the PR, but somehow I missed it.

I wonder if all unit tests are setting this correctly. If the setting is absent, we could perhaps assume that soft-deletes are enabled, instead of disabled.

I will use a Setting Validator to ensure that the index.version.created is always set.

Can you please have another look?

@dnhatn
Copy link
Member Author

dnhatn commented Feb 15, 2019

@jasontedor I am trying to add a Setting Validator to the soft-deletes setting. The soft-deletes validation depends on the index_created_version, but a Validator requires the setting and its dependencies have the same type. Do you have any suggestion to lift this restriction?

Copy link
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

public static final Setting<Boolean> INDEX_SOFT_DELETES_SETTING =
Setting.boolSetting("index.soft_deletes.enabled", true, Property.IndexScope, Property.Final);
public static final Setting<Boolean> INDEX_SOFT_DELETES_SETTING = Setting.boolSetting("index.soft_deletes.enabled",
settings -> Boolean.toString(IndexMetaData.SETTING_INDEX_VERSION_CREATED.get(settings).onOrAfter(Version.V_7_0_0)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we create IndexMetadata without this setting I think it will barf. so I think we are good.

@dnhatn dnhatn requested a review from ywelsch February 25, 2019 17:19
Copy link
Contributor

@ywelsch ywelsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Let's get this in

@dnhatn
Copy link
Member Author

dnhatn commented Feb 25, 2019

@jasontedor @ywelsch @s1monw Thanks for reviewing!

@dnhatn dnhatn merged commit 9af8113 into elastic:master Feb 25, 2019
@dnhatn dnhatn deleted the soft-deletes-default branch February 25, 2019 19:57
dnhatn added a commit that referenced this pull request Feb 25, 2019
Today when users upgrade to 7.0, existing indices will automatically
switch to soft-deletes without an opt-out option. With this change, 
we only enable soft-deletes by default for new indices.

Relates #36141
dnhatn added a commit that referenced this pull request Feb 26, 2019
Today when users upgrade to 7.0, existing indices will automatically
switch to soft-deletes without an opt-out option. With this change, 
we only enable soft-deletes by default for new indices.

Relates #36141
@jakelandis jakelandis removed the v8.0.0 label Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Indexing/Distributed A catch all label for anything in the Distributed Indexing Area. Please avoid if you can. >enhancement v7.0.0-rc2 v7.2.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants