-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Improve Close Index Response #39687
Conversation
Pinging @elastic/es-distributed |
There was a problem hiding this 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
There was a problem hiding this 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.
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.
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?
There was a problem hiding this comment.
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.
@henningandersen I addressed your comments. Can you please give it another look? Thank you! |
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. I pushed 1c9ddf0.
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 <[email protected]>
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 <[email protected]>
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
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:
The response reports shard failures like:
Relates #33888