@@ -415,13 +415,30 @@ public void onResponse(Void unused) {
415415
416416 @ Override
417417 public void onFailure (Exception exception ) {
418- if (exception instanceof FailedToCommitClusterStateException failedToCommitClusterStateException ) {
418+ if (exception instanceof FailedToCommitClusterStateException || exception instanceof NotMasterException ) {
419419 final long notificationStartTime = threadPool .rawRelativeTimeInMillis ();
420420 final long version = newClusterState .version ();
421- logger .warn (() -> format ("failing [%s]: failed to commit cluster state version [%s]" , summary , version ), exception );
421+
422+ if (exception instanceof FailedToCommitClusterStateException ) {
423+ logger .warn (
424+ () -> format ("Failing [%s]: failed to commit cluster state version [%s]" , summary , version ),
425+ exception
426+ );
427+ } else {
428+ logger .debug (
429+ () -> format (
430+ "Failing [%s]: node is no longer the master. Failed to publish cluster state version [%s]" ,
431+ summary ,
432+ version
433+ ),
434+ exception
435+ );
436+ }
437+
422438 for (final var executionResult : executionResults ) {
423- executionResult .onPublishFailure (failedToCommitClusterStateException );
439+ executionResult .onPublishFailure (exception );
424440 }
441+
425442 final long notificationMillis = threadPool .rawRelativeTimeInMillis () - notificationStartTime ;
426443 clusterStateUpdateStatsTracker .onPublicationFailure (
427444 threadPool .rawRelativeTimeInMillis (),
@@ -985,11 +1002,18 @@ void onClusterStateUnchanged(ClusterState clusterState) {
9851002 }
9861003 }
9871004
988- void onPublishFailure (FailedToCommitClusterStateException e ) {
1005+ void onPublishFailure (Exception e ) {
1006+ assert e instanceof FailedToCommitClusterStateException || e instanceof NotMasterException : e ;
9891007 if (publishedStateConsumer == null && onPublicationSuccess == null ) {
9901008 assert failure != null ;
9911009 var taskFailure = failure ;
992- failure = new FailedToCommitClusterStateException (e .getMessage (), e );
1010+
1011+ if (e instanceof FailedToCommitClusterStateException ) {
1012+ failure = new FailedToCommitClusterStateException (e .getMessage (), e );
1013+ } else {
1014+ failure = new NotMasterException (e .getMessage (), e );
1015+ }
1016+
9931017 failure .addSuppressed (taskFailure );
9941018 notifyFailure ();
9951019 return ;
0 commit comments