-
Notifications
You must be signed in to change notification settings - Fork 43
Update the description of box.space._schema
#4570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,7 @@ | ||
| .. _box-once: | ||
|
|
||
| ------------------------------------------------------------------------------- | ||
| Function box.once | ||
| ------------------------------------------------------------------------------- | ||
| Function box.once | ||
| ================= | ||
|
|
||
| .. function:: box.once(key, function[, ...]) | ||
|
|
||
|
|
@@ -18,40 +17,77 @@ | |
| stopping the database. The solution is to delete the ``once`` object from | ||
| the system space :ref:`_schema <box_space-schema>`. | ||
| Say ``box.space._schema:select{}``, find your ``once`` object there and | ||
| delete it. For example, re-executing a block with ``key='hello'`` : | ||
| delete it. | ||
|
|
||
| When ``box.once()`` is used for initialization, it may be useful to | ||
| wait until the database is in an appropriate state (read-only or read-write). | ||
| In that case, see the functions in the :doc:`/reference/reference_lua/box_ctl`. | ||
|
|
||
| .. code-block:: tarantoolsession | ||
| :param string key: a value that will be checked | ||
| :param function function: a function | ||
| :param ...: arguments that must be passed to function | ||
|
|
||
| .. NOTE:: | ||
|
|
||
| The parameter ``key`` will be stored in the :ref:`_schema <box_space-schema>` | ||
| system space after ``box.once()`` is called in order to prevent a double | ||
| run. These keys are global per replica set. So a simultaneous call of | ||
| ``box.once()`` with the same key on two instances of the same replica set | ||
| may succeed on both of them, but it'll lead to a transaction conflict. | ||
|
|
||
|
|
||
| **Example** | ||
|
|
||
| The example shows how to re-execute the ``box.once()`` block that contains the ``hello`` key. | ||
|
|
||
| First, check the ``_schema`` system space. | ||
| The ``_schema`` space in the example contains two ``box.once`` objects -- ``oncebye`` and ``oncehello``: | ||
|
|
||
| tarantool> box.space._schema:select{} | ||
| .. code-block:: console | ||
xuniq marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| app:instance001> box.space._schema:select{} | ||
| --- | ||
| - - ['cluster', 'b4e15788-d962-4442-892e-d6c1dd5d13f2'] | ||
| - ['max_id', 512] | ||
| - ['oncebye'] | ||
| - - ['oncebye'] | ||
| - ['oncehello'] | ||
| - ['version', 1, 7, 2] | ||
| ... | ||
| - ['replicaset_name', 'replicaset001'] | ||
| - ['replicaset_uuid', '72d2d9bf-5d9f-48c4-ba80-9d657e128fee'] | ||
| - ['version', 3, 1, 0] | ||
| Delete the ``oncehello`` object: | ||
|
|
||
| .. code-block:: console | ||
xuniq marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| tarantool> box.space._schema:delete('oncehello') | ||
| app:instance001> box.space._schema:delete('oncehello') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not reviewing doc patches often, so I might be out of the context. Is it common for us to write the instance name like this now? Or is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the review! We wrote the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So developers likely frequently see |
||
| --- | ||
| - ['oncehello'] | ||
| ... | ||
| tarantool> box.once('hello', function() end) | ||
| After that, check the ``_schema`` space again: | ||
|
|
||
| .. code-block:: console | ||
xuniq marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| app:instance001> box.space._schema:select{} | ||
| --- | ||
| - - ['oncebye'] | ||
| - ['replicaset_name', 'replicaset001'] | ||
| - ['replicaset_uuid', '72d2d9bf-5d9f-48c4-ba80-9d657e128fee'] | ||
| - ['version', 3, 1, 0] | ||
| ... | ||
| :param string key: a value that will be checked | ||
| :param function function: a function | ||
| :param ...: arguments that must be passed to function | ||
| To re-execute the function, call the ``box.once()`` method again: | ||
|
|
||
| .. NOTE:: | ||
| .. code-block:: console | ||
xuniq marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| app:instance001> box.once('hello', function() end) | ||
| --- | ||
| ... | ||
| app:instance001> box.space._schema:select{} | ||
| --- | ||
| - - ['oncebye'] | ||
| - ['oncehello'] | ||
| - ['replicaset_name', 'replicaset001'] | ||
| - ['replicaset_uuid', '72d2d9bf-5d9f-48c4-ba80-9d657e128fee'] | ||
| - ['version', 3, 1, 0] | ||
| ... | ||
| The parameter ``key`` will be stored in the :ref:`_schema <box_space-schema>` | ||
| system space after ``box.once()`` is called in order to prevent a double | ||
| run. These keys are global per replica set. So a simultaneous call of | ||
| ``box.once()`` with the same key on two instances of the same replica set | ||
| may succeed on both of them, but it'll lead to a transaction conflict. | ||
Uh oh!
There was an error while loading. Please reload this page.