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] The split index's shards cannot be assigned because of the source index's index.blocks.read_only setting #4845

Closed
gaobinlong opened this issue Oct 20, 2022 · 2 comments
Labels
bug Something isn't working Indexing & Search v2.8.0 'Issues and PRs related to version v2.8.0' v3.0.0 Issues and PRs related to version 3.0.0

Comments

@gaobinlong
Copy link
Collaborator

gaobinlong commented Oct 20, 2022

Describe the bug
When executing Split API , if we set the index.blocks.read_only setting of the source index to true, then the Split API responds slowly and finally return an action_request_validation_exception with 400 status code, but the new splitted index is created and only part of the new shards are STARTED, so the new split index's health is red. By checking the log, it shows that the unassigned shards cannot be recovered because the new split index has a read_only block:
Caused by: org.opensearch.cluster.block.ClusterBlockException: index [index111] blocked by: [FORBIDDEN/5/index read-only (api)]

I think it means that the new spit index's settings are copied from the source index, so the index.blocks.read_only setting of the new spit index is true. After changing the setting to false and executing POST _cluster/reroute?retry_failed=true to retry recovering the unassigned shards, the new spit index's health then became green.

So, should we add more validations for Split & Shrink & Clone API ? Maybe we can throw an action_request_validation_exception with 400 when the source index's index.blocks.read_only or index.blocks.metadata setting was set to true.

Besides, why only parts of new spit index's shards are assigned and in STARTED status? That's really confused and there might be some other underlying problems.

To Reproduce
Steps to reproduce the behavior:

  1. Update the source index's index.blocks.read_only setting to true
PUT opensearch_dashboards_sample_data_ecommerce/_settings
{
  "index.blocks.read_only":true
}
  1. Executing the Split API
POST opensearch_dashboards_sample_data_ecommerce/_split/index111
{
  "settings":{
    "index.number_of_shards":6,
    "index.number_of_replicas":0
  }
}

the response is:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "action_request_validation_exception",
        "reason" : "Validation Failed: 1: index.number_of_shards is required for split operations;"
      }
    ],
    "type" : "action_request_validation_exception",
    "reason" : "Validation Failed: 1: index.number_of_shards is required for split operations;"
  },
  "status" : 400
}
  1. Check the new split index
GET _cat/shards/index111
GET index111/_recovery
GET _cluster/health/index111

we can see that only parts of the new shards are STARTED and the new index's health is red.

Expected behavior

Add more validations for Split & Shrink & Clone API to avoid the above situation.

Host/Environment (please complete the following information):

  • OS: macOS
  • Version: 12.5.1
    The opensearch version is 2.3.
@gaobinlong gaobinlong added bug Something isn't working untriaged labels Oct 20, 2022
@anasalkouz
Copy link
Member

@nandi-github Could you look into this?

@gaobinlong
Copy link
Collaborator Author

gaobinlong commented Dec 2, 2022

From the code I found that there is a block check, but it's useless because the new split index has not been created yet:

return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA_WRITE, request.getTargetIndexRequest().index());
.
So maybe we should check the MATADATA_WRITE block when creating the new split index, like this:
if (state.blocks().indexBlocked(ClusterBlockLevel.WRITE, sourceIndex) == false) {
.

I think we can throw an illegalArgumentException if the new split index has a METADATA_WRITE block because it will prevent the new shards from being allocated , there are two situations the new split index may have a METADATA_WRITE block:

  1. User sets index setting index.blocks.read_only or index.blocks.metadata to true explicitly in the API's request body parameter settings.
  2. The source index's setting index.blocks.read_only is true, and user does not set index setting index.blocks.read_only to false explicitly in the API's request body(if user does so, the setting in the request body will overwrite the setting copied from the source index).

For another situation, if the source index's setting index.blocks.metadata is true, a cluster_block_exception will be thrown early in getting source index's stats, so the new split index will not have a METADATA_WRITE block.

@nandi-github may I know your opinion about this?

gaobinlong added a commit to gaobinlong/OpenSearch that referenced this issue Mar 21, 2023
reta pushed a commit that referenced this issue May 17, 2023
* Add more index blocks check for resize APIs (#4845)

Signed-off-by: Gao Binlong <[email protected]>

* modify change log

Signed-off-by: Gao Binlong <[email protected]>

* Rewording the error message

Signed-off-by: Gao Binlong <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
@reta reta added v3.0.0 Issues and PRs related to version 3.0.0 v2.8.0 'Issues and PRs related to version v2.8.0' labels May 17, 2023
opensearch-trigger-bot bot pushed a commit that referenced this issue May 17, 2023
* Add more index blocks check for resize APIs (#4845)

Signed-off-by: Gao Binlong <[email protected]>

* modify change log

Signed-off-by: Gao Binlong <[email protected]>

* Rewording the error message

Signed-off-by: Gao Binlong <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
(cherry picked from commit 170dcef)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
reta added a commit that referenced this issue May 18, 2023
…7601)

* Add more index blocks check for resize APIs (#4845) (#6774)

* Add more index blocks check for resize APIs (#4845)

Signed-off-by: Gao Binlong <[email protected]>

* modify change log

Signed-off-by: Gao Binlong <[email protected]>

* Rewording the error message

Signed-off-by: Gao Binlong <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
(cherry picked from commit 170dcef)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Update REST API spec tests version ranges

Signed-off-by: Andriy Redko <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: Andriy Redko <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Andriy Redko <[email protected]>
@reta reta closed this as completed May 18, 2023
stephen-crawford pushed a commit to stephen-crawford/OpenSearch that referenced this issue May 31, 2023
…opensearch-project#6774)

* Add more index blocks check for resize APIs (opensearch-project#4845)

Signed-off-by: Gao Binlong <[email protected]>

* modify change log

Signed-off-by: Gao Binlong <[email protected]>

* Rewording the error message

Signed-off-by: Gao Binlong <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this issue Apr 25, 2024
…opensearch-project#6774)

* Add more index blocks check for resize APIs (opensearch-project#4845)

Signed-off-by: Gao Binlong <[email protected]>

* modify change log

Signed-off-by: Gao Binlong <[email protected]>

* Rewording the error message

Signed-off-by: Gao Binlong <[email protected]>

---------

Signed-off-by: Gao Binlong <[email protected]>
Signed-off-by: Shivansh Arora <[email protected]>
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 & Search v2.8.0 'Issues and PRs related to version v2.8.0' v3.0.0 Issues and PRs related to version 3.0.0
Projects
None yet
Development

No branches or pull requests

4 participants