Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
bda72033
Commit
bda72033
authored
9 years ago
by
ocelot-inc
Browse files
Options
Downloads
Patches
Plain Diff
trigger list, error.last, box.once
parent
3661ec6f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/sphinx/book/box/box_error.rst
+15
-7
15 additions, 7 deletions
doc/sphinx/book/box/box_error.rst
doc/sphinx/book/box/triggers.rst
+11
-7
11 additions, 7 deletions
doc/sphinx/book/box/triggers.rst
doc/sphinx/book/replication/index.rst
+20
-0
20 additions, 0 deletions
doc/sphinx/book/replication/index.rst
with
46 additions
and
14 deletions
doc/sphinx/book/box/box_error.rst
+
15
−
7
View file @
bda72033
...
...
@@ -62,10 +62,13 @@ be presented to the client as ``ER_PROC_LUA``.
.. function:: box.error.last()
Returns a description of the last error, as a Lua table
with three members: "type" (string) error's C++ class,
"message" (string) error's message, "code" (numeric) error's number.
with five members: "line" (number) Tarantool source file line number,
"code" (number) error's number,
"type", (string) error's C++ class,
"message" (string) error's message,
"file" (string) Tarantool source file.
Additionally, if the error is a system error (for example due to a
failure in socket or file io), there
is a four
th member:
failure in socket or file io), there
may be a six
th member:
"errno" (number) C standard error number.
rtype: table
...
...
@@ -82,13 +85,18 @@ be presented to the client as ``ER_PROC_LUA``.
| :codenormal:`- error: Arbitrary message`
| :codenormal:`..`
|
| :codenormal:`tarantool>` :codebold:`box.schema.space.create('#')`
| :codenormal:`---`
| :codenormal:`- error: Invalid identifier '#' (expected letters, digits or an underscore)`
| :codenormal:`...`
| :codenormal:`tarantool>` :codebold:`box.error.last()`
| :codenormal:`---`
| :codenormal:`- type: ClientError`
| :codenormal:`message: Arbitrary message`
| :codenormal:`code: 555`
| :codenormal:`- line: 278`
| |nbsp| |nbsp| :codenormal:`code: 70`
| |nbsp| |nbsp| :codenormal:`type: ClientError`
| |nbsp| |nbsp| :codenormal:`message: Invalid identifier '#' (expected letters, digits or an underscore)`
| |nbsp| |nbsp| :codenormal:`file: /tmp/buildd/tarantool-1.6.6.252.g1654e31~precise/src/box/key_def.cc`
| :codenormal:`...`
|
| :codenormal:`tarantool>` :codebold:`box.error.clear()`
| :codenormal:`---`
| :codenormal:`...`
...
...
This diff is collapsed.
Click to expand it.
doc/sphinx/book/box/triggers.rst
+
11
−
7
View file @
bda72033
...
...
@@ -30,8 +30,8 @@ All triggers have the following characteristics.
order that they were defined in.
* They must work `within the event context`. If the function contains requests
which normally could not occur immediately after the event but before the
return from the event, effects are undefined. For example,
defining a trigger
function as
``os.exit()`` or ``box.rollback()`` would be bringing in requests
return from the event, effects are undefined. For example,
putting
``os.exit()`` or ``box.rollback()``
in a trigger function
would be bringing in requests
outside the event context.
* They are `replaceable`. The request to "redefine a trigger" consists of passing
the names of a new trigger function and an old trigger function to one of the
...
...
@@ -194,7 +194,7 @@ is executed once after each insert.
The following series of requests will associate an existing function named F
with an existing space named T, associate the function a second time with the
same space (so it will be called twice), disable all triggers of T, and de
stroy
same space (so it will be called twice), disable all triggers of T, and de
lete
each trigger by replacing with ``nil``.
.. code-block:: lua
...
...
@@ -210,14 +210,15 @@ each trigger by replacing with ``nil``.
===========================================================
The code :code:`on_connect()` -- with no arguments --
lists
all connect-trigger functions;
:code:`on_auth()`
list
s all authentication-trigger functions;
:code:`on_disconnect()`
list
s all disconnect-trigger functions;
:code:`on_replace()`
list
s all replace-trigger functions.
returns a table of
all connect-trigger functions;
:code:`on_auth()`
return
s all authentication-trigger functions;
:code:`on_disconnect()`
return
s all disconnect-trigger functions;
:code:`on_replace()`
return
s all replace-trigger functions.
In the following example a user finds that there are
three functions associated with :code:`on_connect`
triggers, and executes the third function, which happens to
contain the line "print('function #3')".
Then it deletes the third trigger.
| :codenormal:`tarantool>` :codebold:`box.session.on_connect()`
| :codenormal:`---`
...
...
@@ -230,6 +231,9 @@ contain the line "print('function #3')".
| :codenormal:`function #3`
| :codenormal:`---`
| :codenormal:`...`
| :codenormal:`tarantool>` :codebold:`box.session.on_connect(nil,box.session.on_connect()[3])`
| :codenormal:`---`
| :codenormal:`...`
...
...
This diff is collapsed.
Click to expand it.
doc/sphinx/book/replication/index.rst
+
20
−
0
View file @
bda72033
...
...
@@ -143,6 +143,26 @@ If a primary server is started with :codenormal:`box.cfg{...logger =` :codeitali
then there will be lines in the log file, containing the word "relay",
when a replica connects or disconnects.
=====================================================================
Preventing Duplicate Actions
=====================================================================
Suppose that the replica tries to do something
that the master has already done. For example: |br|
:code:`box.schema.space.create('X')` |br|
This would cause an error, "Space X exists".
For this particular situation, the code could be changed to: |br|
:code:`box.schema.space.create('X',{if_not_exists=true})` |br|
But there is a more general solution: the
:samp:`box.once({key},{function})` method.
If :code:`box.once()` has been called before with the
same :codeitalic:`key` value, then :codeitalic:`function`
is ignored; otherwise :codeitalic:`function` is executed.
Therefore, actions which should only occur once during the
life of a replicated session should be placed in a function
which is executed via :code:`box.once()`. For example: |br|
:codebold:`function f() box.schema.space.create('X'); end` |br|
:codebold:`box.once('space_creator',f)`
=====================================================================
Master-Master Replication
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment