This is an automated email from the ASF dual-hosted git repository.
healchow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git
The following commit(s) were added to refs/heads/master by this push:
new 1941ebc327 [INLONG-8449][Manager] Fix abnormal growth of
self-increasing primary key in the heartbeat table (#8454)
1941ebc327 is described below
commit 1941ebc327bbe51fb959bd0a2016fa9337ccfd7b
Author: fuweng11 <[email protected]>
AuthorDate: Fri Jul 7 13:52:02 2023 +0800
[INLONG-8449][Manager] Fix abnormal growth of self-increasing primary key
in the heartbeat table (#8454)
---
.../dao/mapper/ComponentHeartbeatEntityMapper.java | 4 ----
.../dao/mapper/GroupHeartbeatEntityMapper.java | 4 ----
.../dao/mapper/StreamHeartbeatEntityMapper.java | 4 ----
.../mappers/ComponentHeartbeatEntityMapper.xml | 20 ++++----------------
.../resources/mappers/GroupHeartbeatEntityMapper.xml | 14 +-------------
.../mappers/StreamHeartbeatEntityMapper.xml | 14 +-------------
.../src/main/resources/h2/apache_inlong_manager.sql | 12 +++---------
.../manager-web/sql/apache_inlong_manager.sql | 12 +++---------
inlong-manager/manager-web/sql/changes-1.8.0.sql | 12 ++++++++++++
9 files changed, 24 insertions(+), 72 deletions(-)
diff --git
a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/ComponentHeartbeatEntityMapper.java
b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/ComponentHeartbeatEntityMapper.java
index 49607486eb..941aa33518 100644
---
a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/ComponentHeartbeatEntityMapper.java
+++
b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/ComponentHeartbeatEntityMapper.java
@@ -32,8 +32,6 @@ public interface ComponentHeartbeatEntityMapper {
int insertOrUpdateByKey(ComponentHeartbeatEntity record);
- ComponentHeartbeatEntity selectByPrimaryKey(Integer id);
-
ComponentHeartbeatEntity selectByKey(@Param("component") String component,
@Param("instance") String instance);
List<ComponentHeartbeatEntity> selectByCondition(@Param("request")
HeartbeatPageRequest request);
@@ -48,6 +46,4 @@ public interface ComponentHeartbeatEntityMapper {
ComponentHeartbeatEntity selectTimeOutHeartBeat(@Param("component") String
component,
@Param("instance") String instance, @Param("beforeSeconds") Long
beforeSeconds);
- int deleteByPrimaryKey(Integer id);
-
}
\ No newline at end of file
diff --git
a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/GroupHeartbeatEntityMapper.java
b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/GroupHeartbeatEntityMapper.java
index 54122cadce..3a54139b36 100644
---
a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/GroupHeartbeatEntityMapper.java
+++
b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/GroupHeartbeatEntityMapper.java
@@ -34,13 +34,9 @@ public interface GroupHeartbeatEntityMapper {
int insertOrUpdateAll(@Param("component") String component,
@Param("instance") String instance,
@Param("reportTime") Long reportTime, @Param("list")
List<GroupHeartbeat> list);
- GroupHeartbeatEntity selectByPrimaryKey(Integer id);
-
GroupHeartbeatEntity selectByKey(@Param("component") String component,
@Param("instance") String instance,
@Param("inlongGroupId") String inlongGroupId);
List<GroupHeartbeatEntity> selectByCondition(@Param("request")
HeartbeatPageRequest request);
- int deleteByPrimaryKey(Integer id);
-
}
\ No newline at end of file
diff --git
a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/StreamHeartbeatEntityMapper.java
b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/StreamHeartbeatEntityMapper.java
index 3bbc7fc399..59e62adf06 100644
---
a/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/StreamHeartbeatEntityMapper.java
+++
b/inlong-manager/manager-dao/src/main/java/org/apache/inlong/manager/dao/mapper/StreamHeartbeatEntityMapper.java
@@ -34,13 +34,9 @@ public interface StreamHeartbeatEntityMapper {
int insertOrUpdateAll(@Param("component") String component,
@Param("instance") String instance,
@Param("reportTime") Long reportTime, @Param("list")
List<StreamHeartbeat> list);
- StreamHeartbeatEntity selectByPrimaryKey(Integer id);
-
StreamHeartbeatEntity selectByKey(@Param("component") String component,
@Param("instance") String instance,
@Param("inlongGroupId") String inlongGroupId,
@Param("inlongStreamId") String inlongStreamId);
List<StreamHeartbeatEntity> selectByCondition(@Param("request")
HeartbeatPageRequest request);
- int deleteByPrimaryKey(Integer id);
-
}
\ No newline at end of file
diff --git
a/inlong-manager/manager-dao/src/main/resources/mappers/ComponentHeartbeatEntityMapper.xml
b/inlong-manager/manager-dao/src/main/resources/mappers/ComponentHeartbeatEntityMapper.xml
index 077ae3efd1..c5f0ebf08c 100644
---
a/inlong-manager/manager-dao/src/main/resources/mappers/ComponentHeartbeatEntityMapper.xml
+++
b/inlong-manager/manager-dao/src/main/resources/mappers/ComponentHeartbeatEntityMapper.xml
@@ -21,7 +21,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace="org.apache.inlong.manager.dao.mapper.ComponentHeartbeatEntityMapper">
<resultMap id="BaseResultMap"
type="org.apache.inlong.manager.dao.entity.ComponentHeartbeatEntity">
- <id column="id" jdbcType="INTEGER" property="id"/>
<result column="component" jdbcType="VARCHAR" property="component"/>
<result column="instance" jdbcType="VARCHAR" property="instance"/>
<result column="status_heartbeat" jdbcType="LONGVARCHAR"
property="statusHeartbeat"/>
@@ -31,7 +30,7 @@
<result column="modify_time" jdbcType="TIMESTAMP"
property="modifyTime"/>
</resultMap>
<sql id="Base_Column_List">
- id, component, instance, status_heartbeat, metric_heartbeat,
report_time, create_time, modify_time
+ component, instance, status_heartbeat, metric_heartbeat, report_time,
create_time, modify_time
</sql>
<insert id="insert"
parameterType="org.apache.inlong.manager.dao.entity.ComponentHeartbeatEntity">
@@ -49,17 +48,11 @@
values (#{component,jdbcType=VARCHAR}, #{instance,jdbcType=VARCHAR},
#{statusHeartbeat,jdbcType=LONGVARCHAR},
#{metricHeartbeat,jdbcType=LONGVARCHAR},
#{reportTime,jdbcType=BIGINT})
- ON DUPLICATE KEY UPDATE status_heartbeat = values(status_heartbeat),
- metric_heartbeat = values(metric_heartbeat),
- report_time = values(report_time)
+ ON DUPLICATE KEY UPDATE status_heartbeat =
values(status_heartbeat),
+ metric_heartbeat = values(metric_heartbeat),
+ report_time = values(report_time)
</insert>
- <select id="selectByPrimaryKey" parameterType="java.lang.Integer"
resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List"/>
- from component_heartbeat
- where id = #{id,jdbcType=INTEGER}
- </select>
<select id="selectByKey" parameterType="java.lang.String"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
@@ -86,9 +79,4 @@
and modify_time >= DATE_ADD(NOW(), INTERVAL -#{beforeSeconds,
jdbcType=INTEGER} SECOND)
</select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
- delete
- from component_heartbeat
- where id = #{id,jdbcType=INTEGER}
- </delete>
</mapper>
\ No newline at end of file
diff --git
a/inlong-manager/manager-dao/src/main/resources/mappers/GroupHeartbeatEntityMapper.xml
b/inlong-manager/manager-dao/src/main/resources/mappers/GroupHeartbeatEntityMapper.xml
index 3bd5ec454e..b333c54fbc 100644
---
a/inlong-manager/manager-dao/src/main/resources/mappers/GroupHeartbeatEntityMapper.xml
+++
b/inlong-manager/manager-dao/src/main/resources/mappers/GroupHeartbeatEntityMapper.xml
@@ -21,7 +21,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace="org.apache.inlong.manager.dao.mapper.GroupHeartbeatEntityMapper">
<resultMap id="BaseResultMap"
type="org.apache.inlong.manager.dao.entity.GroupHeartbeatEntity">
- <id column="id" jdbcType="INTEGER" property="id"/>
<result column="component" jdbcType="VARCHAR" property="component"/>
<result column="instance" jdbcType="VARCHAR" property="instance"/>
<result column="inlong_group_id" jdbcType="VARCHAR"
property="inlongGroupId"/>
@@ -32,7 +31,7 @@
<result column="modify_time" jdbcType="TIMESTAMP"
property="modifyTime"/>
</resultMap>
<sql id="Base_Column_List">
- id, component, instance, inlong_group_id, status_heartbeat,
metric_heartbeat,
+ component, instance, inlong_group_id, status_heartbeat,
metric_heartbeat,
report_time, create_time, modify_time
</sql>
@@ -60,12 +59,6 @@
report_time = values(report_time)
</insert>
- <select id="selectByPrimaryKey" parameterType="java.lang.Integer"
resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List"/>
- from group_heartbeat
- where id = #{id,jdbcType=INTEGER}
- </select>
<select id="selectByKey" parameterType="java.lang.String"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
@@ -92,9 +85,4 @@
</where>
</select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
- delete
- from group_heartbeat
- where id = #{id,jdbcType=INTEGER}
- </delete>
</mapper>
\ No newline at end of file
diff --git
a/inlong-manager/manager-dao/src/main/resources/mappers/StreamHeartbeatEntityMapper.xml
b/inlong-manager/manager-dao/src/main/resources/mappers/StreamHeartbeatEntityMapper.xml
index d168a3a720..d1cf192673 100644
---
a/inlong-manager/manager-dao/src/main/resources/mappers/StreamHeartbeatEntityMapper.xml
+++
b/inlong-manager/manager-dao/src/main/resources/mappers/StreamHeartbeatEntityMapper.xml
@@ -21,7 +21,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace="org.apache.inlong.manager.dao.mapper.StreamHeartbeatEntityMapper">
<resultMap id="BaseResultMap"
type="org.apache.inlong.manager.dao.entity.StreamHeartbeatEntity">
- <id column="id" jdbcType="INTEGER" property="id"/>
<result column="component" jdbcType="VARCHAR" property="component"/>
<result column="instance" jdbcType="VARCHAR" property="instance"/>
<result column="inlong_group_id" jdbcType="VARCHAR"
property="inlongGroupId"/>
@@ -33,7 +32,7 @@
<result column="modify_time" jdbcType="TIMESTAMP"
property="modifyTime"/>
</resultMap>
<sql id="Base_Column_List">
- id, component, instance, inlong_group_id, inlong_stream_id,
status_heartbeat, metric_heartbeat,
+ component, instance, inlong_group_id, inlong_stream_id,
status_heartbeat, metric_heartbeat,
report_time, create_time, modify_time
</sql>
@@ -65,12 +64,6 @@
report_time = values(report_time)
</insert>
- <select id="selectByPrimaryKey" parameterType="java.lang.Integer"
resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List"/>
- from stream_heartbeat
- where id = #{id,jdbcType=INTEGER}
- </select>
<select id="selectByKey" parameterType="java.lang.String"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
@@ -99,9 +92,4 @@
</where>
</select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
- delete
- from stream_heartbeat
- where id = #{id,jdbcType=INTEGER}
- </delete>
</mapper>
\ No newline at end of file
diff --git
a/inlong-manager/manager-test/src/main/resources/h2/apache_inlong_manager.sql
b/inlong-manager/manager-test/src/main/resources/h2/apache_inlong_manager.sql
index 73a656acfa..fe5f8d2d3d 100644
---
a/inlong-manager/manager-test/src/main/resources/h2/apache_inlong_manager.sql
+++
b/inlong-manager/manager-test/src/main/resources/h2/apache_inlong_manager.sql
@@ -730,7 +730,6 @@ CREATE TABLE IF NOT EXISTS `sort_source_config`
-- ----------------------------
CREATE TABLE IF NOT EXISTS `component_heartbeat`
(
- `id` int(11) NOT NULL AUTO_INCREMENT COMMENT
'Incremental primary key',
`component` varchar(64) NOT NULL DEFAULT '' COMMENT 'Component
name, such as: Agent, Sort...',
`instance` varchar(64) NOT NULL DEFAULT '' COMMENT 'Component
instance, can be ip, name...',
`status_heartbeat` mediumtext DEFAULT NULL COMMENT 'Status
heartbeat info',
@@ -738,8 +737,7 @@ CREATE TABLE IF NOT EXISTS `component_heartbeat`
`report_time` bigint(20) NOT NULL COMMENT 'Report time',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT
'Create time',
`modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
- PRIMARY KEY (`id`),
- UNIQUE KEY `unique_component_heartbeat` (`component`, `instance`)
+ PRIMARY KEY (`component`, `instance`)
);
-- ----------------------------
@@ -747,7 +745,6 @@ CREATE TABLE IF NOT EXISTS `component_heartbeat`
-- ----------------------------
CREATE TABLE IF NOT EXISTS `group_heartbeat`
(
- `id` int(11) NOT NULL AUTO_INCREMENT COMMENT
'Incremental primary key',
`component` varchar(64) NOT NULL DEFAULT '' COMMENT 'Component
name, such as: Agent, Sort...',
`instance` varchar(64) NOT NULL DEFAULT '' COMMENT 'Component
instance, can be ip, name...',
`inlong_group_id` varchar(256) NOT NULL DEFAULT '' COMMENT 'Owning inlong
group id',
@@ -756,8 +753,7 @@ CREATE TABLE IF NOT EXISTS `group_heartbeat`
`report_time` bigint(20) NOT NULL COMMENT 'Report time',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT
'Create time',
`modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
- PRIMARY KEY (`id`),
- UNIQUE KEY `unique_group_heartbeat` (`component`, `instance`,
`inlong_group_id`)
+ PRIMARY KEY (`component`, `instance`, `inlong_group_id`)
);
-- ----------------------------
@@ -765,7 +761,6 @@ CREATE TABLE IF NOT EXISTS `group_heartbeat`
-- ----------------------------
CREATE TABLE IF NOT EXISTS `stream_heartbeat`
(
- `id` int(11) NOT NULL AUTO_INCREMENT COMMENT
'Incremental primary key',
`component` varchar(64) NOT NULL DEFAULT '' COMMENT 'Component
name, such as: Agent, Sort...',
`instance` varchar(64) NOT NULL DEFAULT '' COMMENT 'Component
instance, can be ip, name...',
`inlong_group_id` varchar(256) NOT NULL DEFAULT '' COMMENT 'Owning inlong
group id',
@@ -775,8 +770,7 @@ CREATE TABLE IF NOT EXISTS `stream_heartbeat`
`report_time` bigint(20) NOT NULL COMMENT 'Report time',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT
'Create time',
`modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
- PRIMARY KEY (`id`),
- UNIQUE KEY `unique_stream_heartbeat` (`component`, `instance`,
`inlong_group_id`, `inlong_stream_id`)
+ PRIMARY KEY (`component`, `instance`, `inlong_group_id`,
`inlong_stream_id`)
);
-- ----------------------------
diff --git a/inlong-manager/manager-web/sql/apache_inlong_manager.sql
b/inlong-manager/manager-web/sql/apache_inlong_manager.sql
index d2a6173b4c..3301ed56d7 100644
--- a/inlong-manager/manager-web/sql/apache_inlong_manager.sql
+++ b/inlong-manager/manager-web/sql/apache_inlong_manager.sql
@@ -773,7 +773,6 @@ CREATE TABLE IF NOT EXISTS `sort_source_config`
-- ----------------------------
CREATE TABLE IF NOT EXISTS `component_heartbeat`
(
- `id` int(11) NOT NULL AUTO_INCREMENT COMMENT
'Incremental primary key',
`component` varchar(64) NOT NULL DEFAULT '' COMMENT 'Component
name, such as: Agent, Sort...',
`instance` varchar(64) NOT NULL DEFAULT '' COMMENT 'Component
instance, can be ip, name...',
`status_heartbeat` mediumtext DEFAULT NULL COMMENT 'Status
heartbeat info',
@@ -781,8 +780,7 @@ CREATE TABLE IF NOT EXISTS `component_heartbeat`
`report_time` bigint(20) NOT NULL COMMENT 'Report time',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT
'Create time',
`modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
- PRIMARY KEY (`id`),
- UNIQUE KEY `unique_component_heartbeat` (`component`, `instance`)
+ PRIMARY KEY (`component`, `instance`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8 COMMENT ='Inlong component heartbeat';
@@ -791,7 +789,6 @@ CREATE TABLE IF NOT EXISTS `component_heartbeat`
-- ----------------------------
CREATE TABLE IF NOT EXISTS `group_heartbeat`
(
- `id` int(11) NOT NULL AUTO_INCREMENT COMMENT
'Incremental primary key',
`component` varchar(64) NOT NULL DEFAULT '' COMMENT 'Component
name, such as: Agent, Sort...',
`instance` varchar(64) NOT NULL DEFAULT '' COMMENT 'Component
instance, can be ip, name...',
`inlong_group_id` varchar(256) NOT NULL DEFAULT '' COMMENT 'Owning inlong
group id',
@@ -800,8 +797,7 @@ CREATE TABLE IF NOT EXISTS `group_heartbeat`
`report_time` bigint(20) NOT NULL COMMENT 'Report time',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT
'Create time',
`modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
- PRIMARY KEY (`id`),
- UNIQUE KEY `unique_group_heartbeat` (`component`, `instance`,
`inlong_group_id`)
+ PRIMARY KEY (`component`, `instance`, `inlong_group_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8 COMMENT ='Inlong group heartbeat';
@@ -810,7 +806,6 @@ CREATE TABLE IF NOT EXISTS `group_heartbeat`
-- ----------------------------
CREATE TABLE IF NOT EXISTS `stream_heartbeat`
(
- `id` int(11) NOT NULL AUTO_INCREMENT COMMENT
'Incremental primary key',
`component` varchar(64) NOT NULL DEFAULT '' COMMENT 'Component
name, such as: Agent, Sort...',
`instance` varchar(64) NOT NULL DEFAULT '' COMMENT 'Component
instance, can be ip, name...',
`inlong_group_id` varchar(256) NOT NULL DEFAULT '' COMMENT 'Owning inlong
group id',
@@ -820,8 +815,7 @@ CREATE TABLE IF NOT EXISTS `stream_heartbeat`
`report_time` bigint(20) NOT NULL COMMENT 'Report time',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT
'Create time',
`modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
UPDATE CURRENT_TIMESTAMP COMMENT 'Modify time',
- PRIMARY KEY (`id`),
- UNIQUE KEY `unique_stream_heartbeat` (`component`, `instance`,
`inlong_group_id`, `inlong_stream_id`)
+ PRIMARY KEY (`component`, `instance`, `inlong_group_id`,
`inlong_stream_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8 COMMENT ='Inlong stream heartbeat';
diff --git a/inlong-manager/manager-web/sql/changes-1.8.0.sql
b/inlong-manager/manager-web/sql/changes-1.8.0.sql
index 8af19b0e22..51397ad8a5 100644
--- a/inlong-manager/manager-web/sql/changes-1.8.0.sql
+++ b/inlong-manager/manager-web/sql/changes-1.8.0.sql
@@ -118,3 +118,15 @@ ALTER TABLE `workflow_process`
ADD `tenant` VARCHAR(256) DEFAULT 'public' NOT NULL comment 'Inlong tenant
of workflow process' after `inlong_stream_id`;
ALTER TABLE `workflow_task`
ADD `tenant` VARCHAR(256) DEFAULT 'public' NOT NULL comment 'Inlong tenant
of workflow task' after `display_name`;
+
+ALTER TABLE component_heartbeat DROP COLUMN id;
+ALTER TABLE `component_heartbeat` ADD PRIMARY KEY (`component`, `instance`);
+DROP INDEX unique_component_heartbeat on component_heartbeat;
+
+ALTER TABLE group_heartbeat DROP COLUMN id;
+ALTER TABLE `group_heartbeat` ADD PRIMARY KEY (`component`, `instance`,
`inlong_group_id`);
+DROP INDEX unique_group_heartbeat on group_heartbeat;
+
+ALTER TABLE stream_heartbeat DROP COLUMN id;
+ALTER TABLE `stream_heartbeat` ADD PRIMARY KEY (`component`, `instance`,
`inlong_group_id`, `inlong_stream_id`);
+DROP INDEX unique_stream_heartbeat on stream_heartbeat;