[API] Do not specify rollback for ensure in case of any exception or error. (#10793)

(cherry picked from commit b7fbf6c4ad)
This commit is contained in:
WangJPLeo 2022-07-06 14:22:46 +08:00 committed by Jiajie Zhong
parent dca87a4b0c
commit 749a82a78d
19 changed files with 63 additions and 51 deletions

View File

@ -113,6 +113,7 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
/**
* create token
*
* @param loginUser
* @param userId token for user
* @param expireTime token expire time
* @param token token string (if it is absent, it will be automatically generated)
@ -162,6 +163,7 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
/**
* generate token
*
* @param loginUser
* @param userId token for user
* @param expireTime token expire time
* @return token string

View File

@ -137,6 +137,7 @@ public class AlertGroupServiceImpl extends BaseServiceImpl implements AlertGroup
* @return create result code
*/
@Override
@Transactional
public Map<String, Object> createAlertgroup(User loginUser, String groupName, String desc, String alertInstanceIds) {
Map<String, Object> result = new HashMap<>();
//only admin can operate
@ -224,7 +225,7 @@ public class AlertGroupServiceImpl extends BaseServiceImpl implements AlertGroup
* @return delete result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> delAlertgroupById(User loginUser, int id) {
Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false);

View File

@ -91,6 +91,7 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
* @return create result code
*/
@Override
@Transactional
public Result<Object> createDataSource(User loginUser, BaseDataSourceParamDTO datasourceParam) {
DataSourceUtils.checkDatasourceParam(datasourceParam);
Result<Object> result = new Result<>();
@ -371,7 +372,7 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
* @return delete result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Result<Object> delete(User loginUser, int datasourceId) {
Result<Object> result = new Result<>();
try {

View File

@ -87,8 +87,8 @@ public class EnvironmentServiceImpl extends BaseServiceImpl implements Environme
* @param desc environment desc
* @param workerGroups worker groups
*/
@Transactional(rollbackFor = RuntimeException.class)
@Override
@Transactional
public Map<String, Object> createEnvironment(User loginUser, String name, String config, String desc, String workerGroups) {
Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
@ -280,7 +280,7 @@ public class EnvironmentServiceImpl extends BaseServiceImpl implements Environme
* @param loginUser login user
* @param code environment code
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> deleteEnvironmentByCode(User loginUser, Long code) {
Map<String, Object> result = new HashMap<>();
@ -318,7 +318,7 @@ public class EnvironmentServiceImpl extends BaseServiceImpl implements Environme
* @param desc environment desc
* @param workerGroups worker groups
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> updateEnvironmentByCode(User loginUser, Long code, String name, String config, String desc, String workerGroups) {
Map<String, Object> result = new HashMap<>();

View File

@ -208,7 +208,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return create result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> createProcessDefinition(User loginUser,
long projectCode,
String name,
@ -532,7 +532,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return update result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> updateProcessDefinition(User loginUser,
long projectCode,
String name,
@ -689,7 +689,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return delete result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> deleteProcessDefinitionByCode(User loginUser, long projectCode, long code) {
Project project = projectMapper.queryByCode(projectCode);
//check user access for project
@ -760,7 +760,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return release result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> releaseProcessDefinition(User loginUser, long projectCode, long code, ReleaseState releaseState) {
Project project = projectMapper.queryByCode(projectCode);
//check user access for project
@ -900,7 +900,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return import process
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> importProcessDefinition(User loginUser, long projectCode, MultipartFile file) {
Map<String, Object> result = new HashMap<>();
String dagDataScheduleJson = FileUtils.file2String(file);
@ -919,7 +919,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
}
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> importSqlProcessDefinition(User loginUser, long projectCode, MultipartFile file) {
Map<String, Object> result = new HashMap<>();
String processDefinitionName = file.getOriginalFilename() == null ? file.getName() : file.getOriginalFilename();
@ -1653,7 +1653,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @param targetProjectCode targetProjectCode
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> batchMoveProcessDefinition(User loginUser,
long projectCode,
String codes,
@ -1795,7 +1795,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return switch process definition version result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> switchProcessDefinitionVersion(User loginUser, long projectCode, long code, int version) {
Project project = projectMapper.queryByCode(projectCode);
//check user access for project
@ -1890,7 +1890,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return delete result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> deleteProcessDefinitionVersion(User loginUser, long projectCode, long code, int version) {
Project project = projectMapper.queryByCode(projectCode);
//check user access for project
@ -1932,7 +1932,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return process definition code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> createEmptyProcessDefinition(User loginUser,
long projectCode,
String name,
@ -2058,7 +2058,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @return update result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> updateProcessDefinitionBasicInfo(User loginUser,
long projectCode,
String name,
@ -2173,7 +2173,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
* @param releaseState releaseState
* @return update result code
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> releaseWorkflowAndSchedule(User loginUser, long projectCode, long code, ReleaseState releaseState) {
Project project = projectMapper.queryByCode(projectCode);

View File

@ -448,7 +448,7 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
* @param tenantCode tenantCode
* @return update result code
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> updateProcessInstance(User loginUser, long projectCode, Integer processInstanceId, String taskRelationJson,
String taskDefinitionJson, String scheduleTime, Boolean syncDefine, String globalParams,
@ -615,7 +615,7 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
* @return delete result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> deleteProcessInstanceById(User loginUser, long projectCode, Integer processInstanceId) {
Project project = projectMapper.queryByCode(projectCode);
//check user access for project

View File

@ -96,7 +96,7 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* @param postTaskCode postTaskCode
* @return create result code
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> createProcessTaskRelation(User loginUser, long projectCode, long processDefinitionCode, long preTaskCode, long postTaskCode) {
Project project = projectMapper.queryByCode(projectCode);
@ -187,7 +187,7 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* @param taskCode the post task code
* @return delete result code
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> deleteTaskProcessRelation(User loginUser, long projectCode, long processDefinitionCode, long taskCode) {
Project project = projectMapper.queryByCode(projectCode);
@ -267,7 +267,7 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* @param taskCode the post task code
* @return delete result code
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> deleteUpstreamRelation(User loginUser, long projectCode, String preTaskCodes, long taskCode) {
Project project = projectMapper.queryByCode(projectCode);
@ -339,7 +339,7 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* @param taskCode the pre task code
* @return delete result code
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> deleteDownstreamRelation(User loginUser, long projectCode, String postTaskCodes, long taskCode) {
Project project = projectMapper.queryByCode(projectCode);
@ -457,7 +457,7 @@ public class ProcessTaskRelationServiceImpl extends BaseServiceImpl implements P
* @param postTaskCode post task code
* @return delete result code
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> deleteEdge(User loginUser, long projectCode, long processDefinitionCode, long preTaskCode, long postTaskCode) {
Project project = projectMapper.queryByCode(projectCode);

View File

@ -37,6 +37,7 @@ import org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
@ -75,6 +76,7 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
* @return returns an error if it exists
*/
@Override
@Transactional
public Map<String, Object> createProject(User loginUser, String name, String desc) {
Map<String, Object> result = new HashMap<>();

View File

@ -39,6 +39,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -159,6 +160,7 @@ public class QueueServiceImpl extends BaseServiceImpl implements QueueService {
* @return create result
*/
@Override
@Transactional
public Map<String, Object> createQueue(User loginUser, String queue, String queueName) {
Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {

View File

@ -1188,7 +1188,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
* @return update result cod
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Transactional
public Result<Object> updateResourceContent(int resourceId, String content) {
Result<Object> result = checkResourceUploadStartupState();
if (!result.getCode().equals(Status.SUCCESS.getCode())) {

View File

@ -126,7 +126,7 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
* @return create result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> insertSchedule(User loginUser,
long projectCode,
long processDefineCode,
@ -227,7 +227,7 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
* @return update result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> updateSchedule(User loginUser,
long projectCode,
Integer id,
@ -277,7 +277,7 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
* @return publish result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> setScheduleState(User loginUser,
long projectCode,
Integer id,

View File

@ -88,7 +88,7 @@ public class SessionServiceImpl extends BaseServiceImpl implements SessionServic
* @return session string
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public String createSession(User user, String ip) {
Session session = null;

View File

@ -113,7 +113,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
* @param projectCode project code
* @param taskDefinitionJson task definition json
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> createTaskDefinition(User loginUser,
long projectCode,
@ -165,7 +165,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
* @param upstreamCodes upstream task codes, sep comma
* @return create result code
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> createTaskBindsWorkFlow(User loginUser,
long projectCode,
@ -300,7 +300,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
* @param projectCode project code
* @param taskCode task code
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> deleteTaskDefinitionByCode(User loginUser, long projectCode, long taskCode) {
Project project = projectMapper.queryByCode(projectCode);
@ -379,7 +379,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
* @param taskCode task code
* @param taskDefinitionJsonObj task definition json object
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> updateTaskDefinition(User loginUser, long projectCode, long taskCode, String taskDefinitionJsonObj) {
Map<String, Object> result = new HashMap<>();
@ -543,7 +543,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
* @param taskCode task code
* @param version the version user want to switch
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> switchVersion(User loginUser, long projectCode, long taskCode, int version) {
Project project = projectMapper.queryByCode(projectCode);
@ -737,7 +737,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
* @param releaseState releaseState
* @return update result code
*/
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
@Override
public Map<String, Object> releaseTaskDefinition(User loginUser, long projectCode, long code, ReleaseState releaseState) {
Project project = projectMapper.queryByCode(projectCode);

View File

@ -40,6 +40,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -75,6 +76,7 @@ public class TaskGroupServiceImpl extends BaseServiceImpl implements TaskGroupSe
* @return the result code and msg
*/
@Override
@Transactional
public Map<String, Object> createTaskGroup(User loginUser, Long projectCode, String name, String description, int groupSize) {
Map<String, Object> result = new HashMap<>();
if (name == null) {

View File

@ -78,6 +78,7 @@ public class UdfFuncServiceImpl extends BaseServiceImpl implements UdfFuncServic
* @return create result code
*/
@Override
@Transactional
public Result<Object> createUdfFunction(User loginUser,
String funcName,
String className,
@ -304,7 +305,7 @@ public class UdfFuncServiceImpl extends BaseServiceImpl implements UdfFuncServic
* @return delete result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Result<Object> delete(int id) {
Result<Object> result = new Result<>();
udfFuncMapper.deleteById(id);

View File

@ -137,7 +137,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
* @throws Exception exception
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Transactional
public Map<String, Object> createUser(User loginUser,
String userName,
String userPassword,
@ -181,7 +181,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
}
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public User createUser(String userName,
String userPassword,
String email,
@ -216,7 +216,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
* create User for ldap login
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Transactional
public User createUser(UserType userType, String userId, String email) {
User user = new User();
Date now = new Date();
@ -503,7 +503,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
* @throws Exception exception when operate hdfs
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> deleteUserById(User loginUser, int id) throws IOException {
Map<String, Object> result = new HashMap<>();
//only admin can operate
@ -546,7 +546,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
* @return grant result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> grantProject(User loginUser, int userId, String projectIds) {
Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false);
@ -675,7 +675,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
* @return grant result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> grantResources(User loginUser, int userId, String resourceIds) {
Map<String, Object> result = new HashMap<>();
@ -769,7 +769,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
* @return grant result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> grantUDFFunction(User loginUser, int userId, String udfIds) {
Map<String, Object> result = new HashMap<>();
@ -813,7 +813,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
* @return grant result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> grantNamespaces(User loginUser, int userId, String namespaceIds) {
Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false);
@ -860,7 +860,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
* @return grant result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> grantDataSource(User loginUser, int userId, String datasourceIds) {
Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false);
@ -1143,7 +1143,7 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
* @throws Exception exception
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public Map<String, Object> registerUser(String userName, String userPassword, String repeatPassword, String email) {
Map<String, Object> result = new HashMap<>();

View File

@ -78,6 +78,7 @@ public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGro
* @return create or update result code
*/
@Override
@Transactional
public Map<String, Object> saveWorkerGroup(User loginUser, int id, String name, String addrList) {
Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {
@ -304,7 +305,7 @@ public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGro
* @return delete result code
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Transactional
public Map<String, Object> deleteWorkerGroupById(User loginUser, Integer id) {
Map<String, Object> result = new HashMap<>();
if (isNotAdmin(loginUser, result)) {

View File

@ -106,7 +106,7 @@ public interface ProcessService {
TaskInstance submitTaskWithRetry(ProcessInstance processInstance, TaskInstance taskInstance, int commitRetryTimes, long commitInterval);
@Transactional(rollbackFor = Exception.class)
@Transactional
TaskInstance submitTask(ProcessInstance processInstance, TaskInstance taskInstance);
void createSubWorkProcess(ProcessInstance parentProcessInstance, TaskInstance task);
@ -174,7 +174,7 @@ public interface ProcessService {
List<String> queryNeedFailoverProcessInstanceHost();
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
void processNeedFailoverProcessInstances(ProcessInstance processInstance);
List<TaskInstance> queryNeedFailoverTaskInstances(String host);

View File

@ -1270,7 +1270,7 @@ public class ProcessServiceImpl implements ProcessService {
* @return task instance
*/
@Override
@Transactional(rollbackFor = Exception.class)
@Transactional
public TaskInstance submitTask(ProcessInstance processInstance, TaskInstance taskInstance) {
logger.info("Start save taskInstance to database : {}, processInstance id:{}, state: {}",
taskInstance.getName(),
@ -2044,7 +2044,7 @@ public class ProcessServiceImpl implements ProcessService {
* @param processInstance processInstance
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
@Transactional
public void processNeedFailoverProcessInstances(ProcessInstance processInstance) {
//1 update processInstance host is null
processInstance.setHost(Constants.NULL);