{"record":{"id":"ee96d9ea9f1af7da","repo":"t8y2/dbx","slug":"show-databases-failed-v-hiveserver2-metadata-f","errorCode":null,"errorMessage":"SHOW DATABASES failed (%v); HiveServer2 metadata fallback failed: %w","messagePattern":"SHOW DATABASES failed \\((.+?)\\); HiveServer2 metadata fallback failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/argo-go/metadata.go","lineNumber":242,"sourceCode":"\t\t\t\"productVersion\":         version,\n\t\t\t\"unquotedIdentifierCase\": \"mixed\",\n\t\t\t\"quotedIdentifierCase\":   \"mixed\",\n\t\t\t\"driverName\":             driverName,\n\t\t\t\"driverVersion\":          \"gohive-v2.1.0\",\n\t\t},\n\t}, nil\n}\n\nfunc (server *server) listDatabases() ([]databaseInfo, error) {\n\tresult, err := server.executeQuery(queryOptions{SQL: \"SHOW DATABASES\", MaxRows: metadataQueryLimit})\n\tif err == nil {\n\t\treturn databaseInfoFromQueryRows(result.Rows), nil\n\t}\n\tmetadataResult, metadataErr := server.hiveMetadata(func(ctx context.Context, provider gohive.MetadataProvider) (gohive.MetadataResult, error) {\n\t\treturn provider.GetHiveSchemas(ctx, \"%\")\n\t})\n\tif metadataErr != nil {\n\t\treturn nil, fmt.Errorf(\"SHOW DATABASES failed (%v); HiveServer2 metadata fallback failed: %w\", err, metadataErr)\n\t}\n\trows := newHiveMetadataRows(metadataResult)\n\tvalues := make([]databaseInfo, 0, len(rows.rows))\n\tseen := map[string]bool{}\n\tfor _, row := range rows.rows {\n\t\tname := metadataString(rows.value(row, \"TABLE_SCHEM\", \"SCHEMA_NAME\"))\n\t\tif name == \"\" || seen[name] {\n\t\t\tcontinue\n\t\t}\n\t\tseen[name] = true\n\t\tvalues = append(values, databaseInfo{Name: name})\n\t}\n\tsort.Slice(values, func(first, second int) bool { return values[first].Name < values[second].Name })\n\treturn values, nil\n}\n\nfunc databaseInfoFromQueryRows(rows [][]any) []databaseInfo {\n\tvalues := make([]databaseInfo, 0, len(rows))","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/argo-go/metadata.go#L224-L260","documentation":"listDatabases first tries 'SHOW DATABASES' via direct SQL; if that fails it falls back to the HiveServer2 JDBC metadata API (GetHiveSchemas). This error is produced only when BOTH paths fail, wrapping the original SHOW DATABASES error (%v) and the metadata fallback error (%w). It means the driver could not enumerate databases at all.","triggerScenarios":"Calling the 'metadata'/list_databases dispatch method when the server rejects 'SHOW DATABASES' (syntax not supported, insufficient privileges) AND the HiveServer2 GetHiveSchemas metadata call also fails (connection dropped, unsupported catalog, permission denied).","commonSituations":"Connecting to non-Hive backends (Kyuubi/Impala variants or restricted ArgoDB roles) where SHOW DATABASES is denied; stale connections after HiveServer2 restart; user lacking schema-list privileges; network interruption mid-metadata call.","solutions":["Re-run SHOW DATABASES manually as the same user to see the root cause error in the (%v) portion.","Check the user's privileges to list databases/schemas on the HiveServer2 instance.","Reconnect — the fallback often fails because the underlying session died; test_connection to verify connectivity.","If SHOW DATABASES is unsupported by the backend, verify this agent targets ArgoDB; use the hive-go driver for vanilla Hive/Kyuubi/Impala."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: confirm the connection can run trivial queries and the user can list databases.\nif _, err := server.executeQuery(queryOptions{SQL: \"SELECT 1\", MaxRows: 1}); err != nil {\n    return fmt.Errorf(\"connection not usable before listing databases: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"dbs, err := server.listDatabases()\nif err != nil {\n    var cause error\n    if errors.As(err, &cause) {\n        log.Printf(\"listDatabases failed; wrapped cause: %v\", cause)\n    }\n    // treat as connectivity/permission problem: surface both causes to the operator\n    return fmt.Errorf(\"cannot enumerate databases; check privileges and HiveServer2 health: %w\", err)\n}","preventionTips":["Verify the connecting user has privileges to list databases/schemas before building features on top.","Call test_connection before metadata operations to catch dead sessions early.","Run SHOW DATABASES manually as the same user when onboarding a new role or service account.","Use the argo agent only for ArgoDB backends; route vanilla Hive/Kyuubi/Impala to hive-go."],"tags":["hive","metadata","fallback","privileges"],"backgroundTag":"metadata-query-failed","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}