databendlabs/databend · error

Failed to register new_admin_client

Error message

Failed to register new_admin_client: {}

What it means

Setting the created new_admin_client function onto the `metactl` Lua table failed. This is the registration step after create_function; mlua's set() returned an error which is wrapped in this message.

Solutions

  1. Use the standard metactl Lua environment without sandbox write restrictions
  2. Rebuild with consistent mlua features
  3. Retry after resolving memory issues
  4. Upgrade metactl/mlua if the failure is a known regression
Defensive patterns

Strategy: try-catch

Try / catch

match run_lua_script(&script) {
    Err(e) if e.to_string().contains("Failed to register new_admin_client") => {
        eprintln!("metactl table write failed: {e}; check for sandboxing or corrupted state");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Lua table key assignment failing during setup — read-only or corrupted table, mlua incompatibilities, or memory exhaustion.

Common situations: Custom/sandboxed Lua states that block writes, broken mlua builds, OOM conditions while scripting with metactl.

Related errors


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

Appendix: source

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

            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) => {
                        eprintln!("Spawned task error: {}", e);
                        mlua::Value::Nil
                    }
                }

View on GitHub (pinned to 288d84d76e)