Skip to content
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

Implement persistency for Lua triggers #4343

Open
kyukhin opened this issue Jul 12, 2019 · 0 comments
Open

Implement persistency for Lua triggers #4343

kyukhin opened this issue Jul 12, 2019 · 0 comments
Labels
feature A new functionality in design Requires design document
Milestone

Comments

@kyukhin
Copy link
Contributor

kyukhin commented Jul 12, 2019

After #4182 is implemented it'll be possible to make triggers persistent
using very same machinery.
So, ultimately we want to save triggers and and resurrect them during recovery.

Need to understand, if we want to have a switch which will enable/disable this
feature for selected triggers.

@kyukhin kyukhin added the feature A new functionality label Jul 12, 2019
@kyukhin kyukhin added this to the 2.3.0 milestone Jul 12, 2019
@kostja kostja changed the title Implement persistency for triggers Implement persistency for Lua triggers Aug 6, 2019
@kshcherbatov kshcherbatov self-assigned this Aug 20, 2019
kshcherbatov added a commit that referenced this issue Sep 9, 2019
kshcherbatov added a commit that referenced this issue Sep 9, 2019
@kshcherbatov kshcherbatov added in design Requires design document and removed in progress labels Sep 12, 2019
kshcherbatov added a commit that referenced this issue Oct 15, 2019
The trigger pointer in the sql_trigger structure is a dead code
now, so it could be deleted.

Needed for #4343
kshcherbatov added a commit that referenced this issue Oct 15, 2019
Renamed struct trigger to struct lua_trigger because the 'trigger'
name is too general. Currently Tarantool has non-persistent
AppServer Lua triggers represented with 'trigger' structure so as
SQL-specific persistent trigger object named 'sql_trigger'.

In scope of this patchset we going to significantly rework
triggers subsystem and introduce a new base trigger class named
'trigger', so this name is be better to be released.

Needed for #4343
kshcherbatov added a commit that referenced this issue Oct 15, 2019
This patch introduces a new trigger_event_manipulation enum
that describes a trigger event. This is the type of operation on
the associated space for which the trigger activates.
The value could be `INSERT` (a row was inserted), `DELETE`
(a row was deleted), or `UPDATE` (a row was modified).

Using the enum instead of sql-specific TK_ token identified is
an important step to introduce a trigger_def structure in
further patches.

Needed for #4343
kshcherbatov added a commit that referenced this issue Oct 15, 2019
This patch introduces a new trigger_action_timing enum
that describes a moment when the trigger activates: before or
after the triggering event.

Using the enum instead of sql-specific TK_ token identified is
an important step to introduce a trigger_def structure in
further patches.

Needed for #4343
kshcherbatov added a commit that referenced this issue Oct 15, 2019
Using a rlist structure member to organize structures in a list
is typical practice in the Tarantool core; and reduces costs for
supporting and extending of an existent code.

With this refactoring using an universal trigger structure in
further patches would be simpler.

Needed for #4343
kshcherbatov added a commit that referenced this issue Oct 15, 2019
SQL grammar used to construct the sql_trigger object or to
generate a related VDBE instructions in a two functions with
a shared context: sql_trigger_begin and sql_trigger_end.

It used to be an AST compile or VDBE code generation in according
to parser::is_parse_only flag state - that is messy.

This patch reworks SQL rule a bit to call a function once, when
the whole trigger context is assembled to call the first function
that constructs AST or the second to emit VDBE code.

Needed for #4343.
kshcherbatov added a commit that referenced this issue Oct 15, 2019
Introduced a new sql_trigger_expr to aggregate all
sql_triger-related ASTs. This allows to rework
sql_trigger_compile function in further patches to return
sql_trigger_expr object instead of the complete trigger
object.

It is an important step of refactoring, because we are going
to construct trigger and trigger_def objects universally by
information that will be defined in the _trigger space.

Needed for #4343
kshcherbatov added a commit that referenced this issue Oct 15, 2019
This patch reworks sql_trigger class to inherit it from
a new trigger base class. This will allow us to work with
all triggers uniformly regardless of it's implementation.

Needed for #4343
kshcherbatov added a commit that referenced this issue Oct 15, 2019
This patch reworks a _trigger system space to make it
useful not only for sql triggers definitions.

The format of the updated system space is

_trigger (space id = 328)
[<name> STRING, <space_id> UINT32, <opts> MAP, <language> STR,
 <type> STR, <event_manipulation> STR,
 <action_timing> STR, <code> STR]

After insertion into this space, a new instance describing trigger
object is created using language-dependent constructor.

This volumerous refactoring is an initial step for further
introduction of persistent triggers in Lua.

Needed for #4343
Korablev77 pushed a commit that referenced this issue Oct 15, 2019
The trigger pointer in the sql_trigger structure is a dead code
now, so it could be deleted.

Needed for #4343
@kyukhin kyukhin modified the milestones: 2.3.1, 2.4.1 Nov 11, 2019
@kyukhin kyukhin modified the milestones: 2.4.1, 2.5.1 Jan 23, 2020
@kyukhin kyukhin modified the milestones: 2.5.1, 2.6.1 Apr 10, 2020
@kyukhin kyukhin modified the milestones: 2.6.1, wishlist Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new functionality in design Requires design document
Projects
None yet
Development

No branches or pull requests

2 participants