Skip to content

Commit

Permalink
fix "Creating folders with multiple threads will result in multiple i…
Browse files Browse the repository at this point in the history
…dentical folders" apache#3487
  • Loading branch information
mzjnumber1@163.com committed Aug 17, 2020
1 parent c4bbb68 commit 3180e08
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class ResourcesService extends BaseService {
* @return create directory result
*/
@Transactional(rollbackFor = RuntimeException.class)
public synchronized Result createDirectory(User loginUser,
public Result createDirectory(User loginUser,
String name,
String description,
ResourceType type,
Expand Down Expand Up @@ -161,7 +161,7 @@ public synchronized Result createDirectory(User loginUser,
* @return create result code
*/
@Transactional(rollbackFor = RuntimeException.class)
public synchronized Result createResource(User loginUser,
public Result createResource(User loginUser,
String name,
String desc,
ResourceType type,
Expand Down
3 changes: 2 additions & 1 deletion sql/dolphinscheduler-postgre.sql
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,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 @@ -630,7 +630,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

0 comments on commit 3180e08

Please sign in to comment.