Skip to content

Race condition running init.lua #53

@kostja

Description

@kostja

init.lua is executed before the server binds to primary/secondary ports, but can insert data, create connections, etc. - in other words, requires a running event loop.

In fact there is no running event loop, and first and any yield in init.lua script takes it off execution and the script is only resumed after general loading is complete, as part of the main server loop.

This creates ugly race conditions, when parts of init.lua are executed concurrently with insert/update/delete requests on the server port.

How to repeat:

add box.fiber.sleep(10000) into init.lua and observe the server doesn't sleep,
but starts and runs

Or:
add box.fiber.sleep() followed by box.insert(), and observe that at start
there is no tuple inserted into the space, i.e. init.lua is not finished before the main loop begins.

How to fix:

In tarantool_lua_load_init_script run the event loop until the init script completes. Then break the loop, finish bootstrap and resume the loop.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions