Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e97bfe57
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e97bfe57
编写于
8月 21, 2023
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enhance: compact time range - msg compatibility
上级
1366aa7a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
59 addition
and
9 deletion
+59
-9
src/client/src/tscServer.c
src/client/src/tscServer.c
+23
-5
src/inc/taosmsg.h
src/inc/taosmsg.h
+6
-2
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+30
-2
未找到文件。
src/client/src/tscServer.c
浏览文件 @
e97bfe57
...
@@ -2022,7 +2022,11 @@ int tscBuildCompactMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -2022,7 +2022,11 @@ int tscBuildCompactMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
}
int
count
=
removeDupVgid
(
result
,
size
);
int
count
=
removeDupVgid
(
result
,
size
);
pCmd
->
payloadLen
=
sizeof
(
SCompactMsg
)
+
count
*
sizeof
(
int32_t
);
int32_t
payloadLen
=
sizeof
(
SCompactMsg
)
+
count
*
sizeof
(
int32_t
)
+
// compact msg(include vgroup list)
sizeof
(
STLV
)
+
sizeof
(
int64_t
)
*
2
+
// skey, ekey
sizeof
(
STLV
);
//end mark
pCmd
->
payloadLen
=
payloadLen
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_COMPACT_VNODE
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_COMPACT_VNODE
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
...
@@ -2031,6 +2035,8 @@ int tscBuildCompactMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -2031,6 +2035,8 @@ int tscBuildCompactMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
SCompactMsg
*
pCompactMsg
=
(
SCompactMsg
*
)
pCmd
->
payload
;
SCompactMsg
*
pCompactMsg
=
(
SCompactMsg
*
)
pCmd
->
payload
;
pCompactMsg
->
extend
=
1
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
0
);
...
@@ -2042,16 +2048,28 @@ int tscBuildCompactMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -2042,16 +2048,28 @@ int tscBuildCompactMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
tNameGetFullDbName
(
&
pTableMetaInfo
->
name
,
pCompactMsg
->
db
);
tNameGetFullDbName
(
&
pTableMetaInfo
->
name
,
pCompactMsg
->
db
);
}
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
pCmd
);
pCompactMsg
->
skey
=
htobe64
(
pQueryInfo
->
range
.
skey
);
pCompactMsg
->
ekey
=
htobe64
(
pQueryInfo
->
range
.
ekey
);
pCompactMsg
->
numOfVgroup
=
htons
(
count
);
pCompactMsg
->
numOfVgroup
=
htons
(
count
);
for
(
int32_t
i
=
0
;
i
<
count
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
count
;
i
++
)
{
pCompactMsg
->
vgid
[
i
]
=
htons
(
result
[
i
]);
pCompactMsg
->
vgid
[
i
]
=
htons
(
result
[
i
]);
}
}
free
(
result
);
free
(
result
);
char
*
p
=
(
char
*
)
pCompactMsg
+
sizeof
(
SCompactMsg
)
+
count
*
sizeof
(
int32_t
);
STLV
*
tlv
=
(
STLV
*
)(
p
);
tlv
->
type
=
htons
(
TLV_TYPE_COMPACT_VNODES_TIME_RANGE
);
tlv
->
len
=
htonl
(
sizeof
(
int64_t
)
*
2
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
pCmd
);
*
(
int16_t
*
)
tlv
->
value
=
htobe64
(
pQueryInfo
->
range
.
skey
);
*
(
int16_t
*
)(
tlv
->
value
+
sizeof
(
int64_t
))
=
htobe64
(
pQueryInfo
->
range
.
ekey
);
p
+=
sizeof
(
*
tlv
)
+
sizeof
(
int64_t
)
*
2
;
tlv
=
(
STLV
*
)
p
;
tlv
->
type
=
htons
(
TLV_TYPE_END_MARK
);
tlv
->
len
=
0
;
p
+=
sizeof
(
*
tlv
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
src/inc/taosmsg.h
浏览文件 @
e97bfe57
...
@@ -893,10 +893,10 @@ typedef struct {
...
@@ -893,10 +893,10 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int8_t
extend
;
int8_t
extend
;
char
db
[
TSDB_ACCT_ID_LEN
+
TSDB_DB_NAME_LEN
];
char
db
[
TSDB_ACCT_ID_LEN
+
TSDB_DB_NAME_LEN
];
int64_t
skey
;
int64_t
ekey
;
int32_t
numOfVgroup
;
int32_t
numOfVgroup
;
int32_t
vgid
[];
int32_t
vgid
[];
// tlv int64_t skey, ekey;
// tlv end
}
SCompactMsg
;
}
SCompactMsg
;
typedef
struct
SShowRsp
{
typedef
struct
SShowRsp
{
...
@@ -1039,6 +1039,10 @@ enum {
...
@@ -1039,6 +1039,10 @@ enum {
TLV_TYPE_META_VERSION
=
1
,
TLV_TYPE_META_VERSION
=
1
,
};
};
enum
ETlvTypeCompact
{
TLV_TYPE_COMPACT_VNODES_TIME_RANGE
=
1
,
};
#pragma pack(pop)
#pragma pack(pop)
#ifdef __cplusplus
#ifdef __cplusplus
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
e97bfe57
...
@@ -1296,18 +1296,46 @@ static int32_t mnodeSyncDb(SDbObj *pDb, SMnodeMsg *pMsg) {
...
@@ -1296,18 +1296,46 @@ static int32_t mnodeSyncDb(SDbObj *pDb, SMnodeMsg *pMsg) {
static
int32_t
mnodeCompact
(
SDbObj
*
pDb
,
SCompactMsg
*
pCompactMsg
)
{
static
int32_t
mnodeCompact
(
SDbObj
*
pDb
,
SCompactMsg
*
pCompactMsg
)
{
int64_t
skey
=
htobe64
(
pCompactMsg
->
skey
)
;
int64_t
skey
=
INT64_MIN
;
int64_t
ekey
=
htobe64
(
pCompactMsg
->
ekey
)
;
int64_t
ekey
=
INT64_MAX
;
int32_t
count
=
ntohs
(
pCompactMsg
->
numOfVgroup
);
int32_t
count
=
ntohs
(
pCompactMsg
->
numOfVgroup
);
int32_t
*
buf
=
malloc
(
sizeof
(
int32_t
)
*
count
);
int32_t
*
buf
=
malloc
(
sizeof
(
int32_t
)
*
count
);
if
(
buf
==
NULL
)
{
if
(
buf
==
NULL
)
{
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
}
for
(
int32_t
i
=
0
;
i
<
count
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
count
;
i
++
)
{
buf
[
i
]
=
ntohs
(
pCompactMsg
->
vgid
[
i
]);
buf
[
i
]
=
ntohs
(
pCompactMsg
->
vgid
[
i
]);
}
}
if
(
pCompactMsg
->
extend
)
{
char
*
p
=
(
char
*
)
pCompactMsg
+
sizeof
(
SCompactMsg
)
+
count
*
sizeof
(
int32_t
);
STLV
*
tlv
=
NULL
;
while
(
1
)
{
tlv
=
(
STLV
*
)
p
;
tlv
->
type
=
ntohs
(
tlv
->
type
);
tlv
->
len
=
ntohl
(
tlv
->
len
);
if
(
tlv
->
type
==
TLV_TYPE_END_MARK
)
{
break
;
}
switch
(
tlv
->
type
)
{
case
TLV_TYPE_COMPACT_VNODES_TIME_RANGE
:
{
assert
(
tlv
->
len
==
2
*
sizeof
(
int64_t
));
skey
=
htobe64
(
*
(
int64_t
*
)
tlv
->
value
);
ekey
=
htobe64
(
*
(
int64_t
*
)(
tlv
->
value
+
sizeof
(
int64_t
)));
p
+=
sizeof
(
*
tlv
)
+
tlv
->
len
;
break
;
}
default:
{
p
+=
sizeof
(
*
tlv
)
+
tlv
->
len
;
break
;
}
}
}
}
// copy from mnodeSyncDb, so ugly
// copy from mnodeSyncDb, so ugly
for
(
int32_t
i
=
0
;
i
<
count
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
count
;
i
++
)
{
SVgObj
*
pVgroup
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录