Skip to content

Fix system index mapping update for reindexed indices after migration#144782

Merged
alexey-ivanov-es merged 8 commits intoelastic:mainfrom
alexey-ivanov-es:fix/144764
Mar 26, 2026
Merged

Fix system index mapping update for reindexed indices after migration#144782
alexey-ivanov-es merged 8 commits intoelastic:mainfrom
alexey-ivanov-es:fix/144764

Conversation

@alexey-ivanov-es
Copy link
Contributor

@alexey-ivanov-es alexey-ivanov-es commented Mar 23, 2026

SystemIndexMappingUpdateService used projectMetadata.hasIndexAbstraction(d.getPrimaryIndex()) to collect system indices descriptors to check mappings, but then used state.metadata().index(descriptor.getPrimaryIndex()) to get IndexMetadata. This works with indices that were not reindexed, since their name is always the same as the system index's primary name, but after reindexing during migration, the index gains -reindexed-for-<version> suffix and has an alias with the primary name pointing to it. However, index method doesn't support aliases, therefore, IndexMetadata wasn't resolved and mappings were not checked.

This change fixes that by introducing use of indices lookup, if there is no metadata for the primary index.

Closes: #144764

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@elasticsearchmachine
Copy link
Collaborator

Hi @alexey-ivanov-es, I've created a changelog YAML for you.

@alexey-ivanov-es alexey-ivanov-es requested a review from a team March 23, 2026 16:47
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: fd09734f-0f65-464b-b031-3e89120c31fb

📥 Commits

Reviewing files that changed from the base of the PR and between 319b651 and c41b3cf.

📒 Files selected for processing (4)
  • docs/changelog/144782.yaml
  • server/src/internalClusterTest/java/org/elasticsearch/indices/SystemIndexMappingUpdateServiceIT.java
  • server/src/main/java/org/elasticsearch/indices/SystemIndexMappingUpdateService.java
  • server/src/test/java/org/elasticsearch/indices/SystemIndexMappingUpdateServiceTests.java

📝 Walkthrough

Walkthrough

This change addresses system index mapping updates for indices that have been reindexed during major version migrations. The SystemIndexMappingUpdateService now includes a helper method (getSystemIndexMetadata) that resolves system index metadata via alias lookup when the primary index name is not found directly. This allows the service to correctly identify and update mappings on reindexed indices, which are renamed with a suffix and pointed to by an alias. Supporting tests and a changelog entry were added to document the fix.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Changes directly address issue #144764: modified SystemIndexMappingUpdateService to resolve alias-based reindexed indices via indices lookup, added unit and integration tests validating the fix.
Out of Scope Changes check ✅ Passed All changes are scoped to system index mapping updates post-migration: service logic, unit tests, integration tests, and changelog entry—no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 🛠️ Update Documentation: Commit on current branch
  • 🛠️ Update Documentation: Create PR

Comment @coderabbitai help to get the list of available commands and usage tips.

*/
static State calculateIndexState(ProjectState state, SystemIndexDescriptor descriptor) {
final IndexMetadata indexMetadata = state.metadata().index(descriptor.getPrimaryIndex());
IndexMetadata indexMetadata = getSystemIndexMetadata(state, descriptor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is not final anymore, not sure if it's on purpose.

@alexey-ivanov-es alexey-ivanov-es merged commit 29d7e2a into elastic:main Mar 26, 2026
36 checks passed
@alexey-ivanov-es alexey-ivanov-es deleted the fix/144764 branch March 26, 2026 18:59
@alexey-ivanov-es alexey-ivanov-es restored the fix/144764 branch March 26, 2026 18:59
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
9.3
8.19 Commit could not be cherrypicked due to conflicts
9.2

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 144782

alexey-ivanov-es added a commit to alexey-ivanov-es/elasticsearch that referenced this pull request Mar 26, 2026
…elastic#144782)

SystemIndexMappingUpdateService used projectMetadata.hasIndexAbstraction(d.getPrimaryIndex()) to collect system indices descriptors to check mappings, but then used state.metadata().index(descriptor.getPrimaryIndex()) to get IndexMetadata. This works with indices that were not reindexed, since their name is always the same as the system index's primary name, but after reindexing during migration, the index gains -reindexed-for-<version> suffix and has an alias with the primary name pointing to it. However, index method doesn't support aliases, therefore, IndexMetadata wasn't resolved and mappings were not checked.

This change fixes that by introducing use of indices lookup, if there is no metadata for the primary index.
alexey-ivanov-es added a commit to alexey-ivanov-es/elasticsearch that referenced this pull request Mar 26, 2026
…elastic#144782)

SystemIndexMappingUpdateService used projectMetadata.hasIndexAbstraction(d.getPrimaryIndex()) to collect system indices descriptors to check mappings, but then used state.metadata().index(descriptor.getPrimaryIndex()) to get IndexMetadata. This works with indices that were not reindexed, since their name is always the same as the system index's primary name, but after reindexing during migration, the index gains -reindexed-for-<version> suffix and has an alias with the primary name pointing to it. However, index method doesn't support aliases, therefore, IndexMetadata wasn't resolved and mappings were not checked.

This change fixes that by introducing use of indices lookup, if there is no metadata for the primary index.
@alexey-ivanov-es alexey-ivanov-es deleted the fix/144764 branch March 26, 2026 19:49
alexey-ivanov-es added a commit that referenced this pull request Mar 26, 2026
…gration (#144782)

SystemIndexMappingUpdateService used projectMetadata.hasIndexAbstraction(d.getPrimaryIndex()) to collect system indices descriptors to check mappings, but then used state.metadata().index(descriptor.getPrimaryIndex()) to get IndexMetadata. This works with indices that were not reindexed, since their name is always the same as the system index's primary name, but after reindexing during migration, the index gains -reindexed-for-<version> suffix and has an alias with the primary name pointing to it. However, index method doesn't support aliases, therefore, IndexMetadata wasn't resolved and mappings were not checked.

This change fixes that by introducing use of indices lookup, if there is no metadata for the primary index.

(cherry picked from commit 29d7e2a)
@alexey-ivanov-es
Copy link
Contributor Author

8.19 backport: #145031

elasticsearchmachine pushed a commit that referenced this pull request Mar 26, 2026
…#144782) (#145026)

SystemIndexMappingUpdateService used projectMetadata.hasIndexAbstraction(d.getPrimaryIndex()) to collect system indices descriptors to check mappings, but then used state.metadata().index(descriptor.getPrimaryIndex()) to get IndexMetadata. This works with indices that were not reindexed, since their name is always the same as the system index's primary name, but after reindexing during migration, the index gains -reindexed-for-<version> suffix and has an alias with the primary name pointing to it. However, index method doesn't support aliases, therefore, IndexMetadata wasn't resolved and mappings were not checked.

This change fixes that by introducing use of indices lookup, if there is no metadata for the primary index.
elasticsearchmachine pushed a commit that referenced this pull request Mar 26, 2026
…gration (#144782) (#145031)

* [8.19] Fix system index mapping update for reindexed indices after migration (#144782)

SystemIndexMappingUpdateService used projectMetadata.hasIndexAbstraction(d.getPrimaryIndex()) to collect system indices descriptors to check mappings, but then used state.metadata().index(descriptor.getPrimaryIndex()) to get IndexMetadata. This works with indices that were not reindexed, since their name is always the same as the system index's primary name, but after reindexing during migration, the index gains -reindexed-for-<version> suffix and has an alias with the primary name pointing to it. However, index method doesn't support aliases, therefore, IndexMetadata wasn't resolved and mappings were not checked.

This change fixes that by introducing use of indices lookup, if there is no metadata for the primary index.

(cherry picked from commit 29d7e2a)

* Fix build
alexey-ivanov-es added a commit that referenced this pull request Mar 26, 2026
…ration (#144782) (#145025)

SystemIndexMappingUpdateService used projectMetadata.hasIndexAbstraction(d.getPrimaryIndex()) to collect system indices descriptors to check mappings, but then used state.metadata().index(descriptor.getPrimaryIndex()) to get IndexMetadata. This works with indices that were not reindexed, since their name is always the same as the system index's primary name, but after reindexing during migration, the index gains -reindexed-for-<version> suffix and has an alias with the primary name pointing to it. However, index method doesn't support aliases, therefore, IndexMetadata wasn't resolved and mappings were not checked.

This change fixes that by introducing use of indices lookup, if there is no metadata for the primary index.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged backport pending >bug :Core/Infra/System Indices Team:Core/Infra Meta label for core/infra team v8.19.14 v9.2.8 v9.3.3 v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System index mappings not be updated if the index migrated from the previous ES major version

3 participants