Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/126840.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 126840
summary: Fix `PolicyStepsRegistry` cache concurrency issue
area: ILM+SLM
type: bug
issues:
- 118406
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ tests:
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
method: test {p0=transform/transforms_unattended/Test unattended put and start}
issue: https://github.com/elastic/elasticsearch/issues/120019
- class: org.elasticsearch.xpack.ilm.actions.SearchableSnapshotActionIT
method: testUpdatePolicyToAddPhasesYieldsInvalidActionsToBeSkipped
issue: https://github.com/elastic/elasticsearch/issues/118406
- class: org.elasticsearch.xpack.security.QueryableReservedRolesIT
method: testConfiguredReservedRolesAfterClosingAndOpeningIndex
issue: https://github.com/elastic/elasticsearch/issues/120127
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ Map<String, Map<Step.StepKey, Step>> getStepMap() {
public void update(IndexLifecycleMetadata meta) {
assert meta != null : "IndexLifecycleMetadata cannot be null when updating the policy steps registry";

// since the policies (may have) changed, the whole steps cache needs to be thrown out
cachedSteps.clear();

DiffableUtils.MapDiff<String, LifecyclePolicyMetadata, Map<String, LifecyclePolicyMetadata>> mapDiff = DiffableUtils.diff(
lifecyclePolicyMap,
meta.getPolicyMetadatas(),
Expand Down Expand Up @@ -163,6 +160,11 @@ public LifecyclePolicyMetadata read(StreamInput in, String key) {
}
}
}

// Since the policies (may have) changed, the whole steps cache needs to be thrown out.
// We do this after we update `lifecyclePolicyMap` to ensure `cachedSteps` does not contain outdated data.
// This means we may clear up-to-date data, but that's a lot better than the cache containing outdated entries indefinitely.
cachedSteps.clear();
}

/**
Expand Down
Loading