[PATCH v4 0/6] box: rework functions machinery

Kirill Shcherbatov kshcherbatov at tarantool.org
Sun Jun 23 16:57:51 MSK 2019


This patchset reworks Tarantool's functions machinery to support
persistent Lua functions and provide an universal way to call any
registered function.

This patchset consists of following conceptual changes:
1. Func updates on alter were simplified: now replace _func tuple is
   forbidden and func_new constructor may fail. This makes possible to
   define a failable function object constructors.
2. box_lua_call and box_lua_eval were refactored to do nottake call_request
   argument and to use input and output port instead. A new msgpack_port allows
   to use this abstraction also for a regular memory msgpack.
3. Introduced an abstract function class and func_c and func_lua
   implementations that allow to call C and Lua functions correspondingly
   with uniform API defined on base func class.
4. Introduced an infrastructure to call functions from Lua. A new box.func
   folder exports functions objects that have :call and :drop methods and their
   definition.
4. Introduced persistent Lua functions. Such functions are a part of Tarantool
   snapshoot so they are available even after restart. The new is_sandboxed
   option initializes a new persistent Lua function is a separate 'sandbox':
   an isolated environment with strong restrictions: only limited number of
   on-board functions are available, no global state is available at all.

Persistent Lua functions is an important step to implement functional indexes
in Tarantool. Only a deterministic, sandboxed, persistent Lua function may
be used as a functional index extractor.

Changes in version 4:
   Build of persistent Lua function in a sandbox
   New space format
   Minor review fixes

Changes in version 3:
   Source code is re-organised to be bit clear and to provide a better function
   object abstraction.

http://github.com/tarantool/tarantool/tree/kshch/gh-4182-persistent-lua-functions
https://github.com/tarantool/tarantool/issues/4182

Kirill Shcherbatov (6):
  box: rework func cache update machinery
  box: rework box_lua_{call, eval} to use input port
  box: rework func object as a function frontend
  box: export registered functions in box.func folder
  box: refactor box_lua_find helper
  box: introduce Lua persistent functions

 src/box/alter.cc             | 147 ++++++---
 src/box/bootstrap.snap       | Bin 4475 -> 4650 bytes
 src/box/call.c               | 168 +++-------
 src/box/call.h               |   4 -
 src/box/errcode.h            |   2 +-
 src/box/execute.c            |   1 +
 src/box/func.c               | 198 ++++++++++--
 src/box/func.h               |  34 +-
 src/box/func_def.c           |  25 ++
 src/box/func_def.h           |  51 ++-
 src/box/lua/call.c           | 608 +++++++++++++++++++++++++++++++----
 src/box/lua/call.h           |  13 +-
 src/box/lua/execute.c        |   8 +-
 src/box/lua/execute.h        |   4 +-
 src/box/lua/init.c           |   1 +
 src/box/lua/misc.cc          |  23 +-
 src/box/lua/schema.lua       |  47 ++-
 src/box/lua/upgrade.lua      |  34 +-
 src/box/port.c               |   3 +-
 src/box/port.h               |  17 +-
 src/box/schema.cc            |  31 +-
 src/box/schema.h             |  14 +-
 src/box/schema_def.h         |  11 +
 src/box/session.cc           |  11 +-
 src/box/session.h            |   9 +
 src/lib/core/port.h          |  38 ++-
 test/box-py/bootstrap.result |   6 +-
 test/box/access_misc.result  |   6 +-
 test/box/function1.c         |  33 ++
 test/box/function1.result    | 413 ++++++++++++++++++++++++
 test/box/function1.test.lua  | 139 ++++++++
 test/box/misc.result         |   2 +-
 test/wal_off/func_max.result |   4 +-
 33 files changed, 1766 insertions(+), 339 deletions(-)

-- 
2.21.0




More information about the Tarantool-patches mailing list