@@ -3080,36 +3080,35 @@ box_demote(void)
3080
3080
return 0 ;
3081
3081
3082
3082
const struct raft *raft = box_raft ();
3083
- if (box_election_mode == ELECTION_MODE_OFF) {
3084
- assert (raft->state == RAFT_STATE_FOLLOWER);
3085
- if (raft->leader != REPLICA_ID_NIL) {
3086
- diag_set (ClientError, ER_NOT_LEADER, raft->leader );
3087
- return -1 ;
3088
- }
3089
- if (txn_limbo.owner_id == REPLICA_ID_NIL)
3090
- return 0 ;
3091
- /*
3092
- * If the limbo term is up to date with Raft, then it might have
3093
- * a valid owner right now. Demotion would disrupt it. In this
3094
- * case the user has to explicitly overthrow the old owner with
3095
- * local promote(), or call demote() on the actual owner.
3096
- */
3097
- if (txn_limbo.promote_greatest_term == raft->term &&
3098
- txn_limbo.owner_id != instance_id)
3099
- return 0 ;
3100
- } else {
3083
+ if (box_election_mode != ELECTION_MODE_OFF) {
3101
3084
if (txn_limbo_replica_term (&txn_limbo, instance_id) !=
3102
3085
raft->term )
3103
3086
return 0 ;
3104
3087
if (txn_limbo.owner_id != instance_id)
3105
3088
return 0 ;
3106
3089
if (raft->state != RAFT_STATE_LEADER)
3107
3090
return 0 ;
3091
+ return box_trigger_elections ();
3108
3092
}
3109
- if (box_trigger_elections () != 0 )
3093
+
3094
+ assert (raft->state == RAFT_STATE_FOLLOWER);
3095
+ if (raft->leader != REPLICA_ID_NIL) {
3096
+ diag_set (ClientError, ER_NOT_LEADER, raft->leader );
3110
3097
return -1 ;
3111
- if (box_election_mode != ELECTION_MODE_OFF)
3098
+ }
3099
+ if (txn_limbo.owner_id == REPLICA_ID_NIL)
3112
3100
return 0 ;
3101
+ /*
3102
+ * If the limbo term is up to date with Raft, then it might have
3103
+ * a valid owner right now. Demotion would disrupt it. In this
3104
+ * case the user has to explicitly overthrow the old owner with
3105
+ * local promote(), or call demote() on the actual owner.
3106
+ */
3107
+ if (txn_limbo.promote_greatest_term == raft->term &&
3108
+ txn_limbo.owner_id != instance_id)
3109
+ return 0 ;
3110
+ if (box_trigger_elections () != 0 )
3111
+ return -1 ;
3113
3112
if (box_try_wait_confirm (2 * replication_synchro_timeout) < 0 )
3114
3113
return -1 ;
3115
3114
int64_t wait_lsn = box_wait_limbo_acked (replication_synchro_timeout);
0 commit comments