{"record":{"id":"e804d6f9b6837219","repo":"apache/seatunnel","slug":"list-databases-failed","errorCode":"LIST_DATABASES_FAILED","errorMessage":"Cannot list databases from clickhouse","messagePattern":"Cannot list databases from clickhouse","errorType":"error_code","errorClass":"ClickhouseConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/util/ClickhouseProxy.java","lineNumber":332,"sourceCode":"                        \"select count(1) from system.tables where database = '%s' and name = '%s'\",\n                        database, table);\n        try (ClickHouseResponse response = clickhouseRequest.query(sql).executeAndWait()) {\n            return response.firstRecord().getValue(0).asInteger() > 0;\n        } catch (ClickHouseException e) {\n            throw new ClickhouseConnectorException(\n                    SeaTunnelAPIErrorCode.TABLE_NOT_EXISTED, \"Cannot get table from clickhouse\", e);\n        }\n    }\n\n    public List<String> listDatabases() {\n        String sql = \"select distinct database from system.tables\";\n        try (ClickHouseResponse response = clickhouseRequest.query(sql).executeAndWait()) {\n            Iterable<ClickHouseRecord> records = response.records();\n            return StreamSupport.stream(records.spliterator(), false)\n                    .map(r -> r.getValue(0).asString())\n                    .collect(Collectors.toList());\n        } catch (ClickHouseException e) {\n            throw new ClickhouseConnectorException(\n                    SeaTunnelAPIErrorCode.LIST_DATABASES_FAILED,\n                    \"Cannot list databases from clickhouse\",\n                    e);\n        }\n    }\n\n    public List<String> listTable(String database) {\n        String sql = \"SELECT name FROM system.tables WHERE database = '\" + database + \"'\";\n        try (ClickHouseResponse response = clickhouseRequest.query(sql).executeAndWait()) {\n            Iterable<ClickHouseRecord> records = response.records();\n            return StreamSupport.stream(records.spliterator(), false)\n                    .map(r -> r.getValue(0).asString())\n                    .collect(Collectors.toList());\n        } catch (ClickHouseException e) {\n            throw new ClickhouseConnectorException(\n                    SeaTunnelAPIErrorCode.LIST_TABLES_FAILED,\n                    \"Cannot list tables from clickhouse\",\n                    e);","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/util/ClickhouseProxy.java#L314-L350","documentation":"ClickhouseProxy.listDatabases runs 'select distinct database from system.tables' and wraps ClickHouseException into a ClickhouseConnectorException with SeaTunnelAPIErrorCode.LIST_DATABASES_FAILED. It means the connector could not enumerate databases from the server.","triggerScenarios":"Calling listDatabases when the query against system.tables fails due to connection errors, authentication failure, or insufficient privileges.","commonSituations":"Wrong host/port/credentials in config; user denied access to system tables; ClickHouse server restarting during catalog exploration (e.g. while building table/file source configs).","solutions":["Verify connection parameters and test with clickhouse-client","Grant SHOW DATABASES / access to system.tables for the user","Retry after confirming the ClickHouse server is healthy","Check proxy/firewall rules if connections to port 8123/9000 are blocked"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// connectivity probe\nproxy.getClickHouseColumns(\"system.one\"); // throws early if the server is unreachable","typeGuard":null,"tryCatchPattern":"try {\n    return proxy.listDatabases();\n} catch (ClickhouseConnectorException e) {\n    if (SeaTunnelAPIErrorCode.LIST_DATABASES_FAILED.equals(e.getSeaTunnelAPIErrorCode())) {\n        return retryWithBackoff(3, () -> proxy.listDatabases());\n    }\n    throw e;\n}","preventionTips":["Verify ClickHouse server health before catalog operations","Confirm SHOW DATABASES privilege for the job user","Retry transient network failures with backoff","Keep server version's system.tables schema in mind when querying"],"tags":["clickhouse","catalog","metadata"],"backgroundTag":"database-query-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}