Skip to content

Commit a582629

Browse files
committed
modify batch update sql mode, remove allowMultiQueries
1 parent 11650f2 commit a582629

File tree

10 files changed

+19
-18
lines changed

10 files changed

+19
-18
lines changed

disjob-admin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<kaptcha.version>2.3.3</kaptcha.version>
4343
<pagehelper-spring-boot-starter.version>1.4.7</pagehelper-spring-boot-starter.version>
4444
<fastjson.version>1.2.83</fastjson.version>
45-
<oshi-core.version>6.4.13</oshi-core.version>
45+
<oshi-core.version>6.5.0</oshi-core.version>
4646
<commons-io.version>2.15.1</commons-io.version>
4747
<poi-ooxml.version>5.2.5</poi-ooxml.version>
4848
<velocity-engine-core.version>2.3</velocity-engine-core.version>

disjob-admin/ruoyi-disjob/src/main/resources/application-disjob-mysql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# database configuration
22
disjob.datasource:
33
driver-class-name: com.mysql.cj.jdbc.Driver
4-
jdbc-url: jdbc:mysql://localhost:3306/disjob?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&connectTimeout=2000&socketTimeout=5000&serverTimezone=Asia/Shanghai&failOverReadOnly=false
4+
jdbc-url: jdbc:mysql://localhost:3306/disjob?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&connectTimeout=2000&socketTimeout=5000&serverTimezone=Asia/Shanghai&failOverReadOnly=false
55
username: disjob
66
password: disjob$123456
77
minimum-idle: 2

disjob-core/src/main/java/cn/ponfee/disjob/core/base/Supervisor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public int hashCode() {
169169
private static synchronized Current create(final String host, final int port,
170170
final UnaryOperator<String> workerContextPath) {
171171
if (instance != null) {
172-
throw new Error("Current supervisor already set.");
172+
throw new Error("Current supervisor already created.");
173173
}
174174

175175
instance = new Current(host, port) {

disjob-core/src/main/java/cn/ponfee/disjob/core/base/Worker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ private static synchronized Current create(final String group, final String work
268268
final String wToken, final String sToken,
269269
final String supervisorContextPath) {
270270
if (instance != null) {
271-
throw new Error("Current worker already set.");
271+
throw new Error("Current worker already created.");
272272
}
273273

274274
instance = new Current(group, workerId, host, port) {

disjob-samples/conf-supervisor/application-mysql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# database configuration
22
disjob.datasource:
33
driver-class-name: com.mysql.cj.jdbc.Driver
4-
jdbc-url: jdbc:mysql://localhost:3306/disjob?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&connectTimeout=2000&socketTimeout=5000&serverTimezone=Asia/Shanghai&failOverReadOnly=false
4+
jdbc-url: jdbc:mysql://localhost:3306/disjob?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&connectTimeout=2000&socketTimeout=5000&serverTimezone=Asia/Shanghai&failOverReadOnly=false
55
username: disjob
66
password: disjob$123456
77
minimum-idle: 2

disjob-samples/disjob-samples-springboot-common/src/main/resources/application-registry_database.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ disjob.registry.database:
44
session-timeout-ms: 30000
55
datasource:
66
driver-class-name: com.mysql.cj.jdbc.Driver
7-
jdbc-url: jdbc:mysql://localhost:3306/disjob?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&connectTimeout=2000&socketTimeout=5000&serverTimezone=Asia/Shanghai&failOverReadOnly=false
7+
jdbc-url: jdbc:mysql://localhost:3306/disjob?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&connectTimeout=2000&socketTimeout=5000&serverTimezone=Asia/Shanghai&failOverReadOnly=false
88
username: disjob
99
password: disjob$123456
1010
minimum-idle: 2

disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/component/DistributedJobManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public void updateTaskWorker(List<UpdateTaskWorkerParam> list) {
194194
if (CollectionUtils.isNotEmpty(list)) {
195195
// Sort for prevent sql deadlock: Deadlock found when trying to get lock; try restarting transaction
196196
list.sort(Comparator.comparingLong(UpdateTaskWorkerParam::getTaskId));
197-
Collects.batchProcess(list, taskMapper::batchUpdateWorker, PROCESS_BATCH_SIZE);
197+
Collects.batchProcess(list, taskMapper::batchUpdateWorker, 20);
198198
}
199199
}
200200

disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/dao/SupervisorDataSourceConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* <pre>
4040
* disjob.datasource:
4141
* driver-class-name: com.mysql.cj.jdbc.Driver
42-
* jdbc-url: jdbc:mysql://localhost:3306/disjob?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&connectTimeout=2000&socketTimeout=5000&serverTimezone=Asia/Shanghai&failOverReadOnly=false
42+
* jdbc-url: jdbc:mysql://localhost:3306/disjob?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&connectTimeout=2000&socketTimeout=5000&serverTimezone=Asia/Shanghai&failOverReadOnly=false
4343
* username: disjob
4444
* password:
4545
* minimum-idle: 10

disjob-supervisor/src/main/java/cn/ponfee/disjob/supervisor/dao/xml/SchedTaskMapper.xml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,16 @@
137137
AND (SELECT cnt FROM (SELECT COUNT(*) cnt FROM <include refid="Table_Name" /> WHERE instance_id = #{instanceId,jdbcType=BIGINT} AND execute_state &lt; 40) t)=0
138138
</delete>
139139

140-
<!-- allowMultiQueries=true -->
141-
<update id="batchUpdateWorker" parameterType="collection">
142-
<foreach collection="collection" item="item" separator=";">
143-
UPDATE <include refid="Table_Name" />
144-
SET worker = #{item.worker,jdbcType=VARCHAR},
145-
version = version+1
146-
WHERE task_id = #{item.taskId,jdbcType=BIGINT}
147-
AND execute_state = 10
148-
</foreach>
140+
<update id="batchUpdateWorker" parameterType="list">
141+
UPDATE <include refid="Table_Name" />
142+
SET version = version+1,
143+
worker =
144+
CASE
145+
<foreach collection="list" item="item" separator=" ">
146+
WHEN task_id = #{item.taskId,jdbcType=BIGINT} THEN #{item.worker,jdbcType=VARCHAR}
147+
</foreach>
148+
END
149+
WHERE task_id IN (<foreach collection="list" separator="," item="item">#{item.taskId,jdbcType=BIGINT}</foreach>)
149150
</update>
150151

151152
</mapper>

disjob-supervisor/src/test/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ server.port: 0
33
# database configuration
44
disjob.datasource:
55
driver-class-name: com.mysql.cj.jdbc.Driver
6-
jdbc-url: jdbc:mysql://localhost:23306/disjob?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&connectTimeout=2000&socketTimeout=5000&serverTimezone=Asia/Shanghai&failOverReadOnly=false
6+
jdbc-url: jdbc:mysql://localhost:23306/disjob?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&connectTimeout=2000&socketTimeout=5000&serverTimezone=Asia/Shanghai&failOverReadOnly=false
77
username: disjob
88
password: disjob$123456
99
minimum-idle: 2

0 commit comments

Comments
 (0)