databendlabs/databend · error

Failed to register new_grpc_client

Error message

Failed to register new_grpc_client: {}

What it means

Raised in setup_lua_environment when the metactl_table.set("new_grpc_client", ...) registration of the Lua helper function fails. The helper itself already created a MetaGrpcClient from a Lua-supplied address; this error only occurs if the Lua runtime rejects storing the function into the metactl table, and it aborts Lua environment setup.

Solutions

  1. Ensure the Lua environment is the plain mlua state created by setup_lua_environment (no sandbox forbidding writes)
  2. Rebuild with matching mlua version features
  3. Retry after resolving memory issues
  4. Update metactl if the mlua set() failure is a known bug
Defensive patterns

Strategy: try-catch

Try / catch

match run_lua_script(&script) {
    Err(e) if e.to_string().contains("Failed to register new_grpc_client") => {
        eprintln!("metactl table registration failed: {e}; check Lua env integrity");
    }
    other => other?,
}

Prevention

When it happens

Trigger: metactl table is read-only, non-table, or the Lua state is corrupted when setting the key; also mlua key-setting failures under memory pressure.

Common situations: Broken or tampered Lua environments, custom Lua sandboxes that forbid table writes, mlua version incompatibilities.

Related errors


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

Appendix: source

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

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

View on GitHub (pinned to 288d84d76e)