Skip to content

Commit 1820773

Browse files
builds: merge main into dev/4.2.x (#1922)
* builds: merge dev/4.2.3 into main (#1918) * enhancement: optimize list tickets api RT (#1903) * builds: revert submodule from 4.2.4 to 4.2.3 (#1911) * Revert "optimize" This reverts commit 8bf866e. * optimize list tickets * builds: merge from dev/4.2.3 into main (#1921) * enhancement: optimize list tickets api RT (#1903) * builds: revert submodule from 4.2.4 to 4.2.3 (#1911) * Revert "optimize" This reverts commit 8bf866e. * optimize list tickets * fix(connection): SingleConnectionDataSource concurrent getConnection may have problems (#1914) * fix concurrent * fix concurrent * fix concurrent --------- Co-authored-by: pynzzZ <[email protected]> --------- Co-authored-by: Ang <[email protected]>
1 parent bdad019 commit 1820773

4 files changed

Lines changed: 33 additions & 4 deletions

File tree

server/odc-core/src/main/java/com/oceanbase/odc/core/datasource/SingleConnectionDataSource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class SingleConnectionDataSource extends BaseClassBasedDataSource impleme
5858
private final boolean autoReconnect;
5959
@Setter
6060
private EventPublisher eventPublisher;
61-
protected Connection connection;
61+
protected volatile Connection connection;
6262
private final List<ConnectionInitializer> initializerList = new LinkedList<>();
6363
private Lock lock;
6464
@Setter
@@ -96,7 +96,7 @@ public Connection getConnection(String username, String password) throws SQLExce
9696
/**
9797
* Reset a {@code Connection}
9898
*/
99-
public void resetConnection() throws SQLException {
99+
public synchronized void resetConnection() throws SQLException {
100100
log.info("The connection will be reset soon");
101101
close();
102102
this.connection = null;
@@ -181,7 +181,7 @@ private void onConnectionReset(Connection connection) {
181181
}
182182
}
183183

184-
private Connection innerCreateConnection() throws SQLException {
184+
private synchronized Connection innerCreateConnection() throws SQLException {
185185
if (this.connection != null) {
186186
throw new IllegalStateException("Connection is not null");
187187
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CREATE OR REPLACE VIEW `list_flow_instance_view` AS select /*+use_merge(flow_instance flow_instance_node_task)*/
2+
`flow_instance`.`id` AS `id`,
3+
`flow_instance`.`create_time` AS `create_time`,
4+
`flow_instance`.`update_time` AS `update_time`,
5+
`flow_instance`.`name` AS `name`,
6+
`flow_instance`.`flow_config_id` AS `flow_config_id`,
7+
`flow_instance`.`creator_id` AS `creator_id`,
8+
`flow_instance`.`organization_id` AS `organization_id`,
9+
`flow_instance`.`process_definition_id` AS `process_definition_id`,
10+
`flow_instance`.`process_instance_id` AS `process_instance_id`,
11+
`flow_instance`.`status` AS `status`,
12+
`flow_instance`.`flow_config_snapshot_xml` AS `flow_config_snapshot_xml`,
13+
`flow_instance`.`description` AS `description`,
14+
`flow_instance`.`parent_instance_id` AS `parent_instance_id`,
15+
`flow_instance`.`project_id` AS `project_id`,
16+
`flow_instance_node_task`.`task_type` AS `task_type`
17+
from
18+
(
19+
`flow_instance` join `flow_instance_node_task` on ( `flow_instance`.`id` = `flow_instance_node_task`.`flow_instance_id`)
20+
);

server/odc-service/src/main/java/com/oceanbase/odc/metadb/flow/FlowInstanceViewSpecs.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.oceanbase.odc.metadb.flow;
1818

19+
import java.util.Arrays;
1920
import java.util.Collection;
2021
import java.util.Date;
2122
import java.util.Objects;
@@ -98,6 +99,13 @@ public static Specification<FlowInstanceViewEntity> taskTypeIn(Collection<TaskTy
9899
return SpecificationUtil.columnIn(FLOW_INSTANCE_VIEW_TASK_TYPE, taskTypes);
99100
}
100101

102+
public static Specification<FlowInstanceViewEntity> groupByIdAndTaskType() {
103+
return (root, query, cb) -> {
104+
query.groupBy(Arrays.asList(root.get(FLOW_INSTANCE_VIEW_ID_NAME), root.get(FLOW_INSTANCE_VIEW_TASK_TYPE)));
105+
return cb.conjunction();
106+
};
107+
}
108+
101109
public static Specification<FlowInstanceViewEntity> leftJoinFlowInstanceApprovalView(
102110
@NotNull Set<String> resourceRoleIdentifiers, Long creatorId, Set<FlowNodeStatus> statusList) {
103111
return (root, query, builder) -> {

server/odc-service/src/main/java/com/oceanbase/odc/service/flow/FlowInstanceService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ public Page<FlowInstanceEntity> listAll(@NotNull Pageable pageable, @NotNull Que
399399
.and(FlowInstanceViewSpecs.statusIn(params.getStatuses()))
400400
.and(FlowInstanceViewSpecs.createTimeLate(params.getStartTime()))
401401
.and(FlowInstanceViewSpecs.createTimeBefore(params.getEndTime()))
402-
.and(FlowInstanceViewSpecs.idEquals(targetId));
402+
.and(FlowInstanceViewSpecs.idEquals(targetId))
403+
.and(FlowInstanceViewSpecs.groupByIdAndTaskType());
403404
if (params.getType() != null) {
404405
specification = specification.and(FlowInstanceViewSpecs.taskTypeEquals(params.getType()));
405406
} else {

0 commit comments

Comments
 (0)