Skip to content

Commit

Permalink
Add new option disable_raft_on_small_clusters (#2161)
Browse files Browse the repository at this point in the history
  • Loading branch information
yngvar-antonsson authored Nov 23, 2023
1 parent 416e14b commit 8b91131
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Added

- new issue about vshard storages marked as ``ALL_RW``.

- ``cartridge.cfg`` option ``disable_raft_on_small_clusters`` to disable Raft
failover on clusters with less than 3 instances (default: ``true``).

-------------------------------------------------------------------------------
[2.8.4] - 2023-10-31
-------------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions cartridge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ local function cfg(opts, box_opts)
enable_failover_suppressing = '?boolean',
enable_sychro_mode = '?boolean',
enable_synchro_mode = '?boolean',
disable_raft_on_small_clusters = '?boolean',

transport = '?string',
ssl_ciphers = '?string',
Expand Down Expand Up @@ -887,6 +888,7 @@ local function cfg(opts, box_opts)
upgrade_schema = opts.upgrade_schema,
enable_failover_suppressing = opts.enable_failover_suppressing,
enable_synchro_mode = opts.enable_synchro_mode,
disable_raft_on_small_clusters = opts.disable_raft_on_small_clusters,

transport = opts.transport,
ssl_ciphers = opts.ssl_ciphers,
Expand Down
1 change: 1 addition & 0 deletions cartridge/argparse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ local cluster_opts = {
ssl_client_password = 'string', -- **string**
disable_errstack = 'boolean', -- **boolean**
enable_synchro_mode = 'boolean', -- **boolean**
disable_raft_on_small_clusters = 'boolean', -- **boolean**
enable_failover_suppressing = 'boolean', -- **boolean**
}

Expand Down
4 changes: 4 additions & 0 deletions cartridge/confapplier.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ vars:new('upgrade_schema', nil)

vars:new('enable_failover_suppressing', nil)
vars:new('enable_synchro_mode', nil)
vars:new('disable_raft_on_small_clusters', nil)

vars:new('transport', nil)
vars:new('ssl_options', {
Expand Down Expand Up @@ -314,6 +315,7 @@ local function apply_config(clusterwide_config)
{
enable_failover_suppressing = vars.enable_failover_suppressing,
enable_synchro_mode = vars.enable_synchro_mode,
disable_raft_on_small_clusters = vars.disable_raft_on_small_clusters,
}
)
if not ok then
Expand Down Expand Up @@ -780,6 +782,7 @@ local function init(opts)
upgrade_schema = '?boolean',
enable_failover_suppressing = '?boolean',
enable_synchro_mode = '?boolean',
disable_raft_on_small_clusters = '?boolean',

transport = '?string',
ssl_ciphers = '?string',
Expand All @@ -802,6 +805,7 @@ local function init(opts)
vars.upgrade_schema = opts.upgrade_schema
vars.enable_failover_suppressing = opts.enable_failover_suppressing
vars.enable_synchro_mode = opts.enable_synchro_mode
vars.disable_raft_on_small_clusters = opts.disable_raft_on_small_clusters
vars.transport = opts.transport
vars.ssl_ciphers = opts.ssl_ciphers
vars.ssl_server_ca_file = opts.ssl_server_ca_file
Expand Down
8 changes: 7 additions & 1 deletion cartridge/failover.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ vars:new('failover_fiber')
vars:new('failover_err')
vars:new('cookie_check_err', nil)
vars:new('enable_synchro_mode', false)
vars:new('disable_raft_on_small_clusters', true)
vars:new('schedule', {})
vars:new('client')
vars:new('cache', {
Expand Down Expand Up @@ -758,6 +759,10 @@ local function cfg(clusterwide_config, opts)

vars.enable_synchro_mode = opts.enable_synchro_mode

if opts.disable_raft_on_small_clusters ~= nil then
vars.disable_raft_on_small_clusters = opts.disable_raft_on_small_clusters
end

fencing_cancel()
leader_autoreturn.cancel()
schedule_clear()
Expand Down Expand Up @@ -912,7 +917,8 @@ local function cfg(clusterwide_config, opts)
vars.consistency_needed = false

-- Raft failover can be enabled only on replicasets of 3 or more instances
if #topology.get_leaders_order(
if vars.disable_raft_on_small_clusters
and #topology.get_leaders_order(
topology_cfg, vars.replicaset_uuid, nil, {only_electable=false, only_enabled = true}) < 3
then
first_appointments = _get_appointments_disabled_mode(topology_cfg)
Expand Down
3 changes: 2 additions & 1 deletion rst/topics/failover.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ election mode using the argparse option ``TARANTOOL_ELECTION_MODE`` or
``--election-mode`` or use ``box.cfg{election_mode = ...}`` API in runtime.

Raft failover can be enabled only on replicasets of 3 or more instances
and can't be enabled with ``ALL_RW`` replicasets.
(you can change the behavior by using ``cartridge.cfg`` option
``disable_raft_on_small_clusters``) and can't be enabled with ``ALL_RW`` replicasets.

.. important::

Expand Down

0 comments on commit 8b91131

Please sign in to comment.