Skip to content

Commit 58ac8a0

Browse files
committed
Clear out the cache entirely on master->non-master
1 parent 92346ef commit 58ac8a0

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ public void clusterChanged(ClusterChangedEvent event) {
303303
} else {
304304
// we were the master, and now we aren't
305305
cancelJob();
306+
policyRegistry.clear();
306307
}
307308
}
308309

x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/PolicyStepsRegistry.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ public void delete(Index deleted) {
163163
cachedSteps.remove(deleted);
164164
}
165165

166+
/**
167+
* Clear internal maps that were populated by update (and others).
168+
*/
169+
public void clear() {
170+
// this is potentially large, so it's important to clear it
171+
cachedSteps.clear();
172+
// these are relatively small, but there's no harm in clearing them
173+
lifecyclePolicyMap.clear();
174+
firstStepMap.clear();
175+
stepMap.clear();
176+
}
177+
166178
/**
167179
* Return all ordered steps for the current policy for the index. Does not
168180
* resolve steps using the phase caching, but only for the currently existing policy.

0 commit comments

Comments
 (0)