{"record":{"id":"d25b0ce1a06d8d59","repo":"apache/dolphinscheduler","slug":"query-t-ds-user-error","errorCode":null,"errorMessage":"Query t_ds_user error","messagePattern":"Query t_ds_user error","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/upgrader/v320/V320DolphinSchedulerUpgrader.java","lineNumber":157,"sourceCode":"            return processInstanceList;\n        } catch (Exception ex) {\n            throw new RuntimeException(\"Query t_ds_process_instance error\", ex);\n        }\n\n    }\n\n    private Map<Integer, String> getUserMap() {\n        Map<Integer, String> userMap = new HashMap<>();\n        try (\n                Connection connection = dataSource.getConnection();\n                PreparedStatement preparedStatement =\n                        connection.prepareStatement(\"select id, user_name from t_ds_user\");\n                ResultSet resultSet = preparedStatement.executeQuery()) {\n            while (resultSet.next()) {\n                userMap.put(resultSet.getInt(\"id\"), resultSet.getString(\"user_name\"));\n            }\n        } catch (Exception ex) {\n            throw new RuntimeException(\"Query t_ds_user error\", ex);\n        }\n        return userMap;\n    }\n\n    private List<Map<String, Object>> getProcessInstanceWhichProjectCodeIsNull() {\n        List<Map<String, Object>> processInstanceList = new ArrayList<>();\n        try (\n                Connection connection = dataSource.getConnection();\n                PreparedStatement preparedStatement = connection.prepareStatement(\n                        \"select id, process_definition_code, process_definition_version, executor_id from t_ds_process_instance where project_code is null limit 1000\");\n                ResultSet resultSet = preparedStatement.executeQuery()) {\n            while (resultSet.next()) {\n                Map<String, Object> row = new HashMap<>();\n                row.put(\"id\", resultSet.getInt(\"id\"));\n                row.put(\"process_definition_code\", resultSet.getLong(\"process_definition_code\"));\n                row.put(\"process_definition_version\", resultSet.getInt(\"process_definition_version\"));\n                row.put(\"executor_id\", resultSet.getInt(\"executor_id\"));\n                processInstanceList.add(row);","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/upgrader/v320/V320DolphinSchedulerUpgrader.java#L139-L175","documentation":"Thrown by V320DolphinSchedulerUpgrader.getUserMap when the JDBC query 'select id, user_name from t_ds_user' fails. The upgrader needs the id->user_name map to resolve executor names while backfilling project_code. Any exception in the query is wrapped in this RuntimeException.","triggerScenarios":"Running the v3.2.0 upgrade when t_ds_user does not exist, the DB user lacks SELECT on it, or the connection/driver fails during getUserMap.","commonSituations":"Upgrading against a metadata DB from a different/older version missing t_ds_user; restricted DB account; transient connection loss mid-upgrade.","solutions":["Inspect the 'Caused by' exception for the underlying JDBC error","Verify the DB account can SELECT from t_ds_user","Confirm t_ds_user exists in the schema being upgraded (correct database/schema selected)","Check DB availability and re-run the upgrade tool"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"try (Connection c = dataSource.getConnection();\n     Statement s = c.createStatement()) {\n    s.executeQuery(\"select id, user_name from t_ds_user limit 1\");\n} catch (SQLException e) {\n    throw new IllegalStateException(\"t_ds_user not readable: \" + e.getMessage(), e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    upgrader.upgrade();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Query t_ds_user error\")) {\n        log.error(\"Cannot read t_ds_user: {}\", e.getCause(), e);\n    } else { throw e; }\n}","preventionTips":["Grant SELECT on t_ds_user to the migration DB account","Confirm the target database/schema name in config points at the real metadata DB","Test connectivity with the same JDBC driver version used by the tool"],"tags":["database","jdbc","upgrade","sql"],"backgroundTag":"database-query-failed","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}