{"record":{"id":"40deab6d96bb07dc","repo":"apache/dolphinscheduler","slug":"update-t-ds-process-instance-error","errorCode":null,"errorMessage":"Update t_ds_process_instance error","messagePattern":"Update t_ds_process_instance 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":258,"sourceCode":"            return Collections.emptyMap();\n        } catch (Exception ex) {\n            throw new RuntimeException(\"Query t_ds_schedules error\", ex);\n        }\n    }\n\n    private void updateProjectCodeInProcessInstance(Integer processInstanceId, Long projectCode, String tenantCode,\n                                                    String executorName) {\n        try (\n                Connection connection = dataSource.getConnection();\n                PreparedStatement preparedStatement = connection.prepareStatement(\n                        \"update t_ds_process_instance set project_code = ?, tenant_code = ?, executor_name = ? where id = ?\")) {\n            preparedStatement.setLong(1, projectCode);\n            preparedStatement.setString(2, tenantCode);\n            preparedStatement.setString(3, executorName);\n            preparedStatement.setInt(4, processInstanceId);\n            preparedStatement.executeUpdate();\n        } catch (Exception ex) {\n            throw new RuntimeException(\"Update t_ds_process_instance error\", ex);\n        }\n    }\n\n    private void updateProjectCodeInTaskInstance(Integer id, Long projectCode, String processInstanceName,\n                                                 String executorName) {\n        try (\n                Connection connection = dataSource.getConnection();\n                PreparedStatement preparedStatement = connection.prepareStatement(\n                        \"update t_ds_task_instance set project_code = ?, process_instance_name = ?, executor_name = ? where id = ?\")) {\n            preparedStatement.setLong(1, projectCode);\n            preparedStatement.setString(2, processInstanceName);\n            preparedStatement.setString(3, executorName);\n            preparedStatement.setInt(4, id);\n            preparedStatement.executeUpdate();\n        } catch (Exception ex) {\n            throw new RuntimeException(\"Update t_ds_process_instance error\", ex);\n        }\n    }","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/datasource/upgrader/v320/V320DolphinSchedulerUpgrader.java#L240-L276","documentation":"Thrown by V320DolphinSchedulerUpgrader.updateProjectCodeInProcessInstance when the UPDATE of t_ds_process_instance (setting project_code, tenant_code, executor_name) fails during the 3.2.0 upgrade. JDBC exceptions are wrapped in this RuntimeException.","triggerScenarios":"Executing upgradeWorkflowInstance when the UPDATE fails: missing project_code/tenant_code columns (schema SQL not applied), NOT NULL/constraint violation, row locked, or insufficient UPDATE privilege.","commonSituations":"Running the data upgrader before the DDL migration added the new columns; DB user is read-only; lock contention from a running DolphinScheduler instance using the same metadata DB.","solutions":["Check 'Caused by' for the underlying SQLException","Apply the 3.2.0->3.2.1 DDL first so project_code/tenant_code/executor_name columns exist","Grant UPDATE on t_ds_process_instance to the upgrade user","Stop running DolphinScheduler services during upgrade to avoid row locks","If the update fails mid-way, restore the DB backup and re-run"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"try (Connection c = dataSource.getConnection();\n     ResultSet rs = c.createStatement().executeQuery(\n         \"select project_code, tenant_code, executor_name from t_ds_process_instance where 1=0\")) {\n} catch (SQLException e) {\n    throw new IllegalStateException(\"Update preconditions unmet (columns missing?): \" + e.getMessage(), e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    upgrader.upgrade();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Update t_ds_process_instance error\")) {\n        log.error(\"Update failed: {}\", e.getCause(), e);\n        // restore from backup before re-running since upgrade is partially applied\n    } else { throw e; }\n}","preventionTips":["Run DDL migrations before data upgraders","Stop all DolphinScheduler services during upgrade to avoid locks","Use an account with UPDATE privilege","Take a DB backup so a failed partial upgrade can be rolled back"],"tags":["database","jdbc","upgrade","sql","write"],"backgroundTag":"database-write-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"}