{"record":{"id":"a03480de25af2b90","repo":"databendlabs/databend","slug":"failed-to-create-metactl-table","errorCode":null,"errorMessage":"Failed to create metactl table: {}","messagePattern":"Failed to create metactl table: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/meta/control/src/lua_support.rs","lineNumber":386,"sourceCode":"                    Err(e) => {\n                        eprintln!(\"Join error: {}\", e);\n                        Ok(mlua::Value::Nil)\n                    }\n                },\n                None => {\n                    eprintln!(\"Handle already consumed - task was already awaited\");\n                    Ok(mlua::Value::Nil)\n                }\n            }\n        });\n    }\n}\n\npub fn setup_lua_environment(lua: &Lua) -> anyhow::Result<()> {\n    // Create metactl table to namespace all functions\n    let metactl_table = lua\n        .create_table()\n        .map_err(|e| anyhow::anyhow!(\"Failed to create metactl table: {}\", e))?;\n\n    // Register new_grpc_client function\n    let new_grpc_client = lua\n        .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))?;","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/meta/control/src/lua_support.rs#L368-L404","documentation":"setup_lua_environment creates the `metactl` Lua table that namespaces helper functions for Lua scripting. If mlua's create_table fails (typically an internal Lua state/allocation error), the failure is wrapped in this anyhow error.","triggerScenarios":"Calling run_lua_script / run_lua_script_with_result (or the Lua tests) when the mlua Lua state is corrupt, out of memory, or the runtime was misinitialized.","commonSituations":"Embedding metactl Lua scripting in constrained environments (OOM), or building mlua without a compatible Lua runtime feature flag so state creation misbehaves.","solutions":["Retry the command; transient allocation/OOM issues usually resolve after freeing memory","Check memory limits of the container/machine running metactl","Verify the mlua feature flags of the build are consistent (correct Lua version feature)","Update to a newer metactl/mlua version if the Lua state initialization is known-buggy"],"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 metactl table\") => {\n        eprintln!(\"Lua environment init failed (state/memory): {e}; retry or fix mlua build\");\n    }\n    other => other?,\n}","preventionTips":["Run Lua-scripted metactl in environments with adequate memory","Keep mlua feature flags consistent across the workspace build","Upgrade metactl/mlua together to tested versions","Smoke-test `metactl` Lua scripting once after each deployment"],"tags":["lua","initialization","mlua"],"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"}