-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Add small optimizations to PUT _component_template
API
#135644
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
base: main
Are you sure you want to change the base?
Conversation
By moving component template normalization to the transport action, we can perform an equality check on the component template before creating a cluster state update task. This reduces the load on the master/cluster state update thread for no-op update requests. We still need to perform the equality check in the cluster state update task, as the cluster state could have been updated after we performed the check in the transport action. But avoiding a cluster state update task altogether in some cases is worth adding the check to the transport action. Additionally, by making some small refactorings in `MetadataIndexTemplateService#addComponentTemplate` we avoid building some objects unnecessarily and improve readability.
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.
All the added lines in this class are solely from moving the tests over from MetadataIndexTemplateServiceTests
.
// These two validation checks are only scoped to the component template itself (and don't depend on any other entities in the | ||
// cluster state) and could thus be done in the transport action. However, since we're parsing mappings here, we shouldn't be doing | ||
// it directly on the transport thread. Instead, we should fork to a different threadpool (management/generic). | ||
validateTemplate(finalComponentTemplate.template().settings(), finalComponentTemplate.template().mappings(), indicesService); | ||
validate(name, finalComponentTemplate.template(), List.of(), null); |
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 experimented with moving these two validations to the transport action, but since the Distributed Coordination team advised running them on the management or generic threadpool, I decided to leave it as future work. In terms of overall processing, we wouldn't save much. The only/main win would be that we avoid adding a cluster state update task in case the validation fails.
Also worth noting is that we potentially do more (heavier) mappings validation in validateIndexTemplateV2
below. Although #135457 helps reduce that in a lot of cases.
By moving component template normalization to the transport action, we can perform an equality check on the component template before creating a cluster state update task. This reduces the load on the master/cluster state update thread for no-op update requests. We still need to perform the equality check in the cluster state update task, as the cluster state could have been updated after we performed the check in the transport action. But avoiding a cluster state update task altogether in some cases is worth adding the check to the transport action.
Additionally, by making some small refactorings in
MetadataIndexTemplateService#addComponentTemplate
we avoid building some objects unnecessarily and improve readability.The number of changed lines looks scary, but most "changed" lines are only moving tests from one class to another.
Also see #135457 for another (bigger) optimization in component templates.