Improve Close Index Response#39687
Conversation
|
Pinging @elastic/es-distributed |
ywelsch
left a comment
There was a problem hiding this comment.
Looking good. Can @henningandersen give this a look as well? Thank you
henningandersen
left a comment
There was a problem hiding this comment.
Thanks @dnhatn , I left a few comments, my primary concern is the comment on handling when closeRoutingTable skips indices.
server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java
Outdated
Show resolved
Hide resolved
| .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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Good observation :). I pushed 434696b to report error if closing block disappeared.
|
@henningandersen I addressed your comments. Can you please give it another look? Thank you! |
| CloseIndexResponse() { | ||
| } | ||
|
|
||
| public CloseIndexResponse(final boolean acknowledged, final boolean shardsAcknowledged) { |
There was a problem hiding this comment.
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.
server/src/test/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponseTests.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponseTests.java
Outdated
Show resolved
Hide resolved
# Conflicts: # server/src/test/java/org/elasticsearch/indices/state/CloseIndexIT.java
|
@ywelsch @henningandersen Thanks for reviewing. |
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>
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>
Relates elastic#39687
The CloseIndexResponse was improved in #39687; this commit exposes it in the HLRC.
Relates: #4001 Relates: elastic/elasticsearch#39687 This commit adds shards_acknowledged and indices resuls to CloseIndexResponse.
) Relates: #4001 Relates: elastic/elasticsearch#39687 This commit adds shards_acknowledged and indices resuls to CloseIndexResponse.
) Relates: #4001 Relates: elastic/elasticsearch#39687 This commit adds shards_acknowledged and indices resuls to CloseIndexResponse. (cherry picked from commit 169b784)
This changes the
CloseIndexResponseso 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:
The response reports shard failures like:
Relates #33888