databendlabs/databend · error
Failed to create metactl table
Error message
Failed to create metactl table: {} What it means
setup_lua_environment creates the `metactl` Lua table that namespaces helper functions for Lua scripting. If mlua's create_table fails (typically an internal Lua state/allocation error), the failure is wrapped in this anyhow error.
Solutions
- Retry the command; transient allocation/OOM issues usually resolve after freeing memory
- Check memory limits of the container/machine running metactl
- Verify the mlua feature flags of the build are consistent (correct Lua version feature)
- Update to a newer metactl/mlua version if the Lua state initialization is known-buggy
Defensive patterns
Strategy: try-catch
Try / catch
match run_lua_script(&script) {
Err(e) if e.to_string().contains("Failed to create metactl table") => {
eprintln!("Lua environment init failed (state/memory): {e}; retry or fix mlua build");
}
other => other?,
} Prevention
- Run Lua-scripted metactl in environments with adequate memory
- Keep mlua feature flags consistent across the workspace build
- Upgrade metactl/mlua together to tested versions
- Smoke-test `metactl` Lua scripting once after each deployment
When it happens
Trigger: Calling run_lua_script / run_lua_script_with_result (or the Lua tests) when the mlua Lua state is corrupt, out of memory, or the runtime was misinitialized.
Common situations: Embedding metactl Lua scripting in constrained environments (OOM), or building mlua without a compatible Lua runtime feature flag so state creation misbehaves.
Related errors
- Failed to create new_grpc_client function
- Failed to create new_admin_client function
- Failed to register new_grpc_client
- Failed to register new_admin_client
- Failed to register NULL constant
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/a03480de25af2b90.
Report an issue: GitHub.
Appendix: source
Thrown at src/meta/control/src/lua_support.rs:386
Err(e) => {
eprintln!("Join error: {}", e);
Ok(mlua::Value::Nil)
}
},
None => {
eprintln!("Handle already consumed - task was already awaited");
Ok(mlua::Value::Nil)
}
}
});
}
}
pub fn setup_lua_environment(lua: &Lua) -> anyhow::Result<()> {
// Create metactl table to namespace all functions
let metactl_table = lua
.create_table()
.map_err(|e| anyhow::anyhow!("Failed to create metactl table: {}", e))?;
// Register new_grpc_client function
let new_grpc_client = lua
.create_function(move |_lua, address: String| {
let client = MetaGrpcClient::try_create(
vec![address],
"root",
"xxx",
Some(Duration::from_secs(2)),
Some(Duration::from_secs(1)),
None,
DEFAULT_GRPC_MESSAGE_SIZE,
)
.map_err(|e| mlua::Error::external(format!("Failed to create gRPC client: {}", e)))?;
Ok(LuaGrpcClient::new(client))
})
.map_err(|e| anyhow::anyhow!("Failed to create new_grpc_client function: {}", e))?;View on GitHub (pinned to 288d84d76e)