Skip to content

Commit

Permalink
Reset GatewayService flags before reroute
Browse files Browse the repository at this point in the history
It's possible (although very unlikely) that the `GatewayService`
recovers the state, then fails over to a new master with unrecovered
state, and then fails back to the original master, and only then
performs the reroute that resets the flags which would trigger another
state recovery attempt. This leaves the cluster in an unrecovered state
until the next cluster state update.

This commit resets the flags at the end of the recovery update rather
than waiting until after the reroute, allowing a subsequent election to
retry recovery again.

Closes elastic#98606
  • Loading branch information
DaveCTurner committed Aug 21, 2023
1 parent c331d92 commit de001ee
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -228,7 +228,8 @@ public void clusterStateProcessed(final ClusterState oldState, final ClusterStat
logger.info("recovered [{}] indices into cluster_state", newState.metadata().indices().size());
// reset flag even though state recovery completed, to ensure that if we subsequently become leader again based on a
// not-recovered state, that we again do another state recovery.
rerouteService.reroute("state recovered", Priority.NORMAL, ActionListener.running(GatewayService.this::resetRecoveredFlags));
resetRecoveredFlags();
rerouteService.reroute("state recovered", Priority.NORMAL, ActionListener.noop());
}

@Override
Expand Down

0 comments on commit de001ee

Please sign in to comment.