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

[BUG] Set index.number_of_replicas to null through index/_settings API doesn't honor cluster setting #14810

Open
chishui opened this issue Jul 18, 2024 · 5 comments
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing

Comments

@chishui
Copy link
Contributor

chishui commented Jul 18, 2024

Describe the bug

I tried to set index.number_of_replicas to null so that it will pick up default replica number configured for cluster.

PUT index/_settings
{
  "index": {
    "number_of_replicas": null
  }
}

It always sets index.number_of_replicas to 1. However, I configured cluster.default_number_of_replicas to 3, and when I create the index and not specify index.number_of_replicas, it will use 3 as default replica number.

Related component

Indexing

To Reproduce

  1. configure cluster replica number
PUT _cluster/settings
{
  "persistent" : {
    "cluster.default_number_of_replicas": 3
  }
}
  1. Create index
PUT index
{
  "settings": {
     "index": {
       "refresh_interval": "30s",
       "default_pipeline": "pipeline"
      },
      "number_of_shards": 1
    }
}
  1. Check index settings
GET index/_settings

it returns:
{
...
   "number_of_replicas": 3
}
  1. Update settings
PUT index/_settings
{
  "index": {
    "number_of_replicas": null
  }
}
  1. Check settings again, number_of_replicas becomes 1
GET index/_settings

it returns:
{
...
   "number_of_replicas": 1
}

Expected behavior

The default value of index.number_of_replicas should honor value of cluster setting cluster.default_number_of_replicas

Additional Details

Plugins
Please list all plugins currently enabled.

Screenshots
If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: all
  • Version 2.15

Additional context
Add any other context about the problem here.

@chishui chishui added bug Something isn't working untriaged labels Jul 18, 2024
@github-actions github-actions bot added the Indexing Indexing, Bulk Indexing and anything related to indexing label Jul 18, 2024
@chishui chishui changed the title [BUG] Set index.number_of_replicas to null through index/_settings API doesn't honor cluster.default_number_of_replicas [BUG] Set index.number_of_replicas to null through index/_settings API doesn't honor cluster setting Jul 18, 2024
@mgodwan
Copy link
Member

mgodwan commented Jul 22, 2024

Duplicate of #14783

@mgodwan mgodwan marked this as a duplicate of #14783 Jul 22, 2024
@mgodwan mgodwan closed this as completed Jul 22, 2024
@chishui
Copy link
Contributor Author

chishui commented Jul 23, 2024

@mgodwan this bug is different from #14783. #14783 is about create index API with replica parameter set to null and caused NPE, this is about update setting API with null and it doesn't honor the cluster replica configuration

@chishui
Copy link
Contributor Author

chishui commented Jul 25, 2024

Fixed in #14948

chishui added a commit to chishui/OpenSearch that referenced this issue Jul 26, 2024
chishui added a commit to chishui/OpenSearch that referenced this issue Aug 2, 2024
@sandeshkr419
Copy link
Contributor

@chishui Thanks for reporting and raising a fix for this.

I have my concern on what should be the number of replicas when null is supplied. Should null translate to default count of 3 or it should translate to no replica at all, that is 0.

I suggest that null should translate to 0 - implying that the user does not actually wants to set any replicas. User not supplying anything should only translate to default replica count.

What are your thoughts @mgodwan?

@chishui
Copy link
Contributor Author

chishui commented Aug 9, 2024

@sandeshkr419 thanks for the comment. If cluster setting is not configured, then 1 is the default replica number. The default number of 1 has been there and acknowledged by users for really long time. Setting it to 0 means user has no backup for their data and can potentially lose data if they don't explicitly configure the replica number.

chishui added a commit to chishui/OpenSearch that referenced this issue Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing
Projects
None yet
Development

No branches or pull requests

4 participants