From 28e28caebd388f4c3d1b2093f809e8ff339f684f Mon Sep 17 00:00:00 2001 From: Yelli Date: Fri, 29 May 2020 21:51:19 +0800 Subject: [PATCH] fix table not exist when init db metadata (#2838) * fix table not exist when init db metadata * fix db init error * fix ds-1.3.0 init db * init db modify process instance json Co-authored-by: eights --- .../dao/upgrade/DolphinSchedulerManager.java | 7 ++++--- .../dao/upgrade/UpgradeDao.java | 20 ++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/DolphinSchedulerManager.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/DolphinSchedulerManager.java index a00cb1cac6..8d1d862640 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/DolphinSchedulerManager.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/DolphinSchedulerManager.java @@ -112,11 +112,12 @@ public class DolphinSchedulerManager { for(String schemaDir : schemaList) { schemaVersion = schemaDir.split("_")[0]; if(SchemaUtils.isAGreatVersion(schemaVersion , version)) { - - logger.info("upgrade DolphinScheduler metadata version from " + version + " to " + schemaVersion); - + logger.info("upgrade DolphinScheduler metadata version from {} to {}", version, schemaVersion); logger.info("Begin upgrading DolphinScheduler's table structure"); upgradeDao.upgradeDolphinScheduler(schemaDir); + if ("1.3.0".equals(schemaVersion)) { + upgradeDao.upgradeDolphinSchedulerWorkerGroup(); + } version = schemaVersion; } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java index 39aab3ec41..f9458a82bf 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java @@ -19,11 +19,12 @@ package org.apache.dolphinscheduler.dao.upgrade; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.apache.dolphinscheduler.common.enums.DbType; -import org.apache.dolphinscheduler.common.model.TaskNode; -import org.apache.dolphinscheduler.common.utils.*; +import org.apache.dolphinscheduler.common.utils.ConnectionUtils; +import org.apache.dolphinscheduler.common.utils.SchemaUtils; +import org.apache.dolphinscheduler.common.utils.ScriptRunner; +import org.apache.dolphinscheduler.common.utils.StringUtils; import org.apache.dolphinscheduler.dao.AbstractBaseDao; import org.apache.dolphinscheduler.dao.datasource.ConnectionFactory; -import org.apache.dolphinscheduler.dao.entity.ProcessData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,7 +35,8 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.text.MessageFormat; -import java.util.*; +import java.util.HashMap; +import java.util.Map; public abstract class UpgradeDao extends AbstractBaseDao { @@ -258,12 +260,16 @@ public abstract class UpgradeDao extends AbstractBaseDao { upgradeDolphinSchedulerDDL(schemaDir); upgradeDolphinSchedulerDML(schemaDir); - - updateProcessDefinitionJsonWorkerGroup(); + } + /** + * upgrade DolphinScheduler worker group + * ds-1.3.0 modify the worker group for process definition json + */ + public void upgradeDolphinSchedulerWorkerGroup() { + updateProcessDefinitionJsonWorkerGroup(); } - /** * updateProcessDefinitionJsonWorkerGroup */