Skip to content

Fix bugs with index.number_of_routing_shards setting. (#109656) #109658

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Rassyan
Copy link
Contributor

@Rassyan Rassyan commented Jun 13, 2024

Description

This PR addresses the issues outlined in issue #109656 regarding the index.number_of_routing_shards setting. The key fixes include:

  1. Default Value Alignment: Ensures that the default value of index.number_of_routing_shards matches the computed value of routing_num_shards.
  2. Immutability Enforcement: Prevents modification of index.number_of_routing_shards after index creation.
  3. API Consistency: Ensures that the _settings API correctly returns the value of index.number_of_routing_shards.

Self-Tests After Fix

Test 1: Default Value Alignment

DELETE test

PUT test
{
  "settings": {
    "index.number_of_shards": 3
  }
}

GET test/_settings?include_defaults&filter_path=**.*routing*shards
---
{
  "test": {
    "defaults": {
      "index": {
        "number_of_routing_shards": "768"
      }
    }
  }
}

GET /_cluster/state/metadata/test?filter_path=**.*routing*shards
---
{
  "metadata": {
    "indices": {
      "test": {
        "routing_num_shards": 768
      }
    }
  }
}

Test 2: Immutability Enforcement

POST test/_close

PUT test/_settings
{
  "settings": {
    "index.number_of_routing_shards": 6
  }
}
---
{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "final test setting [index.number_of_routing_shards], not updateable"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "final test setting [index.number_of_routing_shards], not updateable"
  },
  "status": 400
}

POST test/_open

GET test/_settings?include_defaults&filter_path=**.*routing*shards
---
{
  "test": {
    "defaults": {
      "index": {
        "number_of_routing_shards": "768"
      }
    }
  }
}

GET /_cluster/state/metadata/test?filter_path=**.*routing*shards
---
{
  "metadata": {
    "indices": {
      "test": {
        "routing_num_shards": 768
      }
    }
  }
}

Test 3: Explicit Setting Retrieval

DELETE test1

PUT test1
{
  "settings": {
    "index.number_of_shards": 3,
    "index.number_of_routing_shards": 6
  }
}

GET test1/_settings?include_defaults&filter_path=**.*routing*shards
---
{
  "test1": {
    "settings": {
      "index": {
        "number_of_routing_shards": "6"
      }
    }
  }
}

GET /_cluster/state/metadata/test1?filter_path=**.*routing*shards
---
{
  "metadata": {
    "indices": {
      "test1": {
        "routing_num_shards": 6,
        "settings": {
          "index": {
            "number_of_routing_shards": "6"
          }
        }
      }
    }
  }
}

Summary

This fix ensures that the index.number_of_routing_shards setting is correctly set and retrieved, and enforces its immutability post-creation. The routing_num_shards remains an internal setting, as originally designed, and does not require modification.

@elasticsearchmachine elasticsearchmachine added needs:triage Requires assignment of a team area label v8.15.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Jun 13, 2024
@jakelandis jakelandis added :Distributed Indexing/Distributed A catch all label for anything in the Distributed Indexing Area. Please avoid if you can. and removed needs:triage Requires assignment of a team area label labels Jun 13, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

@elasticsearchmachine elasticsearchmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Jun 13, 2024
@ywangd ywangd added :Data Management/Indices APIs APIs to create and manage indices and templates and removed :Distributed Indexing/Distributed A catch all label for anything in the Distributed Indexing Area. Please avoid if you can. labels Jun 16, 2024
@elasticsearchmachine elasticsearchmachine added Team:Data Management Meta label for data/management team and removed Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. labels Jun 16, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@Rassyan Rassyan force-pushed the fix-routing-shards-num-bugs branch from aea6013 to 70675f8 Compare July 11, 2024 06:29
@Rassyan
Copy link
Contributor Author

Rassyan commented Apr 21, 2025

Hi team 👋 @jakelandis @ywangd @mark-vieira
Just a friendly ping regarding this PR. It's been 9 months since submission and I wanted to check if someone could help review or share feedback when you get a chance.

Happy to make any adjustments needed. Thanks for your time! 🙌

@ywangd
Copy link
Member

ywangd commented Apr 28, 2025

@elastic/es-data-management Could you please help provide a response here? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Indices APIs APIs to create and manage indices and templates external-contributor Pull request authored by a developer outside the Elasticsearch team Team:Data Management Meta label for data/management team v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants