{"record":{"id":"a20229150d79b049","repo":"databendlabs/databend","slug":"failed-to-register-new-grpc-client","errorCode":null,"errorMessage":"Failed to register new_grpc_client: {}","messagePattern":"Failed to register new_grpc_client: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/meta/control/src/lua_support.rs","lineNumber":408,"sourceCode":"        .create_function(move |_lua, address: String| {\n            let client = MetaGrpcClient::try_create(\n                vec![address],\n                \"root\",\n                \"xxx\",\n                Some(Duration::from_secs(2)),\n                Some(Duration::from_secs(1)),\n                None,\n                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","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/meta/control/src/lua_support.rs#L390-L426","documentation":"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.","triggerScenarios":"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.","commonSituations":"Broken or tampered Lua environments, custom Lua sandboxes that forbid table writes, mlua version incompatibilities.","solutions":["Ensure the Lua environment is the plain mlua state created by setup_lua_environment (no sandbox forbidding writes)","Rebuild with matching mlua version features","Retry after resolving memory issues","Update metactl if the mlua set() failure is a known bug"],"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 register new_grpc_client\") => {\n        eprintln!(\"metactl table registration failed: {e}; check Lua env integrity\");\n    }\n    other => other?,\n}","preventionTips":["Do not wrap the metactl Lua state in write-restricted sandboxes","Create the environment fresh per run via setup_lua_environment","Keep mlua versions aligned between dependencies","Add a post-setup assertion that metactl.new_grpc_client exists in CI"],"tags":["lua","mlua","registration"],"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"}