fix: 2.5.0
1. 修复postgres兼容问题
This commit is contained in:
parent
f86a69406b
commit
cc1ced4f10
@ -11,7 +11,7 @@ CREATE TABLE namespace
|
||||
deleted SMALLINT NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX uk_namespace_unique_id ON namespace (unique_id);
|
||||
CREATE UNIQUE INDEX uk_namespace_unique_id ON "namespace" (unique_id);
|
||||
|
||||
COMMENT ON COLUMN namespace.id IS '主键';
|
||||
COMMENT ON COLUMN namespace.name IS '名称';
|
||||
@ -22,6 +22,9 @@ COMMENT ON COLUMN namespace.update_dt IS '修改时间';
|
||||
COMMENT ON COLUMN namespace.deleted IS '逻辑删除 1、删除';
|
||||
COMMENT ON TABLE namespace IS '命名空间';
|
||||
|
||||
INSERT INTO namespace (name, unique_id, create_dt, update_dt, deleted)
|
||||
VALUES ('Default', '764d604ec6fc45f68cd92514c40e9e1a', now(), now(), 0);
|
||||
|
||||
CREATE TABLE group_config
|
||||
(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
@ -555,6 +558,7 @@ COMMENT ON TABLE "job_task" IS '任务批次';
|
||||
CREATE TABLE job_notify_config
|
||||
(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
namespace_id VARCHAR(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a',
|
||||
group_name VARCHAR(64) NOT NULL,
|
||||
job_id BIGINT NOT NULL,
|
||||
notify_status SMALLINT NOT NULL DEFAULT 0,
|
||||
@ -569,9 +573,10 @@ CREATE TABLE job_notify_config
|
||||
update_dt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE INDEX idx_group_name ON job_notify_config (group_name);
|
||||
CREATE INDEX idx_namespace_id_group_name_job_id_job_notify_config ON job_notify_config (namespace_id, group_name, job_id);
|
||||
|
||||
COMMENT ON COLUMN "job_notify_config"."id" IS '主键';
|
||||
COMMENT ON COLUMN "job_task"."namespace_id" IS '命名空间id';
|
||||
COMMENT ON COLUMN "job_notify_config"."group_name" IS '组名称';
|
||||
COMMENT ON COLUMN "job_notify_config"."job_id" IS '任务信息id';
|
||||
COMMENT ON COLUMN "job_notify_config"."notify_status" IS '通知状态 0、未启用 1、启用';
|
||||
|
@ -52,5 +52,5 @@ public class Namespace implements Serializable {
|
||||
/**
|
||||
* 逻辑删除 1、删除
|
||||
*/
|
||||
private Byte deleted;
|
||||
private Integer deleted;
|
||||
}
|
||||
|
@ -32,4 +32,18 @@
|
||||
#{item.taskType}, #{item.createDt}, #{item.namespaceId})
|
||||
</foreach>
|
||||
</insert>
|
||||
<!-- 重试统计 -->
|
||||
<select id="retrySummaryRetryTaskLogList"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryResponseDO">
|
||||
SELECT namespace_id AS namespaceId,
|
||||
group_name AS groupName,
|
||||
scene_name AS sceneName,
|
||||
SUM(CASE WHEN (retry_status = 0) THEN 1 ELSE 0 END) AS runningNum,
|
||||
SUM(CASE WHEN (retry_status = 1) THEN 1 ELSE 0 END) AS finishNum,
|
||||
SUM(CASE WHEN (retry_status = 2) THEN 1 ELSE 0 END) AS maxCountNum,
|
||||
SUM(CASE WHEN (retry_status = 3) THEN 1 ELSE 0 END) AS suspendNum
|
||||
FROM retry_task_log
|
||||
WHERE create_dt between #{from} and #{to}
|
||||
GROUP BY namespace_id, group_name, scene_name
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -18,13 +18,13 @@
|
||||
id, group_name, context_path, host_id, host_ip, host_port, expire_at, node_type,create_dt,update_dt
|
||||
</sql>
|
||||
<insert id="insertOrUpdate" parameterType="com.aizuda.easy.retry.template.datasource.persistence.po.ServerNode" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into server_node (id, group_name, host_id, host_ip, host_port,
|
||||
insert into server_node (namespace_id, group_name, host_id, host_ip, host_port,
|
||||
expire_at, node_type, ext_attrs, context_path, create_dt)
|
||||
values
|
||||
<foreach collection="records" item="item" index="index" separator="," open="(" close=")">
|
||||
#{id,jdbcType=BIGINT}, #{groupName,jdbcType=VARCHAR}, #{hostId,jdbcType=VARCHAR}, #{hostIp,jdbcType=VARCHAR},
|
||||
#{hostPort,jdbcType=INTEGER},
|
||||
#{expireAt,jdbcType=TIMESTAMP}, #{nodeType,jdbcType=TINYINT}, #{extAttrs,jdbcType=VARCHAR}, #{contextPath,jdbcType=VARCHAR}, #{createDt,jdbcType=TIMESTAMP}
|
||||
<foreach collection="records" item="item" index="index" separator=",">
|
||||
(#{item.namespaceId,jdbcType=VARCHAR}, #{item.groupName,jdbcType=VARCHAR}, #{item.hostId,jdbcType=VARCHAR}, #{item.hostIp,jdbcType=VARCHAR},
|
||||
#{item.hostPort,jdbcType=INTEGER}, #{item.expireAt,jdbcType=TIMESTAMP}, #{item.nodeType,jdbcType=TINYINT},
|
||||
#{item.extAttrs,jdbcType=VARCHAR}, #{item.contextPath,jdbcType=VARCHAR}, #{item.createDt,jdbcType=TIMESTAMP})
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
expire_at = values(`expire_at`)
|
||||
|
@ -53,28 +53,28 @@
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="type == 'DAY'">
|
||||
DATE_FORMAT(create_dt,'%H')
|
||||
to_char(create_dt,'%H')
|
||||
</when>
|
||||
<when test="type == 'WEEK'">
|
||||
DATE_FORMAT(create_dt,'%Y-%m-%d')
|
||||
to_char(create_dt,'%Y-%m-%d')
|
||||
</when>
|
||||
<when test="type =='MONTH'">
|
||||
DATE_FORMAT(create_dt,'%Y-%m-%d')
|
||||
to_char(create_dt,'%Y-%m-%d')
|
||||
</when>
|
||||
<when test="type == 'YEAR'">
|
||||
DATE_FORMAT(create_dt,'%Y-%m')
|
||||
to_char(create_dt,'%Y-%m')
|
||||
</when>
|
||||
<otherwise>
|
||||
DATE_FORMAT(create_dt,'%Y-%m-%d')
|
||||
to_char(create_dt,'%Y-%m-%d')
|
||||
</otherwise>
|
||||
</choose>
|
||||
AS createDt,
|
||||
ifnull(SUM(success_num), 0) AS success,
|
||||
ifnull(SUM(fail_num), 0) AS failNum,
|
||||
ifnull(SUM(stop_num), 0) AS stop,
|
||||
ifnull(SUM(cancel_num), 0) AS cancel,
|
||||
ifnull(SUM(fail_num + stop_num + cancel_num), 0) AS fail,
|
||||
ifnull(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
|
||||
COALESCE(SUM(success_num), 0) AS success,
|
||||
COALESCE(SUM(fail_num), 0) AS failNum,
|
||||
COALESCE(SUM(stop_num), 0) AS stop,
|
||||
COALESCE(SUM(cancel_num), 0) AS cancel,
|
||||
COALESCE(SUM(fail_num + stop_num + cancel_num), 0) AS fail,
|
||||
COALESCE(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
|
||||
FROM job_summary
|
||||
<where>
|
||||
<if test="groupName != null and groupName != '' ">
|
||||
@ -87,11 +87,11 @@
|
||||
|
||||
<select id="toJobTask"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$JobTask">
|
||||
SELECT ifnull(sum(success_num), 0) AS successNum,
|
||||
ifnull(sum(stop_num), 0) AS stopNum,
|
||||
ifnull(sum(cancel_num), 0) AS cancelNum,
|
||||
ifnull(sum(fail_num), 0) AS failNum,
|
||||
ifnull(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum
|
||||
SELECT COALESCE(sum(success_num), 0) AS successNum,
|
||||
COALESCE(sum(stop_num), 0) AS stopNum,
|
||||
COALESCE(sum(cancel_num), 0) AS cancelNum,
|
||||
COALESCE(sum(fail_num), 0) AS failNum,
|
||||
COALESCE(sum(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum
|
||||
FROM job_summary
|
||||
WHERE namespace_id = #{namespaceId}
|
||||
</select>
|
||||
@ -99,7 +99,7 @@
|
||||
<select id="dashboardRank"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
|
||||
SELECT
|
||||
CONCAT(group_name, '/', (SELECT job_name FROM job WHERE id=job_id)) `name`,
|
||||
CONCAT(group_name, '/', (SELECT job_name FROM job WHERE id=job_id)) name,
|
||||
SUM(fail_num) AS total FROM job_summary
|
||||
<where>
|
||||
<if test="groupName != '' and groupName != null">
|
||||
@ -109,7 +109,7 @@
|
||||
</where>
|
||||
AND namespace_id = #{namespaceId}
|
||||
GROUP BY namespace_id, group_name, job_id
|
||||
HAVING total > 0
|
||||
HAVING SUM(fail_num) > 0
|
||||
ORDER BY total DESC LIMIT 10
|
||||
</select>
|
||||
|
||||
|
@ -41,31 +41,31 @@
|
||||
|
||||
<select id="retryTask"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTask">
|
||||
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 COALESCE(sum(running_num), 0) AS runningNum,
|
||||
COALESCE(sum(finish_num), 0) AS finishNum,
|
||||
COALESCE(sum(max_count_num), 0) AS maxCountNum,
|
||||
COALESCE(sum(suspend_num), 0) AS suspendNum,
|
||||
COALESCE(sum(running_num + finish_num + max_count_num + suspend_num), 0) AS totalNum
|
||||
FROM retry_summary
|
||||
WHERE namespace_id = #{namespaceId}
|
||||
</select>
|
||||
|
||||
<select id="retryTaskBarList"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTaskBar">
|
||||
SELECT tmp.date AS x, ifnull(b.taskTotal, 0) AS taskTotal
|
||||
FROM (SELECT curdate() AS date
|
||||
SELECT tmp.date AS x, COALESCE(b.taskTotal, 0) AS taskTotal
|
||||
FROM (SELECT CURRENT_DATE AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY) AS date
|
||||
SELECT CURRENT_DATE - INTERVAL '1 day' AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 2 day) AS date
|
||||
SELECT CURRENT_DATE - INTERVAL '2 days' AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 3 day) AS date
|
||||
SELECT CURRENT_DATE - INTERVAL '3 days' AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 4 day) AS date
|
||||
SELECT CURRENT_DATE - INTERVAL '4 days' AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 5 day) AS date
|
||||
SELECT CURRENT_DATE - INTERVAL '5 days' AS date
|
||||
UNION ALL
|
||||
SELECT DATE_SUB(CURDATE(), interval 6 day) AS date) tmp
|
||||
SELECT CURRENT_DATE - INTERVAL '6 days' AS date) tmp
|
||||
LEFT JOIN (SELECT DATE (trigger_at) AS triggerAt,
|
||||
SUM(running_num + finish_num + max_count_num + suspend_num) AS taskTotal FROM retry_summary
|
||||
WHERE namespace_id = #{namespaceId}
|
||||
@ -79,27 +79,27 @@
|
||||
SELECT
|
||||
<choose>
|
||||
<when test="type == 'DAY'">
|
||||
DATE_FORMAT(create_dt,'%H')
|
||||
to_char(create_dt,'%H')
|
||||
</when>
|
||||
<when test="type == 'WEEK'">
|
||||
DATE_FORMAT(create_dt,'%Y-%m-%d')
|
||||
to_char(create_dt,'%Y-%m-%d')
|
||||
</when>
|
||||
<when test="type =='MONTH'">
|
||||
DATE_FORMAT(create_dt,'%Y-%m-%d')
|
||||
to_char(create_dt,'%Y-%m-%d')
|
||||
</when>
|
||||
<when test="type == 'YEAR'">
|
||||
DATE_FORMAT(create_dt,'%Y-%m')
|
||||
to_char(create_dt,'%Y-%m')
|
||||
</when>
|
||||
<otherwise>
|
||||
DATE_FORMAT(create_dt,'%Y-%m-%d')
|
||||
to_char(create_dt,'%Y-%m-%d')
|
||||
</otherwise>
|
||||
</choose>
|
||||
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
|
||||
COALESCE(SUM(finish_num), 0) AS successNum,
|
||||
COALESCE(SUM(running_num), 0) AS runningNum,
|
||||
COALESCE(SUM(max_count_num), 0) AS maxCountNum,
|
||||
COALESCE(SUM(suspend_num), 0) AS suspendNum,
|
||||
COALESCE(SUM(finish_num + running_num + max_count_num + suspend_num), 0) AS total
|
||||
FROM retry_summary
|
||||
<where>
|
||||
<if test="groupName != null and groupName != '' ">
|
||||
@ -113,7 +113,7 @@
|
||||
<select id="dashboardRank"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
|
||||
SELECT
|
||||
CONCAT(group_name, '/', scene_name) `name`,
|
||||
CONCAT(group_name, '/', scene_name) name,
|
||||
SUM(running_num + finish_num + max_count_num + suspend_num) AS total FROM retry_summary
|
||||
<where>
|
||||
<if test="groupName != '' and groupName != null">
|
||||
@ -123,7 +123,7 @@
|
||||
AND trigger_at >= #{startTime} AND trigger_at <= #{endTime}
|
||||
</where>
|
||||
GROUP BY namespace_id, group_name, scene_name
|
||||
HAVING total > 0
|
||||
HAVING SUM(running_num + finish_num + max_count_num + suspend_num) > 0
|
||||
ORDER BY total DESC LIMIT 10
|
||||
</select>
|
||||
|
||||
|
@ -32,4 +32,19 @@
|
||||
#{item.taskType}, #{item.createDt}, #{item.namespaceId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 重试统计 -->
|
||||
<select id="retrySummaryRetryTaskLogList"
|
||||
resultType="com.aizuda.easy.retry.template.datasource.persistence.dataobject.DashboardRetryResponseDO">
|
||||
SELECT namespace_id AS namespaceId,
|
||||
group_name AS groupName,
|
||||
scene_name AS sceneName,
|
||||
SUM(CASE WHEN (retry_status = 0) THEN 1 ELSE 0 END) AS runningNum,
|
||||
SUM(CASE WHEN (retry_status = 1) THEN 1 ELSE 0 END) AS finishNum,
|
||||
SUM(CASE WHEN (retry_status = 2) THEN 1 ELSE 0 END) AS maxCountNum,
|
||||
SUM(CASE WHEN (retry_status = 3) THEN 1 ELSE 0 END) AS suspendNum
|
||||
FROM retry_task_log
|
||||
WHERE create_dt between #{from} and #{to}
|
||||
GROUP BY namespace_id, group_name, scene_name
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -19,7 +19,7 @@
|
||||
</sql>
|
||||
<insert id="insertOrUpdate" parameterType="com.aizuda.easy.retry.template.datasource.persistence.po.ServerNode"
|
||||
useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO server_node (group_name, host_id, host_ip, host_port,
|
||||
INSERT INTO server_node (namespace_id, group_name, host_id, host_ip, host_port,
|
||||
expire_at, node_type, ext_attrs, context_path, create_dt)
|
||||
VALUES
|
||||
<foreach collection="records" item="item" index="index" separator=",">
|
||||
|
@ -11,6 +11,7 @@ import com.aizuda.easy.retry.server.web.model.response.GroupConfigResponseVO;
|
||||
import com.aizuda.easy.retry.server.web.annotation.LoginRequired;
|
||||
import com.aizuda.easy.retry.server.web.annotation.RoleEnum;
|
||||
import com.aizuda.easy.retry.server.web.service.GroupConfigService;
|
||||
import com.aizuda.easy.retry.template.datasource.enums.DbTypeEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -91,7 +92,16 @@ public class GroupConfigController {
|
||||
@GetMapping("/partition-table/list")
|
||||
public List<Integer> getTablePartitionList() {
|
||||
// https://gitee.com/aizuda/easy-retry/issues/I8DAMH
|
||||
List<String> tableList = jdbcTemplate.queryForList("SHOW TABLES LIKE 'retry_task_%'", String.class);
|
||||
String sql;
|
||||
if (systemProperties.getDbType().getDb().equals(DbTypeEnum.POSTGRES.getDb())) {
|
||||
sql = "SELECT table_name\n"
|
||||
+ "FROM information_schema.tables\n"
|
||||
+ "WHERE table_name LIKE 'retry_task_%' AND table_schema = 'public'";
|
||||
} else {
|
||||
sql = "SHOW TABLES LIKE 'retry_task_%'";
|
||||
}
|
||||
|
||||
List<String> tableList = jdbcTemplate.queryForList(sql, String.class);
|
||||
return tableList.stream().map(ReUtil::getFirstNumber).filter(i ->
|
||||
!Objects.isNull(i) && i <= systemProperties.getTotalPartition()).distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
||||
|
||||
try {
|
||||
TaskAccess<RetryDeadLetter> retryTaskAccess = accessTemplate.getRetryDeadLetterAccess();
|
||||
retryTaskAccess.one(groupConfig.getGroupName(), groupConfig.getNamespaceId(),
|
||||
retryTaskAccess.one(groupConfig.getGroupName(), namespaceId,
|
||||
new LambdaQueryWrapper<RetryDeadLetter>().eq(RetryDeadLetter::getId, 1));
|
||||
} catch (BadSqlGrammarException e) {
|
||||
Optional.ofNullable(e.getMessage()).ifPresent(s -> {
|
||||
|
@ -26,13 +26,13 @@ import com.aizuda.easy.retry.server.web.service.convert.JobConverter;
|
||||
import com.aizuda.easy.retry.server.web.service.convert.JobResponseVOConverter;
|
||||
import com.aizuda.easy.retry.server.web.util.UserSessionUtils;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.mapper.JobMapper;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.GroupConfig;
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.Job;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -54,6 +54,7 @@ public class JobServiceImpl implements JobService {
|
||||
private JobMapper jobMapper;
|
||||
@Autowired
|
||||
@Qualifier("terminalJobPrepareHandler")
|
||||
@Lazy
|
||||
private JobPrePareHandler jobPrePareHandler;
|
||||
|
||||
@Override
|
||||
|
@ -73,7 +73,7 @@ public class NamespaceServiceImpl implements NamespaceService {
|
||||
;
|
||||
}
|
||||
|
||||
queryWrapper.eq(Namespace::getDeleted, StatusEnum.NO);
|
||||
queryWrapper.eq(Namespace::getDeleted, StatusEnum.NO.getStatus());
|
||||
queryWrapper.orderByDesc(Namespace::getId);
|
||||
PageDTO<Namespace> selectPage = namespaceMapper.selectPage(pageDTO, queryWrapper);
|
||||
return new PageResult<>(pageDTO,
|
||||
|
Loading…
Reference in New Issue
Block a user