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

Improve Close Index Response #39687

Merged
merged 11 commits into from
May 23, 2019
Merged

Conversation

tlrx
Copy link
Member

@tlrx tlrx commented Mar 5, 2019

This changes the CloseIndexResponse so that it reports closing result for each index. Shard failures or exception are also reported per index, and the global acknowledgment flag is computed from the index results only.

The response looks like:

{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "indices" : {
    "docs" : {
      "closed" : true
    }
  }
}

The response reports shard failures like:

{
  "acknowledged" : false,
  "shards_acknowledged" : false,
  "indices" : {
    "docs-1" : {
      "closed" : true
    },
    "docs-2" : {
      "closed" : false,
      "shards" : {
        "1" : {
          "failures" : [
            {
              "shard" : 1,
              "index" : "docs-2",
              "status" : "BAD_REQUEST",
              "reason" : {
                "type" : "index_closed_exception",
                "reason" : "closed",
                "index_uuid" : "JFmQwr_aSPiZbkAH_KEF7A",
                "index" : "docs-2"
              }
            }
          ]
        }
      }
    },
    "docs-3" : {
      "closed" : true
    }
  }
}

Relates #33888

@tlrx tlrx added >enhancement :Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. v8.0.0 labels Mar 5, 2019
@tlrx tlrx requested a review from ywelsch March 5, 2019 10:01
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

@tlrx tlrx mentioned this pull request Apr 3, 2019
50 tasks
@dnhatn dnhatn marked this pull request as ready for review April 18, 2019 18:37
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.

Looking good. Can @henningandersen give this a look as well? Thank you

Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

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

Thanks @dnhatn , I left a few comments, my primary concern is the comment on handling when closeRoutingTable skips indices.

.map(result -> result.getKey().getName())
.filter(index -> newState.routingTable().hasIndex(index))
final List<IndexResult> indices = new ArrayList<>(results.values());
final boolean acknowledged = indices.stream().noneMatch(IndexResult::hasFailures);
Copy link
Contributor

Choose a reason for hiding this comment

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

In closeRoutingTable, we check for:

currentState.blocks().hasIndexBlock(index.getName(), closingBlock) == false

I think this will not be matched anymore by this acknowledged check, meaning acknowledged would be true afterwards?

Also, I would think that if the block was gone and the index thus is left open, we should see a failure for it in the response?

Copy link
Member

Choose a reason for hiding this comment

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

Good observation :). I pushed 434696b to report error if closing block disappeared.

@ywelsch ywelsch added the v7.2.0 label May 16, 2019
@dnhatn
Copy link
Member

dnhatn commented May 20, 2019

@henningandersen I addressed your comments. Can you please give it another look? Thank you!

@dnhatn dnhatn added v7.3.0 and removed v7.2.0 labels May 21, 2019
Copy link
Contributor

@henningandersen henningandersen 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 class CloseIndexResponse extends ShardsAcknowledgedResponse {

private List<IndexResult> indices;

CloseIndexResponse() {
}

public CloseIndexResponse(final boolean acknowledged, final boolean shardsAcknowledged) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe we should remove this constructor to ensure it is no longer used? I personally prefer to let the caller explicitly pass the empty list, but this may be personal preference so feel free to omit.

Copy link
Member

Choose a reason for hiding this comment

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

+1. I pushed 1c9ddf0.

@dnhatn
Copy link
Member

dnhatn commented May 23, 2019

@ywelsch @henningandersen Thanks for reviewing.

@dnhatn dnhatn merged commit 81f3b5d into elastic:master May 23, 2019
dnhatn pushed a commit to dnhatn/elasticsearch that referenced this pull request May 25, 2019
This changes the `CloseIndexResponse` so that it reports closing result
for each index. Shard failures or exception are also reported per index,
and the global acknowledgment flag is computed from the index results
only.

The response looks like:
```
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "indices" : {
    "docs" : {
      "closed" : true
    }
  }
}
```

The response reports shard failures like:
```
{
  "acknowledged" : false,
  "shards_acknowledged" : false,
  "indices" : {
    "docs-1" : {
      "closed" : true
    },
    "docs-2" : {
      "closed" : false,
      "shards" : {
        "1" : {
          "failures" : [
            {
              "shard" : 1,
              "index" : "docs-2",
              "status" : "BAD_REQUEST",
              "reason" : {
                "type" : "index_closed_exception",
                "reason" : "closed",
                "index_uuid" : "JFmQwr_aSPiZbkAH_KEF7A",
                "index" : "docs-2"
              }
            }
          ]
        }
      }
    },
    "docs-3" : {
      "closed" : true
    }
  }
}
```

Co-authored-by: Tanguy Leroux <tlrx.dev@gmail.com>
dnhatn pushed a commit that referenced this pull request May 25, 2019
This changes the `CloseIndexResponse` so that it reports closing result
for each index. Shard failures or exception are also reported per index,
and the global acknowledgment flag is computed from the index results
only.

The response looks like:
```
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "indices" : {
    "docs" : {
      "closed" : true
    }
  }
}
```

The response reports shard failures like:
```
{
  "acknowledged" : false,
  "shards_acknowledged" : false,
  "indices" : {
    "docs-1" : {
      "closed" : true
    },
    "docs-2" : {
      "closed" : false,
      "shards" : {
        "1" : {
          "failures" : [
            {
              "shard" : 1,
              "index" : "docs-2",
              "status" : "BAD_REQUEST",
              "reason" : {
                "type" : "index_closed_exception",
                "reason" : "closed",
                "index_uuid" : "JFmQwr_aSPiZbkAH_KEF7A",
                "index" : "docs-2"
              }
            }
          ]
        }
      }
    },
    "docs-3" : {
      "closed" : true
    }
  }
}
```

Co-authored-by: Tanguy Leroux <tlrx.dev@gmail.com>
dnhatn added a commit that referenced this pull request May 25, 2019
gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this pull request May 27, 2019
This changes the `CloseIndexResponse` so that it reports closing result
for each index. Shard failures or exception are also reported per index,
and the global acknowledgment flag is computed from the index results
only.

The response looks like:
```
{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "indices" : {
    "docs" : {
      "closed" : true
    }
  }
}
```

The response reports shard failures like:
```
{
  "acknowledged" : false,
  "shards_acknowledged" : false,
  "indices" : {
    "docs-1" : {
      "closed" : true
    },
    "docs-2" : {
      "closed" : false,
      "shards" : {
        "1" : {
          "failures" : [
            {
              "shard" : 1,
              "index" : "docs-2",
              "status" : "BAD_REQUEST",
              "reason" : {
                "type" : "index_closed_exception",
                "reason" : "closed",
                "index_uuid" : "JFmQwr_aSPiZbkAH_KEF7A",
                "index" : "docs-2"
              }
            }
          ]
        }
      }
    },
    "docs-3" : {
      "closed" : true
    }
  }
}
```

Co-authored-by: Tanguy Leroux <tlrx.dev@gmail.com>
gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this pull request May 27, 2019
tlrx added a commit that referenced this pull request Jul 24, 2019
The CloseIndexResponse was improved in #39687; this commit 
exposes it in the HLRC.
tlrx added a commit that referenced this pull request Jul 24, 2019
The CloseIndexResponse was improved in #39687; this commit
exposes it in the HLRC.

Backport of #44349 to 7.x.
polyfractal pushed a commit to polyfractal/elasticsearch that referenced this pull request Jul 29, 2019
The CloseIndexResponse was improved in elastic#39687; this commit 
exposes it in the HLRC.
russcam added a commit to elastic/elasticsearch-net that referenced this pull request Sep 2, 2019
Relates: #4001
Relates: elastic/elasticsearch#39687

This commit adds shards_acknowledged and indices resuls to CloseIndexResponse.
russcam added a commit to elastic/elasticsearch-net that referenced this pull request Sep 4, 2019
)

Relates: #4001
Relates: elastic/elasticsearch#39687

This commit adds shards_acknowledged and indices resuls to CloseIndexResponse.
russcam added a commit to elastic/elasticsearch-net that referenced this pull request Sep 4, 2019
)

Relates: #4001
Relates: elastic/elasticsearch#39687

This commit adds shards_acknowledged and indices resuls to CloseIndexResponse.

(cherry picked from commit 169b784)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/Distributed A catch all label for anything in the Distributed Area. If you aren't sure, use this one. >enhancement v7.3.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants