Skip to content

Commit

Permalink
fix(flow): revert #1380 and #1402 from dev/4.2.x (#1454)
Browse files Browse the repository at this point in the history
* Revert "fix(flow): reduce the result set size of the flow Instance query by parent instance id (#1402)"

This reverts commit 349f780.

* Revert "fix(flow):improve list API rt (#1383)"

This reverts commit db06895

* revert
  • Loading branch information
ungreat committed Jan 25, 2024
1 parent f3f25cf commit f6faf27
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import com.oceanbase.odc.core.shared.exception.OverLimitException;
import com.oceanbase.odc.metadb.flow.FlowInstanceEntity;
import com.oceanbase.odc.metadb.flow.FlowInstanceRepository;
import com.oceanbase.odc.metadb.flow.FlowInstanceRepository.ParentInstanceIdCount;
import com.oceanbase.odc.metadb.flow.GateWayInstanceRepository;
import com.oceanbase.odc.metadb.flow.NodeInstanceEntityRepository;
import com.oceanbase.odc.metadb.flow.SequenceInstanceRepository;
Expand Down Expand Up @@ -449,14 +448,6 @@ public void listStatus() {
Assert.assertEquals(0, status.size());
}

@Test
public void testFindByParentInstanceIdIn() {
createChildFlowInstance("test", 1L);
List<ParentInstanceIdCount> byParentInstanceIdIn = flowInstanceRepository.findByParentInstanceIdIn(
Arrays.asList(1L, 2L));
Assert.assertEquals(byParentInstanceIdIn.size(), 1);
}

private void buildFlowInstance(FlowInstance flowInstance) {
buildFlowInstanceWithTaskType(flowInstance, TaskType.ASYNC);
}
Expand Down Expand Up @@ -500,10 +491,6 @@ private FlowInstance createFlowInstance(String name) {
return flowFactory.generateFlowInstance(name, null, 1L, null);
}

private FlowInstance createChildFlowInstance(String name, Long parentFloweInstanceId) {
return flowFactory.generateFlowInstance(name, parentFloweInstanceId, 1L, null);
}

private FlowTaskInstance createTaskInstance(Long flowInstanceId, TaskEntity taskEntity,
ExecutionStrategyConfig config) {
FlowTaskInstance taskInstance = new FlowTaskInstance(taskEntity.getTaskType(),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.oceanbase.odc.config.jpa.OdcJpaRepository;
import com.oceanbase.odc.core.shared.constant.FlowStatus;
import com.oceanbase.odc.core.shared.constant.TaskType;

Expand All @@ -39,7 +39,7 @@
* @see org.springframework.data.jpa.repository.JpaRepository
*/
public interface FlowInstanceRepository
extends OdcJpaRepository<FlowInstanceEntity, Long>, JpaSpecificationExecutor<FlowInstanceEntity> {
extends JpaRepository<FlowInstanceEntity, Long>, JpaSpecificationExecutor<FlowInstanceEntity> {

List<FlowInstanceEntity> findByIdIn(Collection<Long> ids);

Expand Down Expand Up @@ -82,7 +82,6 @@ int updateProcessDefinitionIdById(@Param("flowInstanceId") Long flowInstanceId,

List<FlowInstanceEntity> findByParentInstanceId(Long parentInstanceId);


@Query(value = "select a.parent_instance_id from flow_instance a left join flow_instance_node_task b on a.id = b.flow_instance_id"
+ " where a.id=:id and task_task_id is not null and b.task_type='ALTER_SCHEDULE' LIMIT 1",
nativeQuery = true)
Expand All @@ -100,14 +99,4 @@ List<FlowInstanceEntity> findByFlowInstanceIdsAndTaskType(@Param("ids") Collecti
nativeQuery = true)
Set<FlowInstanceEntity> findByScheduleIdAndStatus(@Param("scheduleIds") Set<Long> scheduleIds,
@Param("status") FlowStatus status);

@Query("select e.parentInstanceId as parentInstanceId, count(1) as count from FlowInstanceEntity e where e.parentInstanceId in (?1) group by parentInstanceId")
List<ParentInstanceIdCount> findByParentInstanceIdIn(Collection<Long> parentInstanceId);

interface ParentInstanceIdCount {

Long getParentInstanceId();

Integer getCount();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;

import com.google.common.base.MoreObjects;
import com.oceanbase.odc.common.json.JsonUtils;
import com.oceanbase.odc.common.util.StringUtils;
import com.oceanbase.odc.core.shared.constant.TaskType;
Expand All @@ -45,7 +44,6 @@
import com.oceanbase.odc.metadb.connection.ConnectionSpecs;
import com.oceanbase.odc.metadb.flow.FlowInstanceEntity;
import com.oceanbase.odc.metadb.flow.FlowInstanceRepository;
import com.oceanbase.odc.metadb.flow.FlowInstanceRepository.ParentInstanceIdCount;
import com.oceanbase.odc.metadb.flow.ServiceTaskInstanceEntity;
import com.oceanbase.odc.metadb.flow.ServiceTaskInstanceRepository;
import com.oceanbase.odc.metadb.flow.ServiceTaskInstanceSpecs;
Expand Down Expand Up @@ -284,14 +282,8 @@ private FlowInstanceMapper generateMapper(@NonNull Collection<Long> flowInstance
.collect(Collectors.groupingBy(ServiceTaskInstanceEntity::getFlowInstanceId,
Collectors.mapping(ServiceTaskInstanceEntity::getStrategy, Collectors.toList())));

Map<Long, Integer> parentInstanceIdMap = flowInstanceRepository
.findByParentInstanceIdIn(flowInstanceIds)
.stream().collect(
Collectors.toMap(ParentInstanceIdCount::getParentInstanceId, ParentInstanceIdCount::getCount));

Map<Long, Boolean> flowInstanceId2Rollbackable = flowInstanceIds.stream().collect(Collectors
.toMap(Function.identity(),
id -> MoreObjects.firstNonNull(parentInstanceIdMap.get(id), 0) == 0));
.toMap(Function.identity(), id -> flowInstanceRepository.findByParentInstanceId(id).size() == 0));

/**
* In order to improve the interface efficiency, it is necessary to find out the task entity
Expand Down

0 comments on commit f6faf27

Please sign in to comment.