databendlabs/databend · error
Failed to register metactl namespace
Error message
Failed to register metactl namespace: {} What it means
After all members are registered, the `metactl` table itself is assigned as a global with `lua.globals().set("metactl", metactl_table)`. If mlua fails to store the table into the globals table, the error is wrapped as `Failed to register metactl namespace` and setup aborts.
Solutions
- Inspect the inner mlua error; memory/stack errors mean the Lua instance should be recreated.
- Check that no earlier script enabled a sandbox/readonly-globals mode that blocks `globals().set`.
- Ensure `metactl_table` was created in the same Lua instance whose globals are being set.
- Increase or drop custom MemoryLimits; if still failing, report the inner error against mlua.
Defensive patterns
Strategy: try-catch
Try / catch
match setup_lua_environment(&lua) {
Err(e) if e.to_string().contains("Failed to register metactl namespace") => {
// sandbox/globals or state problem: rebuild environment
}
other => other?,
} Prevention
- Do not enable global-locking/sandbox scripts before this registration runs.
- Keep all registration on the same Lua instance.
- Avoid restrictive MemoryLimits.
- Preserve the inner mlua error for diagnosis.
When it happens
Trigger: `lua.globals().set("metactl", metactl_table)` returning an mlua error during `setup_lua_environment`, before `LUA_UTIL` is loaded.
Common situations: Lua stack/memory exhaustion, a globals table that has been locked or replaced by sandboxing code, or values from a mismatched Lua instance.
Related errors
- Failed to create now_ms function
- Failed to create sleep function
- Failed to create spawn function
- Failed to register now_ms function
- Failed to register sleep function
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/f02430f483d0fa86.
Report an issue: GitHub.
Appendix: source
Thrown at src/meta/control/src/lua_support.rs:491
.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!(
"Using gRPC API address: {}",
serde_json::to_string(&addresses).unwrap()
);
MetaGrpcClient::try_create(
addresses,View on GitHub (pinned to 288d84d76e)