{"record":{"id":"6100244eb643e8c8","repo":"apache/dolphinscheduler","slug":"query-t-ds-process-definition-log-error","errorCode":null,"errorMessage":"Query t_ds_process_definition_log error","messagePattern":"Query t_ds_process_definition_log 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":222,"sourceCode":"    private Map<String, Object> getProcessDefinitionLogByCode(Long processDefinitionCode,\n                                                              Integer processDefinitionVersion) {\n        try (\n                Connection connection = dataSource.getConnection();\n                PreparedStatement preparedStatement = connection.prepareStatement(\n                        \"select  project_code from t_ds_process_definition_log where code = ? and version = ?\")) {\n            preparedStatement.setLong(1, processDefinitionCode);\n            preparedStatement.setInt(2, processDefinitionVersion);\n\n            try (ResultSet resultSet = preparedStatement.executeQuery()) {\n                while (resultSet.next()) {\n                    Map<String, Object> row = new HashMap<>();\n                    row.put(\"project_code\", resultSet.getLong(\"project_code\"));\n                    return row;\n                }\n            }\n            return Collections.emptyMap();\n        } catch (Exception ex) {\n            throw new RuntimeException(\"Query t_ds_process_definition_log error\", ex);\n        }\n    }\n\n    private Map<String, Object> getSchedulerByProcessDefinitionCode(Long processDefinitionCode) {\n        try (\n                Connection connection = dataSource.getConnection();\n                PreparedStatement preparedStatement = connection\n                        .prepareStatement(\"select  * from t_ds_schedules where process_definition_code = ?\")) {\n            preparedStatement.setLong(1, processDefinitionCode);\n\n            try (ResultSet resultSet = preparedStatement.executeQuery()) {\n                while (resultSet.next()) {\n                    Map<String, Object> row = new HashMap<>();\n                    row.put(\"tenant_code\", resultSet.getString(\"tenant_code\"));\n                    return row;\n                }\n            }\n            return Collections.emptyMap();","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/upgrader/v320/V320DolphinSchedulerUpgrader.java#L204-L240","documentation":"Thrown by V320DolphinSchedulerUpgrader.getProcessDefinitionLogByCode when the SELECT against t_ds_process_definition_log (by code and version) fails. The upgrade uses this to resolve project_code for orphaned process instances. JDBC exceptions are wrapped in this RuntimeException.","triggerScenarios":"Running the 3.2.0 upgrade when t_ds_process_definition_log is missing/renamed, the (code, version) columns are absent, or the DB connection fails inside processDefinitionLog lookup.","commonSituations":"Upgrading a DB whose history/log table is inconsistent or truncated; privilege-restricted DB account; vendor-specific SQL incompatibility.","solutions":["Check the wrapped cause for the exact JDBC error","Verify t_ds_process_definition_log exists with columns code, version, project_code","Grant the upgrade DB user SELECT on the table","Validate schema consistency against the 3.2.0 baseline before upgrading"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"try (Connection c = dataSource.getConnection();\n     ResultSet rs = c.createStatement().executeQuery(\n         \"select code, version, project_code from t_ds_process_definition_log where 1=0\")) {\n} catch (SQLException e) {\n    throw new IllegalStateException(\"t_ds_process_definition_log schema mismatch: \" + 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_process_definition_log error\")) {\n        log.error(\"Definition log lookup failed: {}\", e.getCause(), e);\n    } else { throw e; }\n}","preventionTips":["Validate log table existence and columns before upgrading","Ensure upgrade account has SELECT on definition log tables","Keep the metadata DB schema consistent with the version being upgraded from"],"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-14T00:17:10.932Z"}