Browse Source

Become candidate on publication failure (#96490)

If the publication fails before starting (e.g. due to one of the
precondition checks in `CoordinationState#handleClientValue`) then we
must explicitly stand down as leader.

Closes #96273
David Turner 2 years ago
parent
commit
c777925450

+ 6 - 0
docs/changelog/96490.yaml

@@ -0,0 +1,6 @@
+pr: 96490
+summary: Become candidate on publication failure
+area: Cluster Coordination
+type: bug
+issues:
+ - 96273

+ 3 - 0
server/src/main/java/org/elasticsearch/cluster/coordination/Coordinator.java

@@ -1548,6 +1548,9 @@ public class Coordinator extends AbstractLifecycleComponent implements ClusterSt
                     followersChecker.setCurrentNodes(publishNodes);
                     lagDetector.setTrackedNodes(publishNodes);
                     publication.start(followersChecker.getFaultyNodes());
+                } catch (Exception e) {
+                    assert currentPublication.isEmpty() : e; // should not fail after setting currentPublication
+                    becomeCandidate("publish");
                 } finally {
                     publicationContext.decRef();
                 }