[Tarantool-patches] [PATCH v4 11/16] box: make promote on the current leader a no-op
Serge Petrenko
sergepetrenko at tarantool.org
Wed Jul 14 21:25:39 MSK 2021
It was allowed to call promote on any instance, even when it's already
the limbo owner (iow Raft leader, when elections are enabled).
This doesn't break anything, when elections are disabled, but is rather
strange.
When elections are enabled, in contrary, calling promote() should be a
no-op on the leader. Otherwise it would make the leader read-only until
it wins the next election round, which's quite inconvenient.
Part-of #6034
---
src/box/box.cc | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/box/box.cc b/src/box/box.cc
index ac6c487e4..6a534952f 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -1701,6 +1701,9 @@ box_promote(void)
*/
if (!is_box_configured)
return 0;
+ if (txn_limbo_replica_term(&txn_limbo, instance_id) ==
+ box_raft()->term)
+ return 0;
bool run_elections = false;
bool try_wait = false;
@@ -1729,10 +1732,6 @@ box_promote(void)
"'candidate'", "manual elections");
return -1;
}
- if (txn_limbo_replica_term(&txn_limbo, instance_id) ==
- box_raft()->term)
- return 0;
-
break;
default:
unreachable();
--
2.30.1 (Apple Git-130)
More information about the Tarantool-patches
mailing list