Skip to content

Commit e6977b7

Browse files
authored
Add replication.autoexpel configuration option (#4742)
* The first draft of rep autoexpel * Error in TOC fixed * Error in TOC fixed_1 * Indent fixed * Some errors fixed * Some errors fixed * Env var added * Code lines convertes to code blocks and fixed to lua lang * divided into three sifferent subsections * check links * errors fixed * errors fixed * indentation fixed * version highlighting added * reviewer's comments applied * reviewer's comments applied_1 * full example and logic deleted * unuseful info deleted
1 parent 783c5ab commit e6977b7

File tree

1 file changed

+175
-1
lines changed

1 file changed

+175
-1
lines changed

doc/reference/configuration/configuration_reference.rst

+175-1
Original file line numberDiff line numberDiff line change
@@ -3543,7 +3543,7 @@ replication
35433543
The ``replication`` section defines configuration parameters related to :ref:`replication <replication>`.
35443544

35453545
- :ref:`replication.anon <configuration_reference_replication_anon>`
3546-
- :ref:`replication.anon <configuration_reference_replication_autoexpel>`
3546+
- :ref:`replication.autoexpel <configuration_reference_replication_autoexpel>`
35473547
- :ref:`replication.bootstrap_strategy <configuration_reference_replication_bootstrap_strategy>`
35483548
- :ref:`replication.connect_timeout <configuration_reference_replication_connect_timeout>`
35493549
- :ref:`replication.election_mode <configuration_reference_replication_election_mode>`
@@ -3599,6 +3599,180 @@ The ``replication`` section defines configuration parameters related to :ref:`re
35993599
| Default: ``false``
36003600
| Environment variable: TT_REPLICATION_ANON
36013601
3602+
.. _configuration_reference_replication_autoexpel:
3603+
3604+
.. confval:: replication.autoexpel
3605+
3606+
**Since:** :doc:`3.3.0 </release/3.3.0>`
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+
3616+
- Match the specified prefix
3617+
- Absent from the updated YAML configuration
3618+
3619+
The expulsion process follows the standard procedure, involving the removal of the instance from the ``_cluster`` system space.
3620+
3621+
``autoexpel`` does not take any actions on newly joined instances unless one of the triggering events occurs.
3622+
This means that an instance meeting the ``autoexpel`` criterion can still join the cluster, but it may be removed
3623+
later during reconfiguration or on subsequent triggering events.
3624+
3625+
.. NOTE::
3626+
The ``replication.autoexpel`` option governs the expelling process and is configurable at the replicaset, group, and
3627+
global levels. It is not applicable at the instance level.
3628+
3629+
3630+
**Configuration fields**
3631+
3632+
3633+
- ``by`` (string, default: ``nil``): specifies the ``autoexpel`` criterion. Currently, only ``prefix`` is supported and must be explicitly set.
3634+
3635+
- ``enabled`` (boolean, default: ``false``): enables or disables the ``autoexpel`` logic.
3636+
3637+
- ``prefix`` (string, default: ``nil``): defines the pattern for instance names that are considered part of the cluster.
3638+
3639+
3640+
3641+
replication.autoexpel.by
3642+
~~~~~~~~~~~~~
3643+
3644+
``replication.autoexpel_by`` purpose is to define the criterion used for determining which instances in a cluster are
3645+
subject to the ``autoexpel`` process.
3646+
3647+
The ``by`` field helps differentiate between:
3648+
3649+
- Instances that are part of the cluster and should adhere to the YAML configuration.
3650+
3651+
- Instances or tools (e.g., CDC tools) that use the replication channel but are not part of the cluster configuration.
3652+
3653+
3654+
The default value of ``by`` is ``nil``, meaning no ``autoexpel`` criterion is applied unless explicitly set.
3655+
3656+
Currently, the only supported value for by is ``prefix``. The ``prefix`` value instructs the system to identify instances
3657+
based on their names, matching them against a prefix pattern defined in the configuration.
3658+
3659+
If the ``autoexpel`` feature is enabled, the ``by`` field must be explicitly set to ``prefix``.
3660+
3661+
The absence of this field or an unsupported value will result in configuration errors.
3662+
3663+
.. code-block:: yaml
3664+
3665+
replication:
3666+
autoexpel:
3667+
enabled: true
3668+
by: prefix
3669+
prefix: '{{ replicaset_name }}'
3670+
3671+
|
3672+
| Type: string
3673+
| Default: ``nil``
3674+
| Environment variable: TT_REPLICATION_AUTOEXPEL_BY
3675+
3676+
3677+
3678+
replication.autoexpel.enabled
3679+
~~~~~~~~~~~~~
3680+
3681+
The ``replication.autoexpel_enabled`` field is a boolean configuration option that determines whether the autoexpel logic is active for the cluster.
3682+
This feature is designed to automatically manage dynamic cluster configurations by removing instances that are no longer present in the YAML configuration.
3683+
3684+
.. NOTE::
3685+
3686+
By default, the ``enabled`` field is set to ``false``, meaning the ``autoexpel`` logic is turned off. This ensures that no instances are automatically removed unless explicitly configured.
3687+
3688+
**Enabling ``autoexpel`` logic**
3689+
3690+
To enable ``autoexpel``, you should set enabled to true in the ``replication.autoexpel`` section of your YAML configuration:
3691+
3692+
.. code-block:: yaml
3693+
3694+
replication:
3695+
autoexpel:
3696+
enabled: true
3697+
by: prefix
3698+
prefix: '{{ replicaset_name }}'
3699+
3700+
3701+
To disable ``autoexpel``, set enabled to ``false``.
3702+
3703+
3704+
**Dependencies**
3705+
3706+
3707+
If ``enabled`` is set to ``true``, the following fields are required:
3708+
3709+
1. ``by``: specifies the criterion for ``autoexpel`` (e.g., ``prefix``).
3710+
2. ``prefix``: defines the pattern used to match instance names for expulsion.
3711+
3712+
Failure to configure these fields when enabled is true will result in a configuration error.
3713+
3714+
|
3715+
| Type: boolean
3716+
| Default: ``false``
3717+
| Environment variable: TT_REPLICATION_AUTOEXPEL_ENABLED
3718+
3719+
3720+
replication.autoexpel.prefix
3721+
~~~~~~~~~~~~~
3722+
3723+
The ``prefix`` field filters instances for expulsion by differentiating cluster instances (from the YAML configuration) from external services (e.g., CDC tools). Only instances matching the prefix are considered.
3724+
3725+
A consistent naming pattern ensures the ``_cluster`` system space automatically aligns with the YAML configuration.
3726+
3727+
3728+
If the ``prefix`` field is not set (``nil``), the ``autoexpel`` logic cannot identify instances for expulsion, and the feature will not function.
3729+
This field is **mandatory** when ``replication.autoexpel_enabled`` is set to ``true``.
3730+
3731+
3732+
How it works:
3733+
3734+
1. The prefix filters instance names (e.g., ``{{ replicaset_name }}`` for replicaset-specific names or ``i-`` for names starting with ``i-``).
3735+
2. Instances matching the prefix and removed from the YAML configuration are expelled.
3736+
3. Unnamed instances or those not matching the prefix are ignored.
3737+
3738+
Dynamic prefix based on replicaset name:
3739+
3740+
.. code-block:: yaml
3741+
3742+
replication:
3743+
autoexpel:
3744+
enabled: true
3745+
by: prefix
3746+
prefix: '{{ replicaset_name }}'
3747+
3748+
3749+
In this setup:
3750+
3751+
- Instances are prefixed with a replicaset name (e.g., ``r-001-i-001`` for replicaset ``r-001``).
3752+
- The prefix ensures that only instances with names matching the replicaset name are auto expelled when removed from the configuration.
3753+
3754+
3755+
Static prefix for matching patterns:
3756+
3757+
.. code-block:: yaml
3758+
3759+
replication:
3760+
autoexpel:
3761+
enabled: true
3762+
by: prefix
3763+
prefix: 'i-'
3764+
3765+
In this setup:
3766+
3767+
- All instances with names starting with ``i-`` (e.g., ``i-001``, ``i-002``) are considered for expulsion.
3768+
- This is useful when instances follow a uniform naming convention.
3769+
3770+
|
3771+
| Type: string
3772+
| Default: ``nil``
3773+
| Environment variable: TT_REPLICATION_AUTOEXPEL_PREFIX
3774+
3775+
36023776
.. _configuration_reference_replication_bootstrap_strategy:
36033777

36043778
.. confval:: replication.bootstrap_strategy

0 commit comments

Comments
 (0)