-
Notifications
You must be signed in to change notification settings - Fork 25.4k
Run TransportGetMappingsAction
on local node
#122921
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
Conversation
This action solely needs the cluster state, it can run on any node. Additionally, it needs to be cancellable to avoid doing unnecessary work after a client failure or timeout. Relates elastic#101805
Pinging @elastic/es-data-management (Team:Data Management) |
Hi @nielsbauman, I've created a changelog YAML for 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.
Relates to #120982
import org.elasticsearch.tasks.CancellableTask; | ||
import org.elasticsearch.tasks.Task; | ||
import org.elasticsearch.tasks.TaskId; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
public class GetMappingsRequest extends ClusterInfoRequest<GetMappingsRequest> { | ||
public class GetMappingsRequest extends LocalClusterStateRequest implements IndicesRequest.Replaceable { |
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.
Similar to #122885, this also gets rid of the ClusterInfo
abstraction.
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 after the cancellation check has been added (and perhaps add a test for it)
} | ||
|
||
@Override | ||
protected void doMasterOperation( | ||
protected void localClusterStateOperation( |
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.
This one is missing a call to ((CancellableTask) task).ensureNotCancelled();
somewhere
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.
(and perhaps add a test for it)
I already added a test:
Lines 112 to 115 in 4ee9ce3
public void testGetMappingsCancellation() { | |
createIndex("test"); | |
runRestActionCancellationTest(new Request(HttpGet.METHOD_NAME, "/test/_mappings"), GetMappingsAction.NAME); | |
} |
I think the reason the test isn't failing is that we already check for the task cancellation right before we execute this method:
Lines 86 to 88 in afff39e
if (task instanceof CancellableTask cancellableTask && cancellableTask.notifyIfCancelled(listener)) { | |
return; | |
} |
In other words, all the
((CancellableTask) task).ensureNotCancelled()
s I've added in the other classes aren't super valuable (in most places). They're not hurting anything, but they're not super valuable either.
I'll add it to this method too, for consistency, but let me know what you think about all this.
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 was viewing the ((CancellableTask) task).ensureNotCancelled()
call as a way to do a check prior to some (semi-)expensive work, to avoid doing it if it was going to be thrown away anyway. It seems like it would still have some value there, though only a little, as you say.
I'm fine either way, so I'll leave it to you whether to include them or not.
@elasticmachine update branch |
@elasticmachine update branch |
"deprecated":{ | ||
"version":"7.8.0", | ||
"description":"This parameter is a no-op and field mappings are always retrieved locally." | ||
} | ||
"deprecated":true |
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.
Was there a specific reason to remove the description and version?
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.
Tbh, the reason is that I didn't add a description and version to any of the actions I converted similarly already because I didn't know they existed. It didn't seem worth it to go back and update all the previous ones to include a description and version, so I went for consistency here. Do you think it is worth to go back and update the previous ones to specify a description and version?
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.
No that's fine, especially as we're trying to move away from manually editing rest-api-spec. Thanks for the explanation!
This action solely needs the cluster state, it can run on any node. Additionally, it needs to be cancellable to avoid doing unnecessary work after a client failure or timeout.
Relates #101805