I want to implement an init function under box.once() to be executed only once in Tarantool, however, this is useful to me only if init has been executed successfully.
Question: How can I make the "onceinit" record valid only if init has run successfully??
To reproduce the case:
The following code of the init function fails because there is no create_space_BAD function, however, when scanning the schema it is registered as executed.
Any suggestions on how to fix this?
The code:
local function start()
box.cfg{}
box.once('init', function()
if not pcall(box.schema.create_space_BAD, 'myspace') then
print('ERROR: create_space_BAD NOT EXIST')
return false
end
...
end)
end
Explore schema:
tarantool> box.space._schema:select{}
---
- - ['cluster', '1cb21086-51a3-46fb-900e-1983609fc396']
- ['max_id', 511]
- ['onceinit']
- ['version', 1, 10, 2]
...