From 7cb854a019e42fd2e017fd3c77a77dc9b81da1b1 Mon Sep 17 00:00:00 2001 From: dhb52 Date: Sun, 31 Mar 2024 23:30:00 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20docker=E5=A2=9E=E5=8A=A0mariadb?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/docker/docker-compose.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/docker/docker-compose.yaml b/doc/docker/docker-compose.yaml index 137e40b2..c22809f8 100644 --- a/doc/docker/docker-compose.yaml +++ b/doc/docker/docker-compose.yaml @@ -7,6 +7,7 @@ volumes: postgres: { } oracle: { } sqlserver: { } + mariadb: { } services: mysql: @@ -69,3 +70,17 @@ services: - ../sql/easy_retry_sqlserver.sql:/tmp/schema.sql:ro # docker compose exec sqlserver bash /tmp/create_schema.sh - ./sqlserver/create_schema.sh:/tmp/create_schema.sh:ro + + mariadb: + image: mariadb:10.11.7 + restart: unless-stopped + environment: + TZ: Asia/Shanghai + MARIADB_ROOT_PASSWORD: root + MARIADB_DATABASE: easy_retry + ports: + - "3308:3306" + volumes: + - mariadb:/var/lib/mysql/ + # 注入初始化脚本, mysql + - ../sql/easy_retry_mysql.sql:/docker-entrypoint-initdb.d/init.sql:ro \ No newline at end of file -- Gitee From fe66990381b55e896e8c487db4120990f33f2d8e Mon Sep 17 00:00:00 2001 From: dhb52 Date: Sun, 31 Mar 2024 23:30:59 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20application.yml=E5=A2=9E=E5=8A=A0ma?= =?UTF-8?q?riadb=E8=BF=9E=E6=8E=A5=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/easy-retry-server/easy-retry-server-starter/src/main/resources/application.yml b/easy-retry-server/easy-retry-server-starter/src/main/resources/application.yml index 2d7f26ee..04ca19d4 100644 --- a/easy-retry-server/easy-retry-server-starter/src/main/resources/application.yml +++ b/easy-retry-server/easy-retry-server-starter/src/main/resources/application.yml @@ -27,6 +27,11 @@ spring: # url: jdbc:sqlserver://localhost:1433;DatabaseName=easy_retry;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true # username: SA # password: EasyRetry@24 + ## mariadb +# driver-class-name: org.mariadb.jdbc.Driver +# url: jdbc:mariadb://localhost:3308/easy_retry?useSSL=false&characterEncoding=utf8&useUnicode=true +# username: root +# password: root type: com.zaxxer.hikari.HikariDataSource hikari: connection-timeout: 30000 -- Gitee From 65e99a6a1b1152b43f1a16fe39bd072cfc0161b7 Mon Sep 17 00:00:00 2001 From: dhb52 Date: Sun, 31 Mar 2024 23:31:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8=E6=9C=80=E6=96=B0?= =?UTF-8?q?mysql=E7=9A=84mapper.xml=E8=A6=86=E7=9B=96mariadb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mariadb/mapper/JobLogMessageMapper.xml | 46 ++++----- .../resources/mariadb/mapper/JobMapper.xml | 21 ++-- .../mariadb/mapper/JobSummaryMapper.xml | 99 ++++++++++--------- .../mariadb/mapper/RetryDeadLetterMapper.xml | 29 ++++-- .../mariadb/mapper/RetrySummaryMapper.xml | 89 +++++++++-------- .../mariadb/mapper/RetryTaskLogMapper.xml | 15 +-- .../mapper/RetryTaskLogMessageMapper.xml | 37 ++++++- .../mariadb/mapper/RetryTaskMapper.xml | 22 ++--- .../mariadb/mapper/ServerNodeMapper.xml | 72 +++++++------- .../mariadb/mapper/WorkflowMapper.xml | 23 +++-- 10 files changed, 253 insertions(+), 200 deletions(-) diff --git a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobLogMessageMapper.xml b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobLogMessageMapper.xml index 11f0b99a..61363a6f 100644 --- a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobLogMessageMapper.xml +++ b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobLogMessageMapper.xml @@ -19,30 +19,30 @@ INSERT INTO job_log_message - ( - namespace_id, - group_name, - job_id, - task_batch_id, - task_id, - log_num, - message, - create_dt, - real_time - ) - VALUES - ( - #{item.namespaceId}, - #{item.groupName}, - #{item.jobId}, - #{item.taskBatchId}, - #{item.taskId}, - #{item.logNum}, - #{item.message}, - #{item.createDt}, - #{item.realTime} + namespace_id, + group_name, + job_id, + task_batch_id, + task_id, + log_num, + message, + create_dt, + real_time ) - + VALUES + + ( + #{item.namespaceId}, + #{item.groupName}, + #{item.jobId}, + #{item.taskBatchId}, + #{item.taskId}, + #{item.logNum}, + #{item.message}, + #{item.createDt}, + #{item.realTime} + ) + diff --git a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobMapper.xml b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobMapper.xml index de263ea0..518a0c23 100644 --- a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobMapper.xml +++ b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobMapper.xml @@ -27,17 +27,16 @@ - update job rt, - ( - - select - #{item.nextTriggerAt} as next_trigger_at, - #{item.id} as id - - ) tt - set - rt.next_trigger_at = tt.next_trigger_at - where rt.id = tt.id + UPDATE job rt, + ( + + SELECT + #{item.nextTriggerAt} AS next_trigger_at, + #{item.id} AS id + + ) tt + SET rt.next_trigger_at = tt.next_trigger_at + WHERE rt.id = tt.id diff --git a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobSummaryMapper.xml b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobSummaryMapper.xml index ac27f9ad..d0b4e728 100644 --- a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobSummaryMapper.xml +++ b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/JobSummaryMapper.xml @@ -23,50 +23,49 @@ INSERT INTO job_summary (namespace_id, group_name, business_id, trigger_at, system_task_type, success_num,fail_num,fail_reason,stop_num,stop_reason, cancel_num,cancel_reason) VALUES - - ( - #{item.namespaceId}, - #{item.groupName}, - #{item.businessId}, - #{item.triggerAt}, - #{item.systemTaskType}, - #{item.successNum}, - #{item.failNum}, - #{item.failReason}, - #{item.stopNum}, - #{item.stopReason}, - #{item.cancelNum}, - #{item.cancelReason} - ) - + + ( + #{item.namespaceId}, + #{item.groupName}, + #{item.businessId}, + #{item.triggerAt}, + #{item.systemTaskType}, + #{item.successNum}, + #{item.failNum}, + #{item.failReason}, + #{item.stopNum}, + #{item.stopReason}, + #{item.cancelNum}, + #{item.cancelReason} + ) + UPDATE job_summary rt, - ( - - SELECT - #{item.successNum} AS success_num, - #{item.failNum} AS fail_num, - #{item.failReason} AS fail_reason, - #{item.stopNum} AS stop_num, - #{item.stopReason} AS stop_reason, - #{item.cancelNum} AS cancel_num, - #{item.cancelReason} AS cancel_reason, - #{item.triggerAt} AS trigger_at, - #{item.businessId} AS business_id - - ) tt - SET - rt.success_num = tt.success_num, - rt.fail_num = tt.fail_num, - rt.fail_reason = tt.fail_reason, - rt.stop_num = tt.stop_num, - rt.stop_reason = tt.stop_reason, - rt.cancel_num = tt.cancel_num, - rt.cancel_reason = tt.cancel_reason - WHERE rt.trigger_at = tt.trigger_at - AND rt.business_id = tt.business_id + ( + + SELECT + #{item.successNum} AS success_num, + #{item.failNum} AS fail_num, + #{item.failReason} AS fail_reason, + #{item.stopNum} AS stop_num, + #{item.stopReason} AS stop_reason, + #{item.cancelNum} AS cancel_num, + #{item.cancelReason} AS cancel_reason, + #{item.triggerAt} AS trigger_at, + #{item.businessId} AS business_id + + ) tt + SET rt.success_num = tt.success_num, + rt.fail_num = tt.fail_num, + rt.fail_reason = tt.fail_reason, + rt.stop_num = tt.stop_num, + rt.stop_reason = tt.stop_reason, + rt.cancel_num = tt.cancel_num, + rt.cancel_reason = tt.cancel_reason + WHERE rt.trigger_at = tt.trigger_at + AND rt.business_id = tt.business_id @@ -104,10 +103,12 @@ CONCAT(group_name, '/', (SELECT workflow_name FROM workflow WHERE id = business_id)) name, - SUM(fail_num) AS total FROM job_summary + SUM(fail_num) AS total + FROM job_summary ${ew.customSqlSegment} HAVING total > 0 - ORDER BY total DESC LIMIT 10 + ORDER BY total DESC + LIMIT 10 - SELECT ifnull(sum(running_num), 0) AS runningNum, - ifnull(sum(finish_num), 0) AS finishNum, - ifnull(sum(max_count_num), 0) AS maxCountNum, - ifnull(sum(suspend_num), 0) AS suspendNum, - ifnull(sum(running_num + finish_num + max_count_num + suspend_num), 0) AS totalNum + SELECT IFNULL(SUM(running_num), 0) AS runningNum, + IFNULL(SUM(finish_num), 0) AS finishNum, + IFNULL(SUM(max_count_num), 0) AS maxCountNum, + IFNULL(SUM(suspend_num), 0) AS suspendNum, + IFNULL(SUM(running_num + finish_num + max_count_num + suspend_num), 0) AS totalNum FROM retry_summary ${ew.customSqlSegment} SELECT - DATE_FORMAT(create_dt, #{dateFormat}) AS createDt, - IFNULL(SUM(finish_num), 0) AS successNum, - IFNULL(SUM(running_num), 0) AS runningNum, - IFNULL(SUM(max_count_num), 0) AS maxCountNum, - IFNULL(SUM(suspend_num), 0) AS suspendNum, - IFNULL(SUM(finish_num + running_num + max_count_num + suspend_num), 0) AS total + DATE_FORMAT(create_dt, #{dateFormat}) AS createDt, + IFNULL(SUM(finish_num), 0) AS successNum, + IFNULL(SUM(running_num), 0) AS runningNum, + IFNULL(SUM(max_count_num), 0) AS maxCountNum, + IFNULL(SUM(suspend_num), 0) AS suspendNum, + IFNULL(SUM(finish_num + running_num + max_count_num + suspend_num), 0) AS total FROM retry_summary ${ew.customSqlSegment} GROUP BY createDt @@ -94,22 +98,21 @@ diff --git a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/RetryTaskLogMapper.xml b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/RetryTaskLogMapper.xml index b42dc32f..cc484ef5 100644 --- a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/RetryTaskLogMapper.xml +++ b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/RetryTaskLogMapper.xml @@ -17,24 +17,25 @@ - id - , unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, retry_status, - create_dt, task_type, namespace_id + id, unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, retry_status, + create_dt, task_type, namespace_id + INSERT INTO retry_task_log (unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name, - args_str, ext_attrs, task_type, create_dt, namespace_id) + args_str, ext_attrs, task_type, create_dt, namespace_id) VALUES (#{item.uniqueId}, #{item.groupName}, #{item.sceneName}, #{item.idempotentId}, - #{item.bizNo}, #{item.executorName}, #{item.argsStr}, #{item.extAttrs}, - #{item.taskType}, #{item.createDt}, #{item.namespaceId}) + #{item.bizNo}, #{item.executorName}, #{item.argsStr}, #{item.extAttrs}, + #{item.taskType}, #{item.createDt}, #{item.namespaceId}) + - SELECT node_type as nodeType, count(*) as total - from server_node - ${ew.customSqlSegment} - + diff --git a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/WorkflowMapper.xml b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/WorkflowMapper.xml index d957fb80..23aad000 100644 --- a/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/WorkflowMapper.xml +++ b/easy-retry-datasource/easy-retry-mariadb-datasource/src/main/resources/mariadb/mapper/WorkflowMapper.xml @@ -15,19 +15,18 @@ + - update workflow rt, - ( - - select - #{item.nextTriggerAt} as next_trigger_at, - #{item.id} as id - - ) tt - set - rt.next_trigger_at = tt.next_trigger_at - where rt.id = tt.id + UPDATE workflow rt, + ( + + SELECT + #{item.nextTriggerAt} AS next_trigger_at, + #{item.id} AS id + + ) tt + SET rt.next_trigger_at = tt.next_trigger_at + WHERE rt.id = tt.id - -- Gitee