From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Kirill Shcherbatov Subject: [PATCH v1 0/3] box: persistent Lua functions Date: Tue, 14 May 2019 16:29:19 +0300 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: tarantool-patches@freelists.org, vdavydov.dev@gmail.com Cc: Kirill Shcherbatov List-ID: Lua functions managed by Tarantool are called 'persistent'. They are stored in snapshoot and are available after server restart. No regular Lua functions, nor C functions can't be 'persistent' because they depend on non-only snapshot environment (libc, global variables etc.). Some restrictions must be accounted writing such routines: 1. only limited set of Lua functions and modules are available: -assert -error -pairs -ipairs -next -pcall -xpcall -type -print -select -string -tonumber -tostring -unpack -math -utf8; 2. global variables are forbidden. Persistent Lua functions are exported in box.schema.func.persistent folder. They may be called via .call in exported object or via netbox:call. In scope of this patch, refactored func module API: in case of persistent Lua function update may be insecure operation, so we need a machinery to transactionally update the object. http://github.com/tarantool/tarantool/tree/kshch/gh-4182-persistent-lua-functions https://github.com/tarantool/tarantool/issues/4182 Kirill Shcherbatov (3): box: refactor box_lua_find helper schema: extend _func space to persist lua functions box: extend box.schema.func with persistent folder src/box/CMakeLists.txt | 1 + src/box/alter.cc | 87 ++++++++---- src/box/bootstrap.snap | Bin 4374 -> 4393 bytes src/box/call.c | 2 +- src/box/func.c | 225 +++++++++++++++++++++++++++++- src/box/func.h | 21 ++- src/box/func_def.h | 10 +- src/box/lua/call.c | 122 +++++++--------- src/box/lua/call.h | 4 +- src/box/lua/init.c | 2 + src/box/lua/schema.lua | 8 +- src/box/lua/upgrade.lua | 15 ++ src/box/lua/util.c | 102 ++++++++++++++ src/box/lua/util.h | 59 ++++++++ src/box/schema.cc | 47 +++---- src/box/schema.h | 31 ++-- src/box/schema_def.h | 1 + test/box-py/bootstrap.result | 6 +- test/box/access_misc.result | 4 +- test/box/persistent_func.result | 185 ++++++++++++++++++++++++ test/box/persistent_func.test.lua | 83 +++++++++++ 21 files changed, 858 insertions(+), 157 deletions(-) create mode 100644 src/box/lua/util.c create mode 100644 src/box/lua/util.h create mode 100644 test/box/persistent_func.result create mode 100644 test/box/persistent_func.test.lua -- 2.21.0