Skip to content

Commit fb0aef6

Browse files
committed
The first draft of rep autoexpel
1 parent 2d943c9 commit fb0aef6

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

doc/reference/configuration/configuration_reference.rst

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3545,6 +3545,7 @@ replication
35453545
The ``replication`` section defines configuration parameters related to :ref:`replication <replication>`.
35463546

35473547
- :ref:`replication.anon <configuration_reference_replication_anon>`
3548+
- :ref:`replication.anon <configuration_reference_replication_autoexpel>`
35483549
- :ref:`replication.bootstrap_strategy <configuration_reference_replication_bootstrap_strategy>`
35493550
- :ref:`replication.connect_timeout <configuration_reference_replication_connect_timeout>`
35503551
- :ref:`replication.election_mode <configuration_reference_replication_election_mode>`
@@ -3600,6 +3601,142 @@ The ``replication`` section defines configuration parameters related to :ref:`re
36003601
| Default: ``false``
36013602
| Environment variable: TT_REPLICATION_ANON
36023603
3604+
.. _configuration_reference_replication_autoexpel:
3605+
3606+
.. confval:: replication.autoexpel
3607+
3608+
The ``replication.autoexpel`` option designed for managing dynamic clusters using YAML-based configurations.
3609+
It enables the automatic expulsion of instances that are removed from the YAML configuration.
3610+
3611+
Only instances with names that match the specified prefix are considered for expulsion; all others are excluded.
3612+
Additionally, instances without a persistent name are ignored.
3613+
3614+
If an instance is in read-write mode and has the latest database schema, it initiates the expulsion of instances that:
3615+
- Match the specified prefix
3616+
- Absent from the updated YAML configuration
3617+
3618+
The expulsion process follows the standard procedure, involving the removal of the instance from the ``_cluster`` system space.
3619+
3620+
The ``autoexpel`` logic is activated during specific events:
3621+
- **Startup**. When the cluster starts, ``autoexpel`` checks and removes instances not matching the updated configuration.
3622+
- **Reconfiguration**. When the YAML configuration is reloaded, ``autoexpel`` compares the current state to the updated configuration and performs necessary expulsions.
3623+
- ``box.status`` **Watcher Event**. Changes detected by the ``box.status watcher`` also trigger the ``autoexpel`` mechanism.
3624+
3625+
New instances
3626+
``Autoexpel`` does not take any actions on newly joined instances unless one of the triggering events occurs.
3627+
This means that an instance meeting the ``autoexpel`` criterion can still join the cluster, but it may be removed
3628+
later during reconfiguration or on subsequent triggering events.
3629+
3630+
.. NOTE::
3631+
The ``replication.autoexpel`` option governs the expelling process and is configurable at the replicaset, group, and
3632+
global levels. It is not applicable at the instance level.
3633+
3634+
Configuration fields
3635+
- **`enabled`** *(boolean, default: `false`)*: enables or disables the ``autoexpel`` logic.
3636+
3637+
- **`by`** *(string, default: `nil`)*: specifies the ``autoexpel`` criterion. Currently, only `prefix` is supported and must be explicitly set.
3638+
3639+
- **`prefix`** *(string, default: `nil`)*: defines the pattern for instance names that are considered part of the cluster.
3640+
3641+
**Example Patterns**:
3642+
- If instances are prefixed with the replicaset name, set:
3643+
``prefix: '{{ replicaset_name }}'``
3644+
- For instances matching a specific pattern (e.g., `i-\d\d\d`), set:
3645+
``prefix: 'i-'``
3646+
3647+
**Example**
3648+
3649+
1. Create a ``config.yaml`` file with the following content:
3650+
3651+
.. code-block:: yaml
3652+
3653+
credentials:
3654+
users:
3655+
guest:
3656+
roles: [super]
3657+
3658+
replication:
3659+
failover: manual
3660+
autoexpel:
3661+
enabled: true
3662+
by: prefix
3663+
prefix: '{{ replicaset_name }}'
3664+
3665+
iproto:
3666+
listen:
3667+
- uri: 'unix/:./var/run/{{ instance_name }}.iproto'
3668+
3669+
groups:
3670+
g-001:
3671+
replicasets:
3672+
r-001:
3673+
leader: r-001-i-001
3674+
instances:
3675+
r-001-i-001: {}
3676+
r-001-i-002: {}
3677+
r-001-i-003: {}
3678+
3679+
3680+
This configuration:
3681+
- Sets up authentication with a guest user assigned the super role.
3682+
- Enables the autoexpel option to automatically expel instances not present in the YAML file.
3683+
- Defines instance names based on a prefix pattern: {{ replicaset_name }}.
3684+
- Lists three instances: r-001-i-001, r-001-i-002, and r-001-i-003.
3685+
3686+
3687+
2. Open terminal window and start three instances using the following commands:
3688+
3689+
``tarantool --name r-001-i-001 --config config.yaml -i``
3690+
3691+
``tarantool --name r-001-i-002 --config config.yaml -i``
3692+
3693+
``tarantool --name r-001-i-003 --config config.yaml -i``
3694+
3695+
3. Edit ``config.yaml`` and remove the following entry for ``r-001-i-003``:
3696+
3697+
``r-001-i-003: {}``
3698+
3699+
3700+
The updated ``config.yaml`` should look like this:
3701+
3702+
.. code-block:: yaml
3703+
3704+
groups:
3705+
g-001:
3706+
replicasets:
3707+
r-001:
3708+
leader: r-001-i-001
3709+
instances:
3710+
r-001-i-001: {}
3711+
r-001-i-002: {}
3712+
3713+
Save the file.
3714+
3715+
4. For the leader instance (``r-001-i-001``), check the _cluster space:
3716+
3717+
.. admonition:: Info
3718+
:class: fact
3719+
3720+
The ``_cluster`` system space in Tarantool stores metadata about all instances currently recognized as part of the cluster.
3721+
It shows which instances are registered and active.
3722+
3723+
You should see ``r-001-i-003`` still listed in the ``_cluster`` system space.
3724+
3725+
5. Reload the configuration:
3726+
3727+
.. code-block:: lua
3728+
3729+
config = require('config')
3730+
config:reload()
3731+
3732+
6. Verify the changes:
3733+
3734+
``box.space._cluster:fselect()``
3735+
3736+
After the reload, ``r-001-i-003`` should no longer appear in the ``_cluster`` system space.
3737+
3738+
3739+
36033740
.. _configuration_reference_replication_bootstrap_strategy:
36043741

36053742
.. confval:: replication.bootstrap_strategy

0 commit comments

Comments
 (0)