-
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
Add index block api #58094
Add index block api #58094
Conversation
Pinging @elastic/es-core-features (:Core/Features/Indices APIs) |
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 for adding this Yannick, I think this will be a neat API and it'll be nice to be able to use this from ILM. I left some comments for you. I have two additional thoughts:
- I think we should change
/{index}/_blocks/{block}
to/{index}/_block/{block}
. By and large the bulk of our APIs use singular verbs/nouns, and it reads better mentally (/foo/_blocks/read
can be thought of as "foo blocks reads", but/foo/_blocks/read_only
is awkward thought of as "foo blocks read onlys", it's nicer to think of/foo/_block/read_only
as "add the read_only block to foo"). It's also useful because we only support a single block, not a comma-separated or wildcard of blocks to add to the index. - How do these blocks work for a searchable snapshot index? Should we add a test for that? (the write block is pretty obviously not needed, but a read block may still be desired)
server/src/internalClusterTest/java/org/elasticsearch/blocks/SimpleBlocksIT.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/action/admin/indices/readonly/AddIndexBlockAction.java
Outdated
Show resolved
Hide resolved
.../org/elasticsearch/action/admin/indices/readonly/AddIndexBlockClusterStateUpdateRequest.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/action/admin/indices/readonly/AddIndexBlockRequest.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/action/admin/indices/readonly/AddIndexBlockRequest.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexStateService.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexStateService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexStateService.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexStateService.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexStateService.java
Show resolved
Hide resolved
@dakrone I've adapted |
@jrodewig can you help out with the docs here? (Feel free to directly push changes to this PR) |
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.
@ywelsch I made some changes to fix the docs CI test. However, I left some other feedback that should be addressed.
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.
:doh: Forgot you gave me permission to push the changes. I went ahead and added my suggestions. 😄
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 for the update Yannick, I made some more comments.
As an aside, it doesn't appear to me (though I am certainly not an expert in shard operation permits!) that this allows adding a read block and waiting for all query operations to finish before returning. Is that correct? Out of curiosity, how hard would that be to add? (It wouldn't have to be in this PR) It would be very useful for ILM operations if we had that ability
rest-api-spec/src/main/resources/rest-api-spec/api/indices.add_block.json
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException { | ||
builder.startObject(index.getName()); |
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.
I don't agree, I think if we go with consistency with our earlier APIs, then we would never eventually transition to the change. Since this is introducing a new API if we make the change now it's one less that we have to change in the future when we eventually have REST versioning.
We've discussed this a lot on the core/features team and always ended up with newly introduced APIs using the newer format, rather than matching the existing dynamically keyed format.
.../main/java/org/elasticsearch/action/admin/indices/readonly/TransportAddIndexBlockAction.java
Outdated
Show resolved
Hide resolved
...va/org/elasticsearch/action/admin/indices/readonly/TransportVerifyShardIndexBlockAction.java
Outdated
Show resolved
Hide resolved
...va/org/elasticsearch/action/admin/indices/readonly/TransportVerifyShardIndexBlockAction.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexStateService.java
Outdated
Show resolved
Hide resolved
index settings, or can be added using a dedicated API, which also ensures | ||
that, once successfully returning to the user, all shards of the index are | ||
properly accounting for the block, for example that all in-flight writes to | ||
an index have been completed after adding the write block. |
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.
Should we call out that this only applies to write operations, not read operations?
You're absolutely right here. The PR was overpromising in this regard (I initially started with a dedicated API to just allow adding a write block, which eventually got turned into this more general one here). I've adapted the docs to point out that we only guarantee this for write operations.
We could do something similar for reads as we do for writes, but there are a bigger number of cases / scenarios to consider and to handle accordingly. For example, how should his affect scrolls that have been opened before the block has been put in place (AFAICS we don't directly close the scroll context today). Similarly how should this handle long-running searches, or a fetch phase (where the query phase successfully executed)... |
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, thanks for iterating on it Yannick!
For example, how should his affect scrolls that have been opened before the block has been put in place (AFAICS we don't directly close the scroll context today). Similarly how should this handle long-running searches, or a fetch phase (where the query phase successfully executed)...
This is the exact scenario I was thinking about, in some places in ILM (like after a shrink) we do a swap-and-delete from the alias, but we have some unavoidable issues where the query may be in the middle of execution during the delete, we unfortunately don't have a way to wait until they are all done. Maybe in the future though?
I'm wondering if that's a situation which should rather be covered by a more resilient _search API, where it would retry searching on the new shards (after alias been swapped), similar to what's discussed in #56236 |
Adds an API for putting an index block in place, which also ensures for write blocks that, once successfully returning to the user, all shards of the index are properly accounting for the block, for example that all in-flight writes to an index have been completed after adding the write block. This API allows coordinating more complex workflows, where it is crucial that an index is no longer receiving writes after the API completes, useful for example when marking an index as read-only during an upgrade in order to reindex its documents.
The read-only-allow-delete block is not really under the user's control since Elasticsearch adds/removes it automatically. This commit removes support for it from the new API for adding blocks to indices that was introduced in elastic#58094.
* Forbid read-only-allow-delete block in blocks API The read-only-allow-delete block is not really under the user's control since Elasticsearch adds/removes it automatically. This commit removes support for it from the new API for adding blocks to indices that was introduced in #58094. * Missing xref * Reword paragraph on read-only-allow-delete block
The read-only-allow-delete block is not really under the user's control since Elasticsearch adds/removes it automatically. This commit removes support for it from the new API for adding blocks to indices that was introduced in #58094.
Adds an API for putting an index block in place, which also ensures for write blocks that, once successfully returning to the user, all shards of the index are properly accounting for the block, for example that all in-flight writes to an index have been completed after adding the write block.
This API allows coordinating more complex workflows, where it is crucial that an index is no longer receiving writes after the API completes, useful for example when marking an index as read-only during an upgrade in order to reindex its documents.
Note to reviewers: I will fix the docs in a later revision once we're all good on naming etc.
Also, HLRC support will only come later.