Skip to content

Draft: feature: picolib.once_exec

Alexey Protsenko requested to merge feature/cluster-once into master

Implement a new function:

picolib.once_exec(timeout_millis, once_id, lua_code) -> Result<bool, LuaError>

Executes the following actions within the timeout:

  1. Checks if once_id is already registered in raft_state and returns if it is.
  2. "Validates" the lua code using box.begin(); <lua_code> ; box.rollback (). This is supposed to catch lua syntax errors and errors related to box API like creating an already existing space. Assumes the side effects of the lua_code can be rolled back.
  3. Proposes a Raft entry with lua_code to the Raft leader.
  4. Waits until the proposed Raft entry is committed in the cluster and the Raft commit handler for this entry executes the lua_code and registers once_id in the same transaction.
Edited by Alexey Protsenko

Merge request reports