Browse Source

[Fix] fix bug #3487 Create folder duplicate name under multithreading (#3697)

* add state

* fixed bug "jackson enum conversion  : InvalidFormatException"

* Word spelling modification
Comment modification
Word spelling modification,Comment modification,Log level modification

* Update EmailManager.java

* Update FlinkParameters.java

* Update SqlTask.java

* fixed  "getNotifyGroupList cache"  bug

* fix bug "Creating folders with multiple threads will result in multiple identical folders #3487"

* fix "Creating folders with multiple threads will result in multiple identical folders" #3487

* fix "Creating folders with multiple threads will result in multiple identical folders" #3487

* fix bug  #3487   Create folder duplicate name under multithreading

* fix bug  #3487   Create folder duplicate name under multithreading

* fix bug  #3487   Create folder duplicate name under multithreading

* fix bug  #3487   Create folder duplicate name under multithreading

Co-authored-by: mzjnumber1@163.com <mzjnumber1@163.com>
Co-authored-by: dailidong <dailidong66@gmail.com>
pull/3/MERGE
muzhongjiang 4 years ago committed by GitHub
parent
commit
c42e769ced
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java
  2. 3
      sql/dolphinscheduler-postgre.sql
  3. 3
      sql/dolphinscheduler_mysql.sql
  4. 26
      sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_ddl.sql
  5. 26
      sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_ddl.sql

5
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ResourcesService.java

@ -37,6 +37,7 @@ import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@ -139,6 +140,10 @@ public class ResourcesService extends BaseService {
}
}
result.setData(resultMap);
} catch (DuplicateKeyException e) {
logger.error("resource directory {} has exist, can't recreate", fullName);
putMsg(result, Status.RESOURCE_EXIST);
return result;
} catch (Exception e) {
logger.error("resource already exists, can't recreate ", e);
throw new RuntimeException("resource already exists, can't recreate");

3
sql/dolphinscheduler-postgre.sql

@ -523,7 +523,8 @@ CREATE TABLE t_ds_resources (
pid int,
full_name varchar(64),
is_directory int,
PRIMARY KEY (id)
PRIMARY KEY (id),
CONSTRAINT t_ds_resources_un UNIQUE (full_name, type)
) ;

3
sql/dolphinscheduler_mysql.sql

@ -657,7 +657,8 @@ CREATE TABLE `t_ds_resources` (
`pid` int(11) DEFAULT NULL,
`full_name` varchar(64) DEFAULT NULL,
`is_directory` tinyint(4) DEFAULT NULL,
PRIMARY KEY (`id`)
PRIMARY KEY (`id`),
UNIQUE KEY `t_ds_resources_un` (`full_name`,`type`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-- ----------------------------

26
sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_ddl.sql

@ -87,3 +87,29 @@ delimiter ;
CALL ct_dolphin_T_t_ds_process_definition_version;
DROP PROCEDURE ct_dolphin_T_t_ds_process_definition_version;
-- add t_ds_resources_un
DROP PROCEDURE IF EXISTS uc_dolphin_T_t_ds_resources_un;
delimiter d//
CREATE PROCEDURE uc_dolphin_T_t_ds_resources_un()
BEGIN
IF NOT EXISTS (
SELECT * FROM information_schema.KEY_COLUMN_USAGE
WHERE TABLE_NAME = 't_ds_resources'
AND CONSTRAINT_NAME = 't_ds_resources_un'
)
THEN
ALTER TABLE t_ds_resources ADD CONSTRAINT t_ds_resources_un UNIQUE KEY (full_name,`type`);
END IF;
END;
d//
delimiter ;
CALL uc_dolphin_T_t_ds_resources_un();
DROP PROCEDURE IF EXISTS uc_dolphin_T_t_ds_resources_un;

26
sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_ddl.sql

@ -80,3 +80,29 @@ d//
delimiter ;
SELECT ct_dolphin_T_t_ds_process_definition_version();
DROP FUNCTION IF EXISTS ct_dolphin_T_t_ds_process_definition_version();
-- add t_ds_resources_un
CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_resources_un() RETURNS void AS $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.KEY_COLUMN_USAGE
WHERE TABLE_NAME = 't_ds_resources'
AND CONSTRAINT_NAME = 't_ds_resources_un'
)
THEN
ALTER TABLE t_ds_resources ADD CONSTRAINT t_ds_resources_un UNIQUE (full_name,"type");
END IF;
END;
$$ LANGUAGE plpgsql;
SELECT uc_dolphin_T_t_ds_resources_un();
DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_resources_un();

Loading…
Cancel
Save