databendlabs/databend · error
Failed to create new_grpc_client function
Error message
Failed to create new_grpc_client function: {} What it means
setup_lua_environment registers a `new_grpc_client` Lua function that constructs a MetaGrpcClient. If mlua's create_function fails to wrap the Rust closure, this anyhow error is raised before the function is attached to the metactl table.
Solutions
- Rebuild metactl with a consistent mlua version/feature set
- Retry after resolving memory constraints
- Upgrade to a release where mlua create_function issues are fixed
- Check that no other component corrupted the shared Lua state before setup
Defensive patterns
Strategy: try-catch
Try / catch
match run_lua_script(&script) {
Err(e) if e.to_string().contains("Failed to create new_grpc_client") => {
eprintln!("Lua function registration failed: {e}; rebuild/retry");
}
other => other?,
} Prevention
- Pin a known-good mlua version
- Avoid custom Lua sandboxes around the metactl state
- Verify Lua scripting works after each binary upgrade
- Monitor memory limits in containers running metactl
When it happens
Trigger: Lua environment setup failing at function creation — normally due to mlua state problems, memory pressure, or incompatible mlua/runtime versions in the build.
Common situations: Running metactl Lua scripts in builds where the mlua feature set or Lua runtime is broken; heavily constrained environments.
Related errors
- Failed to create metactl table
- 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/e3252ea09d3f8bba.
Report an issue: GitHub.
Appendix: source
Thrown at src/meta/control/src/lua_support.rs:404
.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))?;
metactl_table
.set("new_grpc_client", new_grpc_client)
.map_err(|e| anyhow::anyhow!("Failed to register new_grpc_client: {}", e))?;
// Register new_admin_client function
let new_admin_client = lua
.create_function(|_lua, address: String| {
let client = MetaAdminClient::new(&address);
Ok(LuaAdminClient::new(client))
})
.map_err(|e| anyhow::anyhow!("Failed to create new_admin_client function: {}", e))?;
metactl_table
.set("new_admin_client", new_admin_client)
.map_err(|e| anyhow::anyhow!("Failed to register new_admin_client: {}", e))?;
// Export NULL constant to metactl namespaceView on GitHub (pinned to 288d84d76e)