databendlabs/databend · error
Lua execution error
Error message
Lua execution error: {} What it means
When executing an embedded Lua script (via the mlua async runtime), any Lua runtime/compile error is mapped to 'Lua execution error: {}'. metactl uses Lua scripts to fetch data from admin APIs; a script failure means the requested operation could not complete.
Solutions
- Inspect the wrapped message for the underlying Lua error and fix the script or its inputs
- Confirm the target admin API address is correct and responding before running the script
- Report/upgrade if a shipped script fails against a newer metasrv version
Defensive patterns
Strategy: try-catch
Validate before calling
curl -sf http://<admin-api-address>/v1/health || echo 'target admin api down; lua script will fail'
Try / catch
run_lua_script_with_result(&lua_script)
.await
.map_err(|e| eprintln!("Lua execution error: {}; verify admin api and script", e)) Prevention
- Test Lua scripts against a live admin API before production use
- Pin metactl and metasrv versions together
- Include HTTP status checks inside the script with clear Lua error messages
When it happens
Trigger: Calling metactl commands that run Lua (e.g. metrics/status collection) when the script fails to compile or raises a Lua error, such as an HTTP error inside the script or invalid response handling.
Common situations: Target metasrv returning error bodies the script doesn't expect; admin API unreachable from inside the Lua script; internal script bugs from custom/modified scripts.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- Failed to get metrics
- invalid peer raft addr
- node id ( ) has to be one of cluster member( )
- Failed to convert RaftStoreEntry to SMEntry
- Failed to create metactl table
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/c87cc2b8e72947ae.
Report an issue: GitHub.
Appendix: source
Thrown at src/meta/binaries/metactl/main.rs:341
fn new_grpc_client(
&self,
addresses: Vec<String>,
) -> Result<Arc<ClientHandle<DatabendRuntime>>, CreationError> {
lua_support::new_grpc_client(addresses)
}
}
#[allow(clippy::disallowed_types)]
async fn execute_lua_script(
lua: &Lua,
local: &tokio::task::LocalSet,
script: &str,
) -> anyhow::Result<()> {
local
.run_until(lua.load(script).exec_async())
.await
.map_err(|e| anyhow::anyhow!("Lua execution error: {}", e))
}
#[derive(Debug, Clone, Deserialize, Subcommand)]
enum CtlCommand {
#[command(verbatim_doc_comment)]
/// Show cluster status: node info, replication, voters, etc.
///
/// Example:
/// metactl status --grpc-api-address 127.0.0.1:9191
///
/// Sample output:
/// BinaryVersion: v1.2.345-nightly-abc1234(rust-1.75-nightly-2024-01-01T12:00:00)
/// DataVersion: V002
/// RaftLogSize: 1234
/// SnapshotKeyCount: 5678
/// Node: id=0 raft=127.0.0.1:28004
/// State: Leader
/// Leader: Node { name: "0", endpoint: 127.0.0.1:28004 }View on GitHub (pinned to 288d84d76e)