@@ -415,13 +415,30 @@ public void onResponse(Void unused) {
415
415
416
416
@ Override
417
417
public void onFailure (Exception exception ) {
418
- if (exception instanceof FailedToCommitClusterStateException failedToCommitClusterStateException ) {
418
+ if (exception instanceof FailedToCommitClusterStateException || exception instanceof NotMasterException ) {
419
419
final long notificationStartTime = threadPool .rawRelativeTimeInMillis ();
420
420
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
+
422
438
for (final var executionResult : executionResults ) {
423
- executionResult .onPublishFailure (failedToCommitClusterStateException );
439
+ executionResult .onPublishFailure (exception );
424
440
}
441
+
425
442
final long notificationMillis = threadPool .rawRelativeTimeInMillis () - notificationStartTime ;
426
443
clusterStateUpdateStatsTracker .onPublicationFailure (
427
444
threadPool .rawRelativeTimeInMillis (),
@@ -985,11 +1002,18 @@ void onClusterStateUnchanged(ClusterState clusterState) {
985
1002
}
986
1003
}
987
1004
988
- void onPublishFailure (FailedToCommitClusterStateException e ) {
1005
+ void onPublishFailure (Exception e ) {
1006
+ assert e instanceof FailedToCommitClusterStateException || e instanceof NotMasterException : e ;
989
1007
if (publishedStateConsumer == null && onPublicationSuccess == null ) {
990
1008
assert failure != null ;
991
1009
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
+
993
1017
failure .addSuppressed (taskFailure );
994
1018
notifyFailure ();
995
1019
return ;
0 commit comments