databendlabs/databend · error

Failed to create new_admin_client function

Error message

Failed to create new_admin_client function: {}

What it means

Raised in setup_lua_environment if wrapping the new_admin_client closure with lua.create_function fails. This closure builds a MetaAdminClient from a Lua-supplied address; failure here means the mlua runtime could not turn the Rust closure into a Lua function, so the admin-client helper is unavailable and setup is aborted.

Solutions

  1. Rebuild metactl with a consistent mlua configuration
  2. Free memory / raise container limits and retry
  3. Upgrade to a newer metactl/mlua release
  4. Verify no prior code has poisoned the Lua state
Defensive patterns

Strategy: try-catch

Try / catch

match run_lua_script(&script) {
    Err(e) if e.to_string().contains("Failed to create new_admin_client") => {
        eprintln!("Lua function creation failed: {e}; rebuild/retry");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Lua function creation failing during environment setup while registering new_admin_client — mlua state corruption, allocation failure, or incompatible mlua build.

Common situations: Same family as other setup_lua_environment failures: constrained environments or inconsistent mlua feature flags in the metactl build.

Related errors


AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11). Data as JSON: /api/errors/f7ecb344e96fe875. Report an issue: GitHub.

Appendix: source

Thrown at src/meta/control/src/lua_support.rs:416

                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 namespace
    metactl_table
        .set("NULL", Value::NULL)
        .map_err(|e| anyhow::anyhow!("Failed to register NULL constant: {}", e))?;

    // Register spawn function that delegates to tokio::task::spawn_local
    let spawn_fn = lua
        .create_function(|_lua, func: mlua::Function| {
            #[allow(clippy::disallowed_methods)]
            let handle = tokio::task::spawn_local(async move {
                match func.call_async::<mlua::Value>(()).await {
                    Ok(result) => result,
                    Err(e) => {

View on GitHub (pinned to 288d84d76e)