Skip to content

Commit 984f899

Browse files
veod32patiencedaur
andauthored
Describe vshard router master discovery (#2848)
Resolves #2268 * Add description of the `master` parameter and the `master_search_wakeup()` function Co-authored-by: Patience Daur <[email protected]>
1 parent 9afaa26 commit 984f899

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

doc/reference/reference_rock/vshard/vshard_ref.rst

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Basic parameters
2121
* :ref:`rebalancer_max_receiving <cfg_basic-rebalancer_max_receiving>`
2222
* :ref:`rebalancer_max_sending <cfg_basic-rebalancer_max_sending>`
2323
* :ref:`discovery_mode <cfg_basic-discovery_mode>`
24+
* :ref:`master <cfg_basic-master>`
2425

2526
.. _cfg_basic-sharding:
2627

@@ -174,6 +175,73 @@ Basic parameters
174175
| Default: 'on'
175176
| Dynamic: yes
176177
178+
.. _cfg_basic-master:
179+
180+
.. confval:: master
181+
182+
Turns on automated master discovery in a replica set if set to ``auto``.
183+
Applicable only to the configuration of a router; the storage configuration ignores this parameter.
184+
185+
The parameter should be specified per replica set and is not compatible with manual master selection.
186+
187+
**Examples**
188+
189+
Correct configuration:
190+
191+
.. code-block:: kconfig
192+
:emphasize-lines: 4
193+
194+
config = {
195+
sharding = {
196+
<replicaset uuid> = {
197+
master = 'auto',
198+
replicas = {...},
199+
},
200+
...
201+
},
202+
...
203+
}
204+
205+
Incorrect configuration:
206+
207+
.. code-block:: kconfig
208+
:emphasize-lines: 4, 7, 11
209+
210+
config = {
211+
sharding = {
212+
<replicaset uuid> = {
213+
master = 'auto',
214+
replicas = {
215+
<replica uuid1> = {
216+
master = true,
217+
...
218+
},
219+
<replica uuid2> = {
220+
master = false,
221+
...
222+
},
223+
},
224+
},
225+
...
226+
},
227+
...
228+
}
229+
230+
If configuration is incorrect configuration, it is not applied, and the ``vshard.router.cfg()`` call throws an error.
231+
232+
233+
If the ``master`` parameter is set to ``auto`` for some replica sets, the router goes to these replica sets, discovers the master in each of them, and periodically checks if the master instance still has its master status.
234+
When the master in the replica set stops being a master, the router goes around all the nodes of the replica set and finds out which one is the new master.
235+
236+
Without this setting, the router cannot detect master nodes in the configured replica sets on its own.
237+
It relies only on how they are specified in the configuration.
238+
This becomes a problem when the master changes and the change is not delivered to the router's configuration:
239+
for instance, in case the router doesn't rely on a central configuration provider
240+
or the provider cannot deliver a new configuration due to some reason.
241+
242+
| Type: string
243+
| Default: ``nil``
244+
| Dynamic: yes
177245
178246
.. _vshard-config-replica-set-funcs:
179247

doc/reference/reference_rock/vshard/vshard_router.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,21 @@ Router public API
895895
* result of ``function_name`` on success
896896
* nil, err otherwise
897897

898+
.. _router_api-master-search-wakeup:
899+
900+
.. function:: vshard.router.master_search_wakeup()
901+
902+
:ref:`Automated master discovery <cfg_basic-master>` works in its own fiber on a router,
903+
which is activated only if at least one replica set is configured to look for the master (the ``master`` parameter is set to ``auto``).
904+
The fiber wakes up within a certain period. But it is possible to wake it up on demand by using this function.
905+
906+
Manual fiber wakeup can help speed up tests for master change.
907+
Another use case is performing some actions with a router in the router console.
908+
909+
The function does nothing if master search is not :ref:`configured <cfg_basic-master>` for any replica set.
910+
911+
:return: none
912+
898913
.. _vshard_api_reference-router_internal_api:
899914

900915
Router internal API

0 commit comments

Comments
 (0)