Skip to content

Commit

Permalink
[Fix] fix bug #3487 Create folder duplicate name under multithreading (
Browse files Browse the repository at this point in the history
…#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>
  • Loading branch information
3 people committed Sep 9, 2020
1 parent 21a90f2 commit c42e769
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
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;
Expand Down Expand Up @@ -139,6 +140,10 @@ public Result createDirectory(User loginUser,
}
}
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");
Expand Down
3 changes: 2 additions & 1 deletion sql/dolphinscheduler-postgre.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
) ;


Expand Down
3 changes: 2 additions & 1 deletion sql/dolphinscheduler_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

-- ----------------------------
Expand Down
26 changes: 26 additions & 0 deletions sql/upgrade/1.3.3_schema/mysql/dolphinscheduler_ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;



28 changes: 27 additions & 1 deletion sql/upgrade/1.3.3_schema/postgresql/dolphinscheduler_ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,30 @@ d//

delimiter ;
SELECT ct_dolphin_T_t_ds_process_definition_version();
DROP FUNCTION IF EXISTS 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();






0 comments on commit c42e769

Please sign in to comment.