Skip to content

Watcher history created as index with wrong mapping instead of data stream after 8.0 upgrade #85043

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

Closed
henrikno opened this issue Mar 16, 2022 · 2 comments · Fixed by #85287
Closed
Labels

Comments

@henrikno
Copy link
Contributor

henrikno commented Mar 16, 2022

Elasticsearch Version

8.0.1

Installed Plugins

No response

Java Version

bundled

OS Version

Elastic Cloud

Problem Description

After upgrading from 7.17 to 8.0.1 we noticed that some watches would not write their history.
The ES logs has many log lines similar to
[instance-0000000115] watch history could not be written [mywatch_5a0585ef-b8b1-4526-8b24-9fb9bf58981d-2022-03-15T11:29:32.801579308Z], failure [org.elasticsearch.index.mapper.MapperParsingException: failed to parse]

I noticed that .watcher-history-16 has the wrong mapping as everything just has default .text+.keyword, and the index template has a lot more specific fields. But the index template applies to a data stream, but .watcher-history-16 got created as an index, so the template didn't apply. It should have been created as a data stream after #64252, but somehow it didn't.

Steps to Reproduce

(unconfirmed)
Create a 7.17 cluster with multiple nodes
Create multiple watches that fire rapidly.
Upgrade ES to 8.x
.watcher-history-16 should be created as data stream, but got created as an index.

I tried it with a simple cluster and one watch firing every second and it upgraded to datastream, so it might be a race condition or depend on how many watches/how many nodes (we have ~80 watches/12 nodes)

Logs (if relevant)

No response

This looks a bit similar to #56732 except now that it's a data stream it won't be "fixed" by waiting until roll over.

@henrikno henrikno added >bug needs:triage Requires assignment of a team area label labels Mar 16, 2022
@elasticmachine elasticmachine added the Team:Data Management Meta label for data/management team label Mar 16, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@DJRickyB DJRickyB removed the needs:triage Requires assignment of a team area label label Mar 22, 2022
@jakelandis
Copy link
Contributor

I believe this is caused by #82395 , which is a reaction to #82109. It's hard to follow the history, but there is indeed a race condition in the cluster for when Watcher can start and when all of the needed resources such as index templates are in place. We can't simply revert #82395 since it would re-introduce the worse side of this race condition - silently stopping Watcher until a manual restart or changes to the shard allocation.

Attempts to mitigate a related issue was introduced on #69147 and since upgrades now require 7.last I think the requirement to upgrade the template on the master node might be unnecessary and no longer requiring the master node might be the fix here. I assume (not verified) that this can only happen if a Watcher node is upgraded before the master node.

Not a great workaround ... but if you delete the index after the cluster is fully upgraded it will be recreated properly as the data stream with the correct mappings.

jakelandis added a commit that referenced this issue Mar 23, 2022
The master node was required to install Watcher index templates 
in earlier versions of 7.x to ensure that the master node was aware of
composable index templates. 

When upgrading to 8.x this is no longer an issue since all upgrade paths
require elder version of Elasticsearch to be on a version that is aware of 
composable index templates. 

This should fix #85043 by 
ensuring that the watcher history index template is always in place prior
to it's intended usage irregardless of the order of which nodes are upgraded.
jakelandis added a commit to jakelandis/elasticsearch that referenced this issue Mar 23, 2022
…5287)

The master node was required to install Watcher index templates 
in earlier versions of 7.x to ensure that the master node was aware of
composable index templates. 

When upgrading to 8.x this is no longer an issue since all upgrade paths
require elder version of Elasticsearch to be on a version that is aware of 
composable index templates. 

This should fix elastic#85043 by 
ensuring that the watcher history index template is always in place prior
to it's intended usage irregardless of the order of which nodes are upgraded.
elasticsearchmachine pushed a commit that referenced this issue Mar 23, 2022
…85294)

The master node was required to install Watcher index templates 
in earlier versions of 7.x to ensure that the master node was aware of
composable index templates. 

When upgrading to 8.x this is no longer an issue since all upgrade paths
require elder version of Elasticsearch to be on a version that is aware of 
composable index templates. 

This should fix #85043 by 
ensuring that the watcher history index template is always in place prior
to it's intended usage irregardless of the order of which nodes are upgraded.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants