From 3a7006a79649df4f45397f125c2e9665f9659c0b Mon Sep 17 00:00:00 2001 From: Shiwen Cheng Date: Thu, 22 Apr 2021 19:07:19 +0800 Subject: [PATCH] [Fix-5351][K8s] Fix quartz cron task cannot take effect in K8s (#5353) --- sql/dolphinscheduler_mysql.sql | 2 +- sql/dolphinscheduler_postgre.sql | 2 +- .../mysql/dolphinscheduler_ddl.sql | 20 +++++++++++++++++++ .../postgresql/dolphinscheduler_ddl.sql | 18 +++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/sql/dolphinscheduler_mysql.sql b/sql/dolphinscheduler_mysql.sql index b479a5e030..1b7fd32852 100644 --- a/sql/dolphinscheduler_mysql.sql +++ b/sql/dolphinscheduler_mysql.sql @@ -74,7 +74,7 @@ CREATE TABLE `QRTZ_CRON_TRIGGERS` ( DROP TABLE IF EXISTS `QRTZ_FIRED_TRIGGERS`; CREATE TABLE `QRTZ_FIRED_TRIGGERS` ( `SCHED_NAME` varchar(120) NOT NULL, - `ENTRY_ID` varchar(95) NOT NULL, + `ENTRY_ID` varchar(200) NOT NULL, `TRIGGER_NAME` varchar(200) NOT NULL, `TRIGGER_GROUP` varchar(200) NOT NULL, `INSTANCE_NAME` varchar(200) NOT NULL, diff --git a/sql/dolphinscheduler_postgre.sql b/sql/dolphinscheduler_postgre.sql index 22737f7696..50f30ade35 100644 --- a/sql/dolphinscheduler_postgre.sql +++ b/sql/dolphinscheduler_postgre.sql @@ -114,7 +114,7 @@ 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(95) 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, diff --git a/sql/upgrade/1.3.6_schema/mysql/dolphinscheduler_ddl.sql b/sql/upgrade/1.3.6_schema/mysql/dolphinscheduler_ddl.sql index 25b7f5e764..f4df77a928 100644 --- a/sql/upgrade/1.3.6_schema/mysql/dolphinscheduler_ddl.sql +++ b/sql/upgrade/1.3.6_schema/mysql/dolphinscheduler_ddl.sql @@ -38,3 +38,23 @@ d// delimiter ; CALL uc_dolphin_T_t_ds_worker_group_R_ip_list; DROP PROCEDURE uc_dolphin_T_t_ds_worker_group_R_ip_list; + +-- uc_dolphin_T_qrtz_fired_triggers_R_entry_id +drop PROCEDURE if EXISTS uc_dolphin_T_qrtz_fired_triggers_R_entry_id; +delimiter d// +CREATE PROCEDURE uc_dolphin_T_qrtz_fired_triggers_R_entry_id() +BEGIN + IF EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='QRTZ_FIRED_TRIGGERS' + AND TABLE_SCHEMA=(SELECT DATABASE()) + AND COLUMN_NAME ='entry_id') + THEN + ALTER TABLE QRTZ_FIRED_TRIGGERS MODIFY COLUMN `entry_id` varchar(200); + END IF; +END; + +d// + +delimiter ; +CALL uc_dolphin_T_qrtz_fired_triggers_R_entry_id; +DROP PROCEDURE uc_dolphin_T_qrtz_fired_triggers_R_entry_id; diff --git a/sql/upgrade/1.3.6_schema/postgresql/dolphinscheduler_ddl.sql b/sql/upgrade/1.3.6_schema/postgresql/dolphinscheduler_ddl.sql index 17a8807054..b9744c3cd0 100644 --- a/sql/upgrade/1.3.6_schema/postgresql/dolphinscheduler_ddl.sql +++ b/sql/upgrade/1.3.6_schema/postgresql/dolphinscheduler_ddl.sql @@ -36,6 +36,24 @@ delimiter ; SELECT uc_dolphin_T_t_ds_worker_group_A_ip_list(); DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_worker_group_A_ip_list(); +-- uc_dolphin_T_qrtz_fired_triggers_A_entry_id +delimiter d// +CREATE OR REPLACE FUNCTION uc_dolphin_T_qrtz_fired_triggers_A_entry_id() RETURNS void AS $$ +BEGIN + IF EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='qrtz_fired_triggers' + AND COLUMN_NAME ='entry_id') + THEN + ALTER TABLE qrtz_fired_triggers ALTER COLUMN entry_id type varchar(200); + END IF; +END; +$$ LANGUAGE plpgsql; +d// + +delimiter ; +SELECT uc_dolphin_T_qrtz_fired_triggers_A_entry_id(); +DROP FUNCTION IF EXISTS uc_dolphin_T_qrtz_fired_triggers_A_entry_id(); + -- Add foreign key constraints for t_ds_task_instance -- delimiter ; ALTER TABLE t_ds_task_instance ADD CONSTRAINT foreign_key_instance_id FOREIGN KEY(process_instance_id) REFERENCES t_ds_process_instance(id) ON DELETE CASCADE;