{"record":{"id":"f7ecb344e96fe875","repo":"databendlabs/databend","slug":"failed-to-create-new-admin-client-function","errorCode":null,"errorMessage":"Failed to create new_admin_client function: {}","messagePattern":"Failed to create new_admin_client function: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/meta/control/src/lua_support.rs","lineNumber":416,"sourceCode":"                DEFAULT_GRPC_MESSAGE_SIZE,\n            )\n            .map_err(|e| mlua::Error::external(format!(\"Failed to create gRPC client: {}\", e)))?;\n\n            Ok(LuaGrpcClient::new(client))\n        })\n        .map_err(|e| anyhow::anyhow!(\"Failed to create new_grpc_client function: {}\", e))?;\n\n    metactl_table\n        .set(\"new_grpc_client\", new_grpc_client)\n        .map_err(|e| anyhow::anyhow!(\"Failed to register new_grpc_client: {}\", e))?;\n\n    // Register new_admin_client function\n    let new_admin_client = lua\n        .create_function(|_lua, address: String| {\n            let client = MetaAdminClient::new(&address);\n            Ok(LuaAdminClient::new(client))\n        })\n        .map_err(|e| anyhow::anyhow!(\"Failed to create new_admin_client function: {}\", e))?;\n\n    metactl_table\n        .set(\"new_admin_client\", new_admin_client)\n        .map_err(|e| anyhow::anyhow!(\"Failed to register new_admin_client: {}\", e))?;\n\n    // Export NULL constant to metactl namespace\n    metactl_table\n        .set(\"NULL\", Value::NULL)\n        .map_err(|e| anyhow::anyhow!(\"Failed to register NULL constant: {}\", e))?;\n\n    // Register spawn function that delegates to tokio::task::spawn_local\n    let spawn_fn = lua\n        .create_function(|_lua, func: mlua::Function| {\n            #[allow(clippy::disallowed_methods)]\n            let handle = tokio::task::spawn_local(async move {\n                match func.call_async::<mlua::Value>(()).await {\n                    Ok(result) => result,\n                    Err(e) => {","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/meta/control/src/lua_support.rs#L398-L434","documentation":"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.","triggerScenarios":"Lua function creation failing during environment setup while registering new_admin_client — mlua state corruption, allocation failure, or incompatible mlua build.","commonSituations":"Same family as other setup_lua_environment failures: constrained environments or inconsistent mlua feature flags in the metactl build.","solutions":["Rebuild metactl with a consistent mlua configuration","Free memory / raise container limits and retry","Upgrade to a newer metactl/mlua release","Verify no prior code has poisoned the Lua state"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match run_lua_script(&script) {\n    Err(e) if e.to_string().contains(\"Failed to create new_admin_client\") => {\n        eprintln!(\"Lua function creation failed: {e}; rebuild/retry\");\n    }\n    other => other?,\n}","preventionTips":["Pin tested mlua versions","Smoke-test admin-client scripting after upgrades","Ensure sufficient memory for Lua state creation","Avoid mixing mlua feature flags in the build"],"tags":["lua","mlua","admin-client","initialization"],"backgroundTag":"module-init-failed","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}