Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8bc0d4ba
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8bc0d4ba
编写于
1月 30, 2023
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: add alter vnode hashrange request
上级
03dc6e55
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
119 addition
and
27 deletion
+119
-27
include/common/tmsg.h
include/common/tmsg.h
+11
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+34
-0
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
+2
-1
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+15
-2
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+4
-1
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+53
-9
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+0
-14
未找到文件。
include/common/tmsg.h
浏览文件 @
8bc0d4ba
...
...
@@ -1287,6 +1287,17 @@ typedef struct {
int32_t
tSerializeSDisableVnodeWriteReq
(
void
*
buf
,
int32_t
bufLen
,
SDisableVnodeWriteReq
*
pReq
);
int32_t
tDeserializeSDisableVnodeWriteReq
(
void
*
buf
,
int32_t
bufLen
,
SDisableVnodeWriteReq
*
pReq
);
typedef
struct
{
int32_t
srcVgId
;
int32_t
dstVgId
;
uint32_t
hashBegin
;
uint32_t
hashEnd
;
int64_t
reserved
;
}
SAlterVnodeHashRangeReq
;
int32_t
tSerializeSAlterVnodeHashRangeReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeHashRangeReq
*
pReq
);
int32_t
tDeserializeSAlterVnodeHashRangeReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeHashRangeReq
*
pReq
);
typedef
struct
{
SMsgHead
header
;
char
dbFName
[
TSDB_DB_FNAME_LEN
];
...
...
source/common/src/tmsg.c
浏览文件 @
8bc0d4ba
...
...
@@ -4146,6 +4146,40 @@ int32_t tDeserializeSDisableVnodeWriteReq(void *buf, int32_t bufLen, SDisableVno
return
0
;
}
int32_t
tSerializeSAlterVnodeHashRangeReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeHashRangeReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
srcVgId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
dstVgId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
hashBegin
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
hashEnd
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
reserved
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tEncoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSAlterVnodeHashRangeReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeHashRangeReq
*
pReq
)
{
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
srcVgId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
dstVgId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
hashBegin
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
hashEnd
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
reserved
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSKillQueryReq
(
void
*
buf
,
int32_t
bufLen
,
SKillQueryReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
...
...
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
浏览文件 @
8bc0d4ba
...
...
@@ -87,8 +87,9 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);
SArray
*
vmGetMsgHandles
();
int32_t
vmProcessCreateVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmProcessDropVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmProcessAlterVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmProcessAlterVnodeRe
plicaRe
q
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmProcessDisableVnodeWriteReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmProcessAlterHashRangeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
// vmFile.c
int32_t
vmGetVnodeListFromFile
(
SVnodeMgmt
*
pMgmt
,
SWrapperCfg
**
ppCfgs
,
int32_t
*
numOfVnodes
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
8bc0d4ba
...
...
@@ -302,7 +302,20 @@ int32_t vmProcessDisableVnodeWriteReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
0
;
}
int32_t
vmProcessAlterVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
vmProcessAlterHashRangeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
SAlterVnodeHashRangeReq
req
=
{
0
};
if
(
tDeserializeSAlterVnodeHashRangeReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
req
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
dInfo
(
"vgId:%d, alter hashrange msg will be processed, dstVgId:%d, begin:%u, end:%u"
,
req
.
srcVgId
,
req
.
dstVgId
,
req
.
hashBegin
,
req
.
hashEnd
);
return
0
;
}
int32_t
vmProcessAlterVnodeReplicaReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
SAlterVnodeReplicaReq
alterReq
=
{
0
};
if
(
tDeserializeSAlterVnodeReplicaReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
alterReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
...
...
@@ -473,7 +486,7 @@ SArray *vmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIG
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIRM
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DISABLE_WRITE
,
vmPutMsgToMgmtQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_HASHRANGE
,
vmPutMsgTo
Write
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_HASHRANGE
,
vmPutMsgTo
Mgmt
Queue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_COMPACT
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TRIM
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_VNODE
,
vmPutMsgToMgmtQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
8bc0d4ba
...
...
@@ -41,11 +41,14 @@ static void vmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
code
=
vmProcessDropVnodeReq
(
pMgmt
,
pMsg
);
break
;
case
TDMT_VND_ALTER_REPLICA
:
code
=
vmProcessAlterVnodeReq
(
pMgmt
,
pMsg
);
code
=
vmProcessAlterVnodeRe
plicaRe
q
(
pMgmt
,
pMsg
);
break
;
case
TDMT_VND_DISABLE_WRITE
:
code
=
vmProcessDisableVnodeWriteReq
(
pMgmt
,
pMsg
);
break
;
case
TDMT_VND_ALTER_HASHRANGE
:
code
=
vmProcessAlterHashRangeReq
(
pMgmt
,
pMsg
);
break
;
default:
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
dGError
(
"msg:%p, not processed in vnode-mgmt queue"
,
pMsg
);
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
8bc0d4ba
...
...
@@ -420,6 +420,33 @@ static void *mndBuildDisableVnodeWriteReq(SMnode *pMnode, SDbObj *pDb, int32_t v
return
pReq
;
}
static
void
*
mndBuildAlterVnodeHashRangeReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
int32_t
dstVgId
,
int32_t
*
pContLen
)
{
SAlterVnodeHashRangeReq
alterReq
=
{
.
srcVgId
=
pVgroup
->
vgId
,
.
dstVgId
=
dstVgId
,
.
hashBegin
=
pVgroup
->
hashBegin
,
.
hashEnd
=
pVgroup
->
hashEnd
,
};
mInfo
(
"vgId:%d, build alter vnode hashrange req, dstVgId:%d, begin:%u, end:%u"
,
pVgroup
->
vgId
,
dstVgId
,
pVgroup
->
hashBegin
,
pVgroup
->
hashEnd
);
int32_t
contLen
=
tSerializeSAlterVnodeHashRangeReq
(
NULL
,
0
,
&
alterReq
);
if
(
contLen
<
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
void
*
pReq
=
taosMemoryMalloc
(
contLen
);
if
(
pReq
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
tSerializeSAlterVnodeHashRangeReq
(
pReq
,
contLen
,
&
alterReq
);
*
pContLen
=
contLen
;
return
pReq
;
}
void
*
mndBuildDropVnodeReq
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
int32_t
*
pContLen
)
{
SDropVnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
pDnode
->
id
;
...
...
@@ -1077,7 +1104,25 @@ int32_t mndAddAlterVnodeConfirmAction(SMnode *pMnode, STrans *pTrans, SDbObj *pD
return
0
;
}
int32_t
mndAddAlterVnodeHashRangeAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
)
{
return
0
;
}
static
int32_t
mndAddAlterVnodeHashRangeAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SVgObj
*
pVgroup
,
int32_t
dstVgId
)
{
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildAlterVnodeHashRangeReq
(
pMnode
,
pVgroup
,
dstVgId
,
&
contLen
);
if
(
pReq
==
NULL
)
return
-
1
;
action
.
pCont
=
pReq
;
action
.
contLen
=
contLen
;
action
.
msgType
=
TDMT_VND_ALTER_HASHRANGE
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
return
-
1
;
}
return
0
;
}
int32_t
mndAddAlterVnodeConfigAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
)
{
STransAction
action
=
{
0
};
...
...
@@ -1854,12 +1899,6 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
mInfo
(
"vgId:%d, vnode:%d dnode:%d"
,
newVg1
.
vgId
,
i
,
newVg1
.
vnodeGid
[
i
].
dnodeId
);
}
pRaw
=
mndVgroupActionEncode
(
pVgroup
);
if
(
pRaw
==
NULL
)
goto
_OVER
;
if
(
mndTransAppendCommitlog
(
pTrans
,
pRaw
)
!=
0
)
goto
_OVER
;
(
void
)
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_DROPPING
);
pRaw
=
NULL
;
SVgObj
newVg2
=
{
0
};
memcpy
(
&
newVg2
,
&
newVg1
,
sizeof
(
SVgObj
));
newVg1
.
replica
=
1
;
...
...
@@ -1882,8 +1921,13 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
mInfo
(
"vgId:%d, vnode:%d dnode:%d"
,
newVg2
.
vgId
,
i
,
newVg2
.
vnodeGid
[
i
].
dnodeId
);
}
if
(
mndAddAlterVnodeHashRangeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
)
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeHashRangeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg2
)
!=
0
)
goto
_OVER
;
int32_t
maxVgId
=
sdbGetMaxId
(
pMnode
->
pSdb
,
SDB_VGROUP
);
if
(
mndAddAlterVnodeHashRangeAction
(
pMnode
,
pTrans
,
&
newVg1
,
maxVgId
)
!=
0
)
goto
_OVER
;
newVg1
.
vgId
=
maxVgId
;
maxVgId
++
;
if
(
mndAddAlterVnodeHashRangeAction
(
pMnode
,
pTrans
,
&
newVg2
,
maxVgId
)
!=
0
)
goto
_OVER
;
newVg2
.
vgId
=
maxVgId
;
// adjust vgroup replica
if
(
pDb
->
cfg
.
replications
!=
newVg1
.
replica
)
{
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
8bc0d4ba
...
...
@@ -24,7 +24,6 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq
static
int32_t
vnodeProcessSubmitReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
static
int32_t
vnodeProcessCreateTSmaReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
static
int32_t
vnodeProcessAlterConfirmReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
static
int32_t
vnodeProcessAlterHashRangeReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
static
int32_t
vnodeProcessAlterConfigReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
static
int32_t
vnodeProcessDropTtlTbReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
static
int32_t
vnodeProcessTrimReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
);
...
...
@@ -313,9 +312,6 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
case
TDMT_VND_ALTER_CONFIRM
:
vnodeProcessAlterConfirmReq
(
pVnode
,
version
,
pReq
,
len
,
pRsp
);
break
;
case
TDMT_VND_ALTER_HASHRANGE
:
vnodeProcessAlterHashRangeReq
(
pVnode
,
version
,
pReq
,
len
,
pRsp
);
break
;
case
TDMT_VND_ALTER_CONFIG
:
vnodeProcessAlterConfigReq
(
pVnode
,
version
,
pReq
,
len
,
pRsp
);
break
;
...
...
@@ -1246,16 +1242,6 @@ static int32_t vnodeProcessAlterConfirmReq(SVnode *pVnode, int64_t version, void
return
0
;
}
static
int32_t
vnodeProcessAlterHashRangeReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
)
{
vInfo
(
"vgId:%d, alter hashrange msg will be processed"
,
TD_VID
(
pVnode
));
// todo
// 1. stop work
// 2. adjust hash range / compact / remove wals / rename vgroups
// 3. reload sync
return
0
;
}
static
int32_t
vnodeProcessAlterConfigReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
)
{
bool
walChanged
=
false
;
bool
tsdbChanged
=
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录