Skip to content

Commit 47f75f2

Browse files
committed
Sharding config
1 parent 3b51c8b commit 47f75f2

File tree

7 files changed

+227
-236
lines changed

7 files changed

+227
-236
lines changed

doc/book/admin/vshard_admin.rst

Lines changed: 182 additions & 204 deletions
Large diffs are not rendered by default.

doc/code_snippets/snippets/sharding/instances.enabled/sharded_cluster/storage.lua

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
box.schema.create_space('bands', {
2-
format = {
3-
{ name = 'id', type = 'unsigned' },
4-
{ name = 'bucket_id', type = 'unsigned' },
5-
{ name = 'band_name', type = 'string' },
6-
{ name = 'year', type = 'unsigned' }
7-
},
8-
if_not_exists = true
9-
})
10-
box.space.bands:create_index('id', { parts = { 'id' }, if_not_exists = true })
11-
box.space.bands:create_index('bucket_id', { parts = { 'bucket_id' }, unique = false, if_not_exists = true })
1+
box.once('bands', function()
2+
box.schema.create_space('bands', {
3+
format = {
4+
{ name = 'id', type = 'unsigned' },
5+
{ name = 'bucket_id', type = 'unsigned' },
6+
{ name = 'band_name', type = 'string' },
7+
{ name = 'year', type = 'unsigned' }
8+
},
9+
if_not_exists = true
10+
})
11+
box.space.bands:create_index('id', { parts = { 'id' }, if_not_exists = true })
12+
box.space.bands:create_index('bucket_id', { parts = { 'bucket_id' }, unique = false, if_not_exists = true })
13+
end)
1214

1315
function insert_band(id, bucket_id, band_name, year)
1416
box.space.bands:insert({ id, bucket_id, band_name, year })

doc/how-to/vshard_quick.rst

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -217,34 +217,28 @@ The resulting ``config.yaml`` file should look as follows:
217217
Adding storage code
218218
~~~~~~~~~~~~~~~~~~~
219219

220-
1. Open the ``storage.lua`` file and create a space using the :ref:`box.schema.space.create() <box_schema-space_create>` function:
220+
1. Open the ``storage.lua`` file and define a space and indexes inside :ref:`box.once() <box-once>`:
221221

222222
.. literalinclude:: /code_snippets/snippets/sharding/instances.enabled/sharded_cluster/storage.lua
223223
:language: lua
224-
:start-at: box.schema.create_space
225-
:end-before: box.space.bands:create_index('id'
224+
:start-at: box.once
225+
:end-before: function insert_band
226226
:dedent:
227227

228-
Note that the created ``bands`` spaces includes the ``bucket_id`` field.
229-
This field represents a sharding key used to partition a dataset across different storage instances.
228+
* The :ref:`box.schema.create_space() <box_schema-space_create>` function is used to create a space.
229+
Note that the created ``bands`` spaces includes the ``bucket_id`` field.
230+
This field represents a sharding key used to partition a dataset across different storage instances.
231+
* :ref:`space_object:create_index() <box_space-create_index>` is used to create two indexes based on the ``id`` and ``bucket_id`` fields.
230232

231-
2. Create two indexes based on the ``id`` and ``bucket_id`` fields:
232-
233-
.. literalinclude:: /code_snippets/snippets/sharding/instances.enabled/sharded_cluster/storage.lua
234-
:language: lua
235-
:start-at: box.space.bands:create_index('id'
236-
:end-at: box.space.bands:create_index('bucket_id'
237-
:dedent:
238-
239-
3. Define the ``insert_band`` function that inserts a tuple into the created space:
233+
2. Define the ``insert_band`` function that inserts a tuple into the created space:
240234

241235
.. literalinclude:: /code_snippets/snippets/sharding/instances.enabled/sharded_cluster/storage.lua
242236
:language: lua
243237
:start-at: function insert_band
244238
:end-before: function get_band
245239
:dedent:
246240

247-
4. Define the ``get_band`` function that returns data without the ``bucket_id`` value:
241+
3. Define the ``get_band`` function that returns data without the ``bucket_id`` value:
248242

249243
.. literalinclude:: /code_snippets/snippets/sharding/instances.enabled/sharded_cluster/storage.lua
250244
:language: lua

doc/reference/configuration/configuration_reference.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3044,6 +3044,7 @@ The ``sharding`` section defines configuration parameters related to :ref:`shard
30443044
- :ref:`sharding.sched_ref_quota <configuration_reference_sharding_sched_ref_quota>`
30453045
- :ref:`sharding.shard_index <configuration_reference_sharding_shard_index>`
30463046
- :ref:`sharding.sync_timeout <configuration_reference_sharding_sync_timeout>`
3047+
- :ref:`sharding.weight <configuration_reference_sharding_weight>`
30473048
- :ref:`sharding.zone <configuration_reference_sharding_zone>`
30483049

30493050

@@ -3347,11 +3348,28 @@ The ``sharding`` section defines configuration parameters related to :ref:`shard
33473348
| Environment variable: TT_SHARDING_SYNC_TIMEOUT
33483349
33493350

3351+
.. _configuration_reference_sharding_weight:
3352+
3353+
.. confval:: sharding.weight
3354+
3355+
The relative amount of data that a replica set can store.
3356+
Learn more at :ref:`vshard-replica-set-weights`.
3357+
3358+
.. NOTE::
3359+
3360+
``sharding.weight`` can be specified at the :ref:`replica set level <configuration_scopes>`.
3361+
3362+
|
3363+
| Type: number
3364+
| Default: 1
3365+
| Environment variable: TT_SHARDING_WEIGHT
3366+
3367+
33503368
.. _configuration_reference_sharding_zone:
33513369

33523370
.. confval:: sharding.zone
33533371

3354-
A :ref:`zone <vshard-replica-weights>` that can be set for routers and replicas.
3372+
A zone that can be set for routers and replicas.
33553373
This allows sending read-only requests not only to a master instance but to any available replica that is the nearest to the router.
33563374

33573375
.. NOTE::

doc/reference/reference_rock/vshard/vshard_ref.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Basic parameters
4343
.. confval:: weights
4444

4545
A field defining the configuration of relative weights for each zone pair in a
46-
replica set. See the :ref:`Replica weights <vshard-replica-weights>` section.
46+
replica set.
4747

4848
| Type: table
4949
| Default: false

locale/en/reference/reference_rock/vshard/vshard_ref.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ msgid "Dynamic: yes"
9696
msgstr ""
9797

9898
#: ../../doc/reference/reference_rock/vshard/vshard_ref.rst:39
99-
msgid "A field defining the configuration of relative weights for each zone pair in a replica set. See the :ref:`Replica weights <vshard-replica-weights>` section."
99+
msgid "A field defining the configuration of relative weights for each zone pair in a replica set."
100100
msgstr ""
101101

102102
#: ../../doc/reference/reference_rock/vshard/vshard_ref.rst:50

locale/ru/LC_MESSAGES/reference/reference_rock/vshard/vshard_ref.po

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,10 @@ msgstr "Динамический: да"
6363

6464
msgid ""
6565
"A field defining the configuration of relative weights for each zone pair in"
66-
" a replica set. See the :ref:`Replica weights <vshard-replica-weights>` "
67-
"section."
66+
" a replica set."
6867
msgstr ""
6968
"Поле, которое определяет конфигурацию относительного веса для каждой пары "
70-
"зон в наборе реплик. См. раздел :ref:`Вес реплики <vshard-replica-weights>`."
69+
"зон в наборе реплик."
7170

7271
msgid ""
7372
"Name or id of a TREE index over the :ref:`bucket id <vshard-vbuckets>`. "

0 commit comments

Comments
 (0)