Browse Source

[Bug-6152][Server] Fix the the exception of manual workflow execution (#6209)

Hua Jiang 3 years ago
parent
commit
5fead427f2

+ 2 - 2
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessTaskRelationLogMapper.xml

@@ -19,7 +19,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationLogMapper">
     <sql id="baseSql">
-        id, `name`, process_definition_version, project_code, process_definition_code, pre_task_code, pre_task_version,
+        id, name, process_definition_version, project_code, process_definition_code, pre_task_code, pre_task_version,
         post_task_code, post_task_version, condition_type, condition_params, operator, operate_time, create_time, update_time
     </sql>
     <select id="queryByProcessCodeAndVersion" resultType="org.apache.dolphinscheduler.dao.entity.ProcessTaskRelationLog">
@@ -30,7 +30,7 @@
         and process_definition_version = #{processVersion}
     </select>
     <insert id="batchInsert">
-        insert into t_ds_process_task_relation_log (`name`, process_definition_version, project_code, process_definition_code,
+        insert into t_ds_process_task_relation_log (name, process_definition_version, project_code, process_definition_code,
         pre_task_code, pre_task_version, post_task_code, post_task_version, condition_type, condition_params, operator, operate_time,
         create_time, update_time)
         values

+ 2 - 2
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessTaskRelationMapper.xml

@@ -19,7 +19,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper">
     <sql id="baseSql">
-        id, `name`, process_definition_version, project_code, process_definition_code, pre_task_code, pre_task_version,
+        id, name, process_definition_version, project_code, process_definition_code, pre_task_code, pre_task_version,
         post_task_code, post_task_version, condition_type, condition_params, create_time, update_time
     </sql>
     <select id="queryByProcessCode" resultType="org.apache.dolphinscheduler.dao.entity.ProcessTaskRelation">
@@ -60,7 +60,7 @@
         and process_definition_code = #{processCode}
     </delete>
     <insert id="batchInsert">
-        insert into t_ds_process_task_relation (`name`, process_definition_version, project_code, process_definition_code,
+        insert into t_ds_process_task_relation (name, process_definition_version, project_code, process_definition_code,
         pre_task_code, pre_task_version, post_task_code, post_task_version, condition_type, condition_params, create_time, update_time)
         values
         <foreach collection="taskRelationList" item="relation" separator=",">

+ 4 - 4
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionLogMapper.xml

@@ -19,7 +19,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper">
     <sql id="baseSql">
-        id, code, `name`, version, description, project_code, user_id, task_type, task_params, flag, task_priority,
+        id, code, name, version, description, project_code, user_id, task_type, task_params, flag, task_priority,
         worker_group, environment_code, fail_retry_times, fail_retry_interval, timeout_flag, timeout_notify_strategy, timeout, delay_time,
         resource_ids, operator, operate_time, create_time, update_time
     </sql>
@@ -49,14 +49,14 @@
         </if>
     </select>
     <insert id="batchInsert">
-        insert into t_ds_task_definition_log (code, `name`, version, description, project_code, user_id,
-        task_type, task_params, flag, task_priority, worker_group, fail_retry_times, fail_retry_interval,
+        insert into t_ds_task_definition_log (code, name, version, description, project_code, user_id,
+        task_type, task_params, flag, task_priority, worker_group, environment_code, fail_retry_times, fail_retry_interval,
         timeout_flag, timeout_notify_strategy, timeout, delay_time, resource_ids, operator, operate_time, create_time, update_time)
         values
         <foreach collection="taskDefinitionLogs" item="taskDefinitionLog" separator=",">
             (#{taskDefinitionLog.code},#{taskDefinitionLog.name},#{taskDefinitionLog.version},#{taskDefinitionLog.description},
             #{taskDefinitionLog.projectCode},#{taskDefinitionLog.userId},#{taskDefinitionLog.taskType},#{taskDefinitionLog.taskParams},
-            #{taskDefinitionLog.flag},#{taskDefinitionLog.taskPriority},#{taskDefinitionLog.workerGroup},#{taskDefinitionLog.failRetryTimes},
+            #{taskDefinitionLog.flag},#{taskDefinitionLog.taskPriority},#{taskDefinitionLog.workerGroup},#{taskDefinitionLog.environmentCode},#{taskDefinitionLog.failRetryTimes},
             #{taskDefinitionLog.failRetryInterval},#{taskDefinitionLog.timeoutFlag},#{taskDefinitionLog.timeoutNotifyStrategy},#{taskDefinitionLog.timeout},
             #{taskDefinitionLog.delayTime},#{taskDefinitionLog.resourceIds},#{taskDefinitionLog.operator},#{taskDefinitionLog.operateTime},
              #{taskDefinitionLog.createTime},#{taskDefinitionLog.updateTime})

+ 6 - 6
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskDefinitionMapper.xml

@@ -19,7 +19,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper">
     <sql id="baseSql">
-        id, code, `name`, version, description, project_code, user_id, task_type, task_params, flag, task_priority,
+        id, code, name, version, description, project_code, user_id, task_type, task_params, flag, task_priority,
         worker_group, environment_code, fail_retry_times, fail_retry_interval, timeout_flag, timeout_notify_strategy, timeout, delay_time,
         resource_ids, create_time, update_time
     </sql>
@@ -28,7 +28,7 @@
         <include refid="baseSql"/>
         from t_ds_task_definition
         WHERE project_code = #{projectCode}
-        and `name` = #{name}
+        and name = #{name}
     </select>
     <select id="queryAllDefinitionList" resultType="org.apache.dolphinscheduler.dao.entity.TaskDefinition">
         select
@@ -74,21 +74,21 @@
         where code = #{code}
     </delete>
     <insert id="batchInsert">
-        insert into t_ds_task_definition (code, `name`, version, description, project_code, user_id,
-        task_type, task_params, flag, task_priority, worker_group, fail_retry_times, fail_retry_interval,
+        insert into t_ds_task_definition (code, name, version, description, project_code, user_id,
+        task_type, task_params, flag, task_priority, worker_group, environment_code, fail_retry_times, fail_retry_interval,
         timeout_flag, timeout_notify_strategy, timeout, delay_time, resource_ids, create_time, update_time)
         values
         <foreach collection="taskDefinitions" item="taskDefinition" separator=",">
             (#{taskDefinition.code},#{taskDefinition.name},#{taskDefinition.version},#{taskDefinition.description},
             #{taskDefinition.projectCode},#{taskDefinition.userId},#{taskDefinition.taskType},#{taskDefinition.taskParams},
-            #{taskDefinition.flag},#{taskDefinition.taskPriority},#{taskDefinition.workerGroup},#{taskDefinition.failRetryTimes},
+            #{taskDefinition.flag},#{taskDefinition.taskPriority},#{taskDefinition.workerGroup},#{taskDefinition.environmentCode},#{taskDefinition.failRetryTimes},
             #{taskDefinition.failRetryInterval},#{taskDefinition.timeoutFlag},#{taskDefinition.timeoutNotifyStrategy},#{taskDefinition.timeout},
             #{taskDefinition.delayTime},#{taskDefinition.resourceIds},#{taskDefinition.createTime},#{taskDefinition.updateTime})
         </foreach>
     </insert>
     <select id="queryDefineListPaging" resultType="org.apache.dolphinscheduler.dao.entity.TaskDefinition">
         select td.id, td.code, td.name, td.version, td.description, td.project_code, td.user_id, td.task_type, td.task_params,
-        td.flag, td.task_priority, td.worker_group, td.fail_retry_times, td.fail_retry_interval, td.timeout_flag, td.timeout_notify_strategy,
+        td.flag, td.task_priority, td.worker_group,td.environment_code, td.fail_retry_times, td.fail_retry_interval, td.timeout_flag, td.timeout_notify_strategy,
         td.timeout, td.delay_time, td.resource_ids, td.create_time, td.update_time, u.user_name,p.name as project_name
         from t_ds_task_definition td
         JOIN t_ds_user u ON td.user_id = u.id

+ 1 - 1
pom.xml

@@ -16,7 +16,7 @@
   ~ limitations under the License.
   -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.apache.dolphinscheduler</groupId>
     <artifactId>dolphinscheduler</artifactId>

+ 98 - 73
sql/dolphinscheduler_postgre.sql

@@ -27,57 +27,64 @@ DROP TABLE IF EXISTS QRTZ_TRIGGERS;
 DROP TABLE IF EXISTS QRTZ_JOB_DETAILS;
 DROP TABLE IF EXISTS QRTZ_CALENDARS;
 
-CREATE TABLE QRTZ_JOB_DETAILS(
-SCHED_NAME character varying(120) NOT NULL,
-JOB_NAME character varying(200) NOT NULL,
-JOB_GROUP character varying(200) NOT NULL,
-DESCRIPTION character varying(250) NULL,
-JOB_CLASS_NAME character varying(250) NOT NULL,
-IS_DURABLE boolean NOT NULL,
-IS_NONCONCURRENT boolean NOT NULL,
-IS_UPDATE_DATA boolean NOT NULL,
-REQUESTS_RECOVERY boolean NOT NULL,
-JOB_DATA bytea NULL);
+CREATE TABLE QRTZ_JOB_DETAILS (
+  SCHED_NAME character varying(120) NOT NULL,
+  JOB_NAME character varying(200) NOT NULL,
+  JOB_GROUP character varying(200) NOT NULL,
+  DESCRIPTION character varying(250) NULL,
+  JOB_CLASS_NAME character varying(250) NOT NULL,
+  IS_DURABLE boolean NOT NULL,
+  IS_NONCONCURRENT boolean NOT NULL,
+  IS_UPDATE_DATA boolean NOT NULL,
+  REQUESTS_RECOVERY boolean NOT NULL,
+  JOB_DATA bytea NULL
+);
+
 alter table QRTZ_JOB_DETAILS add primary key(SCHED_NAME,JOB_NAME,JOB_GROUP);
 
 CREATE TABLE QRTZ_TRIGGERS (
-SCHED_NAME character varying(120) NOT NULL,
-TRIGGER_NAME character varying(200) NOT NULL,
-TRIGGER_GROUP character varying(200) NOT NULL,
-JOB_NAME character varying(200) NOT NULL,
-JOB_GROUP character varying(200) NOT NULL,
-DESCRIPTION character varying(250) NULL,
-NEXT_FIRE_TIME BIGINT NULL,
-PREV_FIRE_TIME BIGINT NULL,
-PRIORITY INTEGER NULL,
-TRIGGER_STATE character varying(16) NOT NULL,
-TRIGGER_TYPE character varying(8) NOT NULL,
-START_TIME BIGINT NOT NULL,
-END_TIME BIGINT NULL,
-CALENDAR_NAME character varying(200) NULL,
-MISFIRE_INSTR SMALLINT NULL,
-JOB_DATA bytea NULL)  ;
+  SCHED_NAME character varying(120) NOT NULL,
+  TRIGGER_NAME character varying(200) NOT NULL,
+  TRIGGER_GROUP character varying(200) NOT NULL,
+  JOB_NAME character varying(200) NOT NULL,
+  JOB_GROUP character varying(200) NOT NULL,
+  DESCRIPTION character varying(250) NULL,
+  NEXT_FIRE_TIME BIGINT NULL,
+  PREV_FIRE_TIME BIGINT NULL,
+  PRIORITY INTEGER NULL,
+  TRIGGER_STATE character varying(16) NOT NULL,
+  TRIGGER_TYPE character varying(8) NOT NULL,
+  START_TIME BIGINT NOT NULL,
+  END_TIME BIGINT NULL,
+  CALENDAR_NAME character varying(200) NULL,
+  MISFIRE_INSTR SMALLINT NULL,
+  JOB_DATA bytea NULL
+) ;
+
 alter table QRTZ_TRIGGERS add primary key(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP);
 
 CREATE TABLE QRTZ_SIMPLE_TRIGGERS (
-SCHED_NAME character varying(120) NOT NULL,
-TRIGGER_NAME character varying(200) NOT NULL,
-TRIGGER_GROUP character varying(200) NOT NULL,
-REPEAT_COUNT BIGINT NOT NULL,
-REPEAT_INTERVAL BIGINT NOT NULL,
-TIMES_TRIGGERED BIGINT NOT NULL)  ;
+    SCHED_NAME character varying(120) NOT NULL,
+    TRIGGER_NAME character varying(200) NOT NULL,
+    TRIGGER_GROUP character varying(200) NOT NULL,
+    REPEAT_COUNT BIGINT NOT NULL,
+    REPEAT_INTERVAL BIGINT NOT NULL,
+    TIMES_TRIGGERED BIGINT NOT NULL
+) ;
+
 alter table QRTZ_SIMPLE_TRIGGERS add primary key(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP);
 
 CREATE TABLE QRTZ_CRON_TRIGGERS (
-SCHED_NAME character varying(120) NOT NULL,
-TRIGGER_NAME character varying(200) NOT NULL,
-TRIGGER_GROUP character varying(200) NOT NULL,
-CRON_EXPRESSION character varying(120) NOT NULL,
-TIME_ZONE_ID character varying(80))  ;
+    SCHED_NAME character varying(120) NOT NULL,
+    TRIGGER_NAME character varying(200) NOT NULL,
+    TRIGGER_GROUP character varying(200) NOT NULL,
+    CRON_EXPRESSION character varying(120) NOT NULL,
+    TIME_ZONE_ID character varying(80)
+) ;
+
 alter table QRTZ_CRON_TRIGGERS add primary key(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP);
 
-CREATE TABLE QRTZ_SIMPROP_TRIGGERS
-  (
+CREATE TABLE QRTZ_SIMPROP_TRIGGERS (
     SCHED_NAME character varying(120) NOT NULL,
     TRIGGER_NAME character varying(200) NOT NULL,
     TRIGGER_GROUP character varying(200) NOT NULL,
@@ -91,53 +98,67 @@ CREATE TABLE QRTZ_SIMPROP_TRIGGERS
     DEC_PROP_1 NUMERIC(13,4) NULL,
     DEC_PROP_2 NUMERIC(13,4) NULL,
     BOOL_PROP_1 boolean NULL,
-    BOOL_PROP_2 boolean NULL) ;
+    BOOL_PROP_2 boolean NULL
+) ;
+
 alter table QRTZ_SIMPROP_TRIGGERS add primary key(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP);
 
 CREATE TABLE QRTZ_BLOB_TRIGGERS (
-SCHED_NAME character varying(120) NOT NULL,
-TRIGGER_NAME character varying(200) NOT NULL,
-TRIGGER_GROUP character varying(200) NOT NULL,
-BLOB_DATA bytea NULL) ;
+    SCHED_NAME character varying(120) NOT NULL,
+    TRIGGER_NAME character varying(200) NOT NULL,
+    TRIGGER_GROUP character varying(200) NOT NULL,
+    BLOB_DATA bytea NULL
+) ;
+
 alter table QRTZ_BLOB_TRIGGERS add primary key(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP);
 
 CREATE TABLE QRTZ_CALENDARS (
-SCHED_NAME character varying(120) NOT NULL,
-CALENDAR_NAME character varying(200) NOT NULL,
-CALENDAR bytea NOT NULL)  ;
+    SCHED_NAME character varying(120) NOT NULL,
+    CALENDAR_NAME character varying(200) NOT NULL,
+    CALENDAR bytea NOT NULL
+) ;
+
 alter table QRTZ_CALENDARS add primary key(SCHED_NAME,CALENDAR_NAME);
 
 CREATE TABLE QRTZ_PAUSED_TRIGGER_GRPS (
-SCHED_NAME character varying(120) NOT NULL,
-TRIGGER_GROUP character varying(200) NOT NULL)  ;
+    SCHED_NAME character varying(120) NOT NULL,
+    TRIGGER_GROUP character varying(200) NOT NULL
+) ;
+
 alter table QRTZ_PAUSED_TRIGGER_GRPS add primary key(SCHED_NAME,TRIGGER_GROUP);
 
 CREATE TABLE QRTZ_FIRED_TRIGGERS (
-SCHED_NAME character varying(120) NOT NULL,
-ENTRY_ID character varying(200) NOT NULL,
-TRIGGER_NAME character varying(200) NOT NULL,
-TRIGGER_GROUP character varying(200) NOT NULL,
-INSTANCE_NAME character varying(200) NOT NULL,
-FIRED_TIME BIGINT NOT NULL,
-SCHED_TIME BIGINT NOT NULL,
-PRIORITY INTEGER NOT NULL,
-STATE character varying(16) NOT NULL,
-JOB_NAME character varying(200) NULL,
-JOB_GROUP character varying(200) NULL,
-IS_NONCONCURRENT boolean NULL,
-REQUESTS_RECOVERY boolean NULL)  ;
+    SCHED_NAME character varying(120) NOT NULL,
+    ENTRY_ID character varying(200) NOT NULL,
+    TRIGGER_NAME character varying(200) NOT NULL,
+    TRIGGER_GROUP character varying(200) NOT NULL,
+    INSTANCE_NAME character varying(200) NOT NULL,
+    FIRED_TIME BIGINT NOT NULL,
+    SCHED_TIME BIGINT NOT NULL,
+    PRIORITY INTEGER NOT NULL,
+    STATE character varying(16) NOT NULL,
+    JOB_NAME character varying(200) NULL,
+    JOB_GROUP character varying(200) NULL,
+    IS_NONCONCURRENT boolean NULL,
+    REQUESTS_RECOVERY boolean NULL
+) ;
+
 alter table QRTZ_FIRED_TRIGGERS add primary key(SCHED_NAME,ENTRY_ID);
 
 CREATE TABLE QRTZ_SCHEDULER_STATE (
-SCHED_NAME character varying(120) NOT NULL,
-INSTANCE_NAME character varying(200) NOT NULL,
-LAST_CHECKIN_TIME BIGINT NOT NULL,
-CHECKIN_INTERVAL BIGINT NOT NULL)  ;
+    SCHED_NAME character varying(120) NOT NULL,
+    INSTANCE_NAME character varying(200) NOT NULL,
+    LAST_CHECKIN_TIME BIGINT NOT NULL,
+    CHECKIN_INTERVAL BIGINT NOT NULL
+) ;
+
 alter table QRTZ_SCHEDULER_STATE add primary key(SCHED_NAME,INSTANCE_NAME);
 
 CREATE TABLE QRTZ_LOCKS (
-SCHED_NAME character varying(120) NOT NULL,
-LOCK_NAME character varying(40) NOT NULL)  ;
+    SCHED_NAME character varying(120) NOT NULL,
+    LOCK_NAME character varying(40) NOT NULL
+) ;
+
 alter table QRTZ_LOCKS add primary key(SCHED_NAME,LOCK_NAME);
 
 CREATE INDEX IDX_QRTZ_J_REQ_RECOVERY ON QRTZ_JOB_DETAILS(SCHED_NAME,REQUESTS_RECOVERY);
@@ -471,8 +492,9 @@ CREATE TABLE t_ds_process_instance (
   var_pool text ,
   PRIMARY KEY (id)
 ) ;
-  create index process_instance_index on t_ds_process_instance (process_definition_code,id);
-  create index start_time_index on t_ds_process_instance (start_time);
+
+create index process_instance_index on t_ds_process_instance (process_definition_code,id);
+create index start_time_index on t_ds_process_instance (start_time);
 
 --
 -- Table structure for table t_ds_project
@@ -490,7 +512,8 @@ CREATE TABLE t_ds_project (
   update_time timestamp DEFAULT CURRENT_TIMESTAMP ,
   PRIMARY KEY (id)
 ) ;
-  create index user_id_index on t_ds_project (user_id);
+
+create index user_id_index on t_ds_project (user_id);
 
 --
 -- Table structure for table t_ds_queue
@@ -613,7 +636,7 @@ CREATE TABLE t_ds_resources (
 
 DROP TABLE IF EXISTS t_ds_schedules;
 CREATE TABLE t_ds_schedules (
-  id int NOT NULL  ,
+  id int NOT NULL ,
   process_definition_code bigint NOT NULL ,
   start_time timestamp NOT NULL ,
   end_time timestamp NOT NULL ,
@@ -822,9 +845,11 @@ ALTER TABLE t_ds_process_task_relation_log ALTER COLUMN id SET DEFAULT NEXTVAL('
 DROP SEQUENCE IF EXISTS t_ds_process_instance_id_sequence;
 CREATE SEQUENCE  t_ds_process_instance_id_sequence;
 ALTER TABLE t_ds_process_instance ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_process_instance_id_sequence');
+
 DROP SEQUENCE IF EXISTS t_ds_project_id_sequence;
 CREATE SEQUENCE  t_ds_project_id_sequence;
 ALTER TABLE t_ds_project ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_project_id_sequence');
+
 DROP SEQUENCE IF EXISTS t_ds_queue_id_sequence;
 CREATE SEQUENCE  t_ds_queue_id_sequence;
 ALTER TABLE t_ds_queue ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_queue_id_sequence');