databendlabs/databend · error
Failed to register ZipfGenerator
Error message
Failed to register ZipfGenerator: {} What it means
Once evaluated, the ZipfGenerator table is stored into `metactl` via `Table::set`. If mlua cannot push or store that table value, the error is wrapped as `Failed to register ZipfGenerator` and Lua environment setup fails.
Solutions
- Check the inner mlua error; recreate the Lua state for memory/stack failures.
- Ensure `zipf_generator` and `metactl_table` were produced by the same `Lua` instance.
- Raise or remove custom MemoryLimits on the Lua runtime if memory errors appear.
- If reproducible on a clean state, capture the inner error and report/upgrade mlua.
Defensive patterns
Strategy: try-catch
Try / catch
if let Err(e) = setup_lua_environment(&lua) {
if e.to_string().contains("Failed to register ZipfGenerator") {
// rebuild Lua state; inspect inner mlua error
}
} Prevention
- Use one Lua instance for chunk evaluation and table registration.
- Avoid tight MemoryLimits on the runtime.
- Rebuild the Lua state after any fatal script error.
- Keep the full mlua error chain in logs.
When it happens
Trigger: `metactl_table.set("ZipfGenerator", zipf_generator)` returning an mlua error during `setup_lua_environment` (any `run_lua_script`/`run_lua_script_with_result` call or its tests).
Common situations: Lua stack or memory exhaustion in the shared runtime, or value/table belonging to a different Lua instance than the target table.
Related errors
- Failed to create now_ms function
- Failed to create sleep function
- Failed to create spawn function
- Failed to register metactl namespace
- Failed to register now_ms function
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/a39db0294eedab7c.
Report an issue: GitHub.
Appendix: source
Thrown at src/meta/control/src/lua_support.rs:486
let now_ms_fn = lua
.create_function(move |_lua, ()| Ok(start.elapsed().as_secs_f64() * 1000.0))
.map_err(|e| anyhow::anyhow!("Failed to create now_ms function: {}", e))?;
metactl_table
.set("now_ms", now_ms_fn)
.map_err(|e| anyhow::anyhow!("Failed to register now_ms function: {}", e))?;
// Register the Zipf load generator. The module returns the `ZipfGenerator`
// table, exposed as `metactl.ZipfGenerator` so any script can call
// `metactl.ZipfGenerator:new(num_keys, alpha)` directly.
let zipf_generator = lua
.load(ZIPF_LOAD_GENERATOR)
.eval::<Table>()
.map_err(|e| anyhow::anyhow!("Failed to load zipf_load_generator: {}", e))?;
metactl_table
.set("ZipfGenerator", zipf_generator)
.map_err(|e| anyhow::anyhow!("Failed to register ZipfGenerator: {}", e))?;
// Set the metactl table as a global
lua.globals()
.set("metactl", metactl_table)
.map_err(|e| anyhow::anyhow!("Failed to register metactl namespace: {}", e))?;
// Load lua_util functions (which registers to_string in metactl namespace)
lua.load(LUA_UTIL)
.exec()
.map_err(|e| anyhow::anyhow!("Failed to load lua_util functions: {}", e))?;
Ok(())
}
pub fn new_grpc_client(
addresses: Vec<String>,
) -> Result<Arc<ClientHandle<DatabendRuntime>>, CreationError> {
eprintln!(View on GitHub (pinned to 288d84d76e)