File tree Expand file tree Collapse file tree
modules/raft/src/main/java/org/apache/ignite/raft/jraft/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5050import org .apache .ignite .internal .logger .IgniteLogger ;
5151import org .apache .ignite .internal .logger .Loggers ;
5252import org .apache .ignite .internal .metrics .MetricManager ;
53- import org .apache .ignite .internal .metrics .sources .FsmCallerMetricSource ;
54- import org .apache .ignite .internal .metrics .sources .LogManagerMetricSource ;
5553import org .apache .ignite .internal .metrics .sources .NodeMetricSource ;
5654import org .apache .ignite .internal .metrics .sources .RaftMetricSource ;
57- import org .apache .ignite .internal .metrics .sources .ReadOnlyServiceMetricSource ;
5855import org .apache .ignite .internal .raft .JraftGroupEventsListener ;
5956import org .apache .ignite .internal .raft .WriteCommand ;
6057import org .apache .ignite .internal .raft .service .SafeTimeAwareCommandClosure ;
@@ -1159,8 +1156,15 @@ public boolean init(final NodeOptions opts) {
11591156 this .writeLock .lock ();
11601157 if (this .conf .isStable () && this .conf .getConf ().size () == 1 && this .conf .getConf ().contains (this .serverId )) {
11611158 // The group contains only this server which must be the LEADER, trigger
1162- // the timer immediately.
1163- electSelf ();
1159+ // the timer immediately. Skip if already a leader — the election timer may have
1160+ // fired and completed a full election between stepDown() and this lock acquisition,
1161+ // in which case calling electSelf() again would corrupt BallotBox / confCtx state.
1162+ if (this .state != State .STATE_LEADER ) {
1163+ electSelf ();
1164+ }
1165+ else {
1166+ this .writeLock .unlock ();
1167+ }
11641168 }
11651169 else {
11661170 this .writeLock .unlock ();
You can’t perform that action at this time.
0 commit comments