apache/dolphinscheduler · error · RuntimeException

Query t_ds_process_definition_log error

Error message

Query t_ds_process_definition_log error

What it means

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.

Source

Thrown at dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/upgrader/v320/V320DolphinSchedulerUpgrader.java:222

    private Map<String, Object> getProcessDefinitionLogByCode(Long processDefinitionCode,
                                                              Integer processDefinitionVersion) {
        try (
                Connection connection = dataSource.getConnection();
                PreparedStatement preparedStatement = connection.prepareStatement(
                        "select  project_code from t_ds_process_definition_log where code = ? and version = ?")) {
            preparedStatement.setLong(1, processDefinitionCode);
            preparedStatement.setInt(2, processDefinitionVersion);

            try (ResultSet resultSet = preparedStatement.executeQuery()) {
                while (resultSet.next()) {
                    Map<String, Object> row = new HashMap<>();
                    row.put("project_code", resultSet.getLong("project_code"));
                    return row;
                }
            }
            return Collections.emptyMap();
        } catch (Exception ex) {
            throw new RuntimeException("Query t_ds_process_definition_log error", ex);
        }
    }

    private Map<String, Object> getSchedulerByProcessDefinitionCode(Long processDefinitionCode) {
        try (
                Connection connection = dataSource.getConnection();
                PreparedStatement preparedStatement = connection
                        .prepareStatement("select  * from t_ds_schedules where process_definition_code = ?")) {
            preparedStatement.setLong(1, processDefinitionCode);

            try (ResultSet resultSet = preparedStatement.executeQuery()) {
                while (resultSet.next()) {
                    Map<String, Object> row = new HashMap<>();
                    row.put("tenant_code", resultSet.getString("tenant_code"));
                    return row;
                }
            }
            return Collections.emptyMap();

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check the wrapped cause for the exact JDBC error
  2. Verify t_ds_process_definition_log exists with columns code, version, project_code
  3. Grant the upgrade DB user SELECT on the table
  4. Validate schema consistency against the 3.2.0 baseline before upgrading
Defensive patterns

Strategy: try-catch

Validate before calling

try (Connection c = dataSource.getConnection();
     ResultSet rs = c.createStatement().executeQuery(
         "select code, version, project_code from t_ds_process_definition_log where 1=0")) {
} catch (SQLException e) {
    throw new IllegalStateException("t_ds_process_definition_log schema mismatch: " + e.getMessage(), e);
}

Try / catch

try {
    upgrader.upgrade();
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().contains("Query t_ds_process_definition_log error")) {
        log.error("Definition log lookup failed: {}", e.getCause(), e);
    } else { throw e; }
}

Prevention

When it happens

Trigger: 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.

Common situations: Upgrading a DB whose history/log table is inconsistent or truncated; privilege-restricted DB account; vendor-specific SQL incompatibility.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/6100244eb643e8c8. Report an issue: GitHub.