Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
03dc6e55
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
03dc6e55
编写于
1月 30, 2023
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: add disable vnode write request
上级
f36713a5
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
144 addition
and
26 deletion
+144
-26
include/common/tmsg.h
include/common/tmsg.h
+8
-0
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+28
-0
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+1
-0
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
+2
-0
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+27
-5
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+14
-4
source/dnode/mgmt/node_mgmt/src/dmTransport.c
source/dnode/mgmt/node_mgmt/src/dmTransport.c
+1
-1
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+62
-16
未找到文件。
include/common/tmsg.h
浏览文件 @
03dc6e55
...
@@ -1279,6 +1279,14 @@ typedef struct {
...
@@ -1279,6 +1279,14 @@ typedef struct {
int32_t
tSerializeSAlterVnodeReplicaReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeReplicaReq
*
pReq
);
int32_t
tSerializeSAlterVnodeReplicaReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeReplicaReq
*
pReq
);
int32_t
tDeserializeSAlterVnodeReplicaReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeReplicaReq
*
pReq
);
int32_t
tDeserializeSAlterVnodeReplicaReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterVnodeReplicaReq
*
pReq
);
typedef
struct
{
int32_t
vgId
;
int8_t
disable
;
}
SDisableVnodeWriteReq
;
int32_t
tSerializeSDisableVnodeWriteReq
(
void
*
buf
,
int32_t
bufLen
,
SDisableVnodeWriteReq
*
pReq
);
int32_t
tDeserializeSDisableVnodeWriteReq
(
void
*
buf
,
int32_t
bufLen
,
SDisableVnodeWriteReq
*
pReq
);
typedef
struct
{
typedef
struct
{
SMsgHead
header
;
SMsgHead
header
;
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
...
...
include/common/tmsgdef.h
浏览文件 @
03dc6e55
...
@@ -220,6 +220,7 @@ enum {
...
@@ -220,6 +220,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_VND_DROP_TTL_TABLE
,
"vnode-drop-ttl-stb"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_DROP_TTL_TABLE
,
"vnode-drop-ttl-stb"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_TRIM
,
"vnode-trim"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_TRIM
,
"vnode-trim"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_COMMIT
,
"vnode-commit"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_COMMIT
,
"vnode-commit"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_DISABLE_WRITE
,
"vnode-disable-write"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_MAX_MSG
,
"vnd-max"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_MAX_MSG
,
"vnd-max"
,
NULL
,
NULL
)
TD_NEW_MSG_SEG
(
TDMT_SCH_MSG
)
TD_NEW_MSG_SEG
(
TDMT_SCH_MSG
)
...
...
source/common/src/tmsg.c
浏览文件 @
03dc6e55
...
@@ -4118,6 +4118,34 @@ int32_t tDeserializeSAlterVnodeReplicaReq(void *buf, int32_t bufLen, SAlterVnode
...
@@ -4118,6 +4118,34 @@ int32_t tDeserializeSAlterVnodeReplicaReq(void *buf, int32_t bufLen, SAlterVnode
return
0
;
return
0
;
}
}
int32_t
tSerializeSDisableVnodeWriteReq
(
void
*
buf
,
int32_t
bufLen
,
SDisableVnodeWriteReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
vgId
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
disable
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tEncoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSDisableVnodeWriteReq
(
void
*
buf
,
int32_t
bufLen
,
SDisableVnodeWriteReq
*
pReq
)
{
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
vgId
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
disable
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSKillQueryReq
(
void
*
buf
,
int32_t
bufLen
,
SKillQueryReq
*
pReq
)
{
int32_t
tSerializeSKillQueryReq
(
void
*
buf
,
int32_t
bufLen
,
SKillQueryReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
03dc6e55
...
@@ -181,6 +181,7 @@ SArray *mmGetMsgHandles() {
...
@@ -181,6 +181,7 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIRM_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIRM_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_HASHRANGE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_HASHRANGE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_COMPACT_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_COMPACT_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DISABLE_WRITE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
浏览文件 @
03dc6e55
...
@@ -54,6 +54,7 @@ typedef struct {
...
@@ -54,6 +54,7 @@ typedef struct {
int32_t
vgVersion
;
int32_t
vgVersion
;
int32_t
refCount
;
int32_t
refCount
;
int8_t
dropped
;
int8_t
dropped
;
int8_t
disable
;
char
*
path
;
char
*
path
;
SVnode
*
pImpl
;
SVnode
*
pImpl
;
SMultiWorker
pWriteW
;
SMultiWorker
pWriteW
;
...
@@ -87,6 +88,7 @@ SArray *vmGetMsgHandles();
...
@@ -87,6 +88,7 @@ SArray *vmGetMsgHandles();
int32_t
vmProcessCreateVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmProcessCreateVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmProcessDropVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmProcessDropVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmProcessAlterVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmProcessAlterVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmProcessDisableVnodeWriteReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
// vmFile.c
// vmFile.c
int32_t
vmGetVnodeListFromFile
(
SVnodeMgmt
*
pMgmt
,
SWrapperCfg
**
ppCfgs
,
int32_t
*
numOfVnodes
);
int32_t
vmGetVnodeListFromFile
(
SVnodeMgmt
*
pMgmt
,
SWrapperCfg
**
ppCfgs
,
int32_t
*
numOfVnodes
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
03dc6e55
...
@@ -281,6 +281,27 @@ _OVER:
...
@@ -281,6 +281,27 @@ _OVER:
return
code
;
return
code
;
}
}
int32_t
vmProcessDisableVnodeWriteReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
SDisableVnodeWriteReq
req
=
{
0
};
if
(
tDeserializeSDisableVnodeWriteReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
req
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
dInfo
(
"vgId:%d, vnode write disable:%d"
,
req
.
vgId
,
req
.
disable
);
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
req
.
vgId
);
if
(
pVnode
==
NULL
)
{
dError
(
"vgId:%d, failed to disable write since %s"
,
req
.
vgId
,
terrstr
());
terrno
=
TSDB_CODE_VND_NOT_EXIST
;
return
-
1
;
}
pVnode
->
disable
=
req
.
disable
;
vmReleaseVnode
(
pMgmt
,
pVnode
);
return
0
;
}
int32_t
vmProcessAlterVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
vmProcessAlterVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
SAlterVnodeReplicaReq
alterReq
=
{
0
};
SAlterVnodeReplicaReq
alterReq
=
{
0
};
if
(
tDeserializeSAlterVnodeReplicaReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
alterReq
)
!=
0
)
{
if
(
tDeserializeSAlterVnodeReplicaReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
alterReq
)
!=
0
)
{
...
@@ -289,16 +310,16 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -289,16 +310,16 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
}
}
int32_t
vgId
=
alterReq
.
vgId
;
int32_t
vgId
=
alterReq
.
vgId
;
dInfo
(
"vgId:%d, start to alter vnode, replica:%d selfIndex:%d strict:%d"
,
alterReq
.
vgId
,
alterReq
.
replica
,
dInfo
(
"vgId:%d, start to alter vnode, replica:%d selfIndex:%d strict:%d"
,
vgId
,
alterReq
.
replica
,
alterReq
.
selfIndex
,
alterReq
.
s
elfIndex
,
alterReq
.
s
trict
);
alterReq
.
strict
);
for
(
int32_t
i
=
0
;
i
<
alterReq
.
replica
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
alterReq
.
replica
;
++
i
)
{
SReplica
*
pReplica
=
&
alterReq
.
replicas
[
i
];
SReplica
*
pReplica
=
&
alterReq
.
replicas
[
i
];
dInfo
(
"vgId:%d, replica:%d ep:%s:%u dnode:%d"
,
alterReq
.
vgId
,
i
,
pReplica
->
fqdn
,
pReplica
->
port
,
pReplica
->
port
);
dInfo
(
"vgId:%d, replica:%d ep:%s:%u dnode:%d"
,
vgId
,
i
,
pReplica
->
fqdn
,
pReplica
->
port
,
pReplica
->
port
);
}
}
if
(
alterReq
.
replica
<=
0
||
alterReq
.
selfIndex
<
0
||
alterReq
.
selfIndex
>=
alterReq
.
replica
)
{
if
(
alterReq
.
replica
<=
0
||
alterReq
.
selfIndex
<
0
||
alterReq
.
selfIndex
>=
alterReq
.
replica
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
terrno
=
TSDB_CODE_INVALID_MSG
;
dError
(
"vgId:%d, failed to alter replica since invalid msg"
,
alterReq
.
vgId
);
dError
(
"vgId:%d, failed to alter replica since invalid msg"
,
vgId
);
return
-
1
;
return
-
1
;
}
}
...
@@ -306,7 +327,7 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -306,7 +327,7 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
if
(
pReplica
->
id
!=
pMgmt
->
pData
->
dnodeId
||
pReplica
->
port
!=
tsServerPort
||
if
(
pReplica
->
id
!=
pMgmt
->
pData
->
dnodeId
||
pReplica
->
port
!=
tsServerPort
||
strcmp
(
pReplica
->
fqdn
,
tsLocalFqdn
)
!=
0
)
{
strcmp
(
pReplica
->
fqdn
,
tsLocalFqdn
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
terrno
=
TSDB_CODE_INVALID_MSG
;
dError
(
"vgId:%d, dnodeId:%d ep:%s:%u not matched with local dnode"
,
alterReq
.
vgId
,
pReplica
->
id
,
pReplica
->
fqdn
,
dError
(
"vgId:%d, dnodeId:%d ep:%s:%u not matched with local dnode"
,
vgId
,
pReplica
->
id
,
pReplica
->
fqdn
,
pReplica
->
port
);
pReplica
->
port
);
return
-
1
;
return
-
1
;
}
}
...
@@ -451,6 +472,7 @@ SArray *vmGetMsgHandles() {
...
@@ -451,6 +472,7 @@ SArray *vmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_REPLICA
,
vmPutMsgToMgmtQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_REPLICA
,
vmPutMsgToMgmtQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_CONFIG
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
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_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
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_HASHRANGE
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_COMPACT
,
vmPutMsgToWriteQueue
,
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_VND_TRIM
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
03dc6e55
...
@@ -43,6 +43,9 @@ static void vmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
...
@@ -43,6 +43,9 @@ static void vmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
case
TDMT_VND_ALTER_REPLICA
:
case
TDMT_VND_ALTER_REPLICA
:
code
=
vmProcessAlterVnodeReq
(
pMgmt
,
pMsg
);
code
=
vmProcessAlterVnodeReq
(
pMgmt
,
pMsg
);
break
;
break
;
case
TDMT_VND_DISABLE_WRITE
:
code
=
vmProcessDisableVnodeWriteReq
(
pMgmt
,
pMsg
);
break
;
default:
default:
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
dGError
(
"msg:%p, not processed in vnode-mgmt queue"
,
pMsg
);
dGError
(
"msg:%p, not processed in vnode-mgmt queue"
,
pMsg
);
...
@@ -191,14 +194,21 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
...
@@ -191,14 +194,21 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
terrno
=
TSDB_CODE_NO_DISKSPACE
;
terrno
=
TSDB_CODE_NO_DISKSPACE
;
code
=
terrno
;
code
=
terrno
;
dError
(
"vgId:%d, msg:%p put into vnode-write queue failed since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
(
code
));
dError
(
"vgId:%d, msg:%p put into vnode-write queue failed since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
(
code
));
}
else
if
((
pMsg
->
msgType
==
TDMT_VND_SUBMIT
)
&&
(
grantCheck
(
TSDB_GRANT_STORAGE
)
!=
TSDB_CODE_SUCCESS
))
{
break
;
}
if
(
pMsg
->
msgType
==
TDMT_VND_SUBMIT
&&
(
grantCheck
(
TSDB_GRANT_STORAGE
)
!=
TSDB_CODE_SUCCESS
))
{
terrno
=
TSDB_CODE_VND_NO_WRITE_AUTH
;
terrno
=
TSDB_CODE_VND_NO_WRITE_AUTH
;
code
=
terrno
;
code
=
terrno
;
dDebug
(
"vgId:%d, msg:%p put into vnode-write queue failed since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
(
code
));
dDebug
(
"vgId:%d, msg:%p put into vnode-write queue failed since %s"
,
pVnode
->
vgId
,
pMsg
,
terrstr
(
code
));
}
else
{
break
;
dGTrace
(
"vgId:%d, msg:%p put into vnode-write queue"
,
pVnode
->
vgId
,
pMsg
);
}
taosWriteQitem
(
pVnode
->
pWriteW
.
queue
,
pMsg
);
if
(
pMsg
->
msgType
!=
TDMT_VND_ALTER_CONFIRM
&&
pVnode
->
disable
)
{
dDebug
(
"vgId:%d, msg:%p put into vnode-write queue failed since its disable"
,
pVnode
->
vgId
,
pMsg
);
terrno
=
TSDB_CODE_VND_STOPPED
;
break
;
}
}
dGTrace
(
"vgId:%d, msg:%p put into vnode-write queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pWriteW
.
queue
,
pMsg
);
break
;
break
;
case
SYNC_QUEUE
:
case
SYNC_QUEUE
:
dGTrace
(
"vgId:%d, msg:%p put into vnode-sync queue"
,
pVnode
->
vgId
,
pMsg
);
dGTrace
(
"vgId:%d, msg:%p put into vnode-sync queue"
,
pVnode
->
vgId
,
pMsg
);
...
...
source/dnode/mgmt/node_mgmt/src/dmTransport.c
浏览文件 @
03dc6e55
...
@@ -39,7 +39,7 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
...
@@ -39,7 +39,7 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) {
NodeMsgFp
msgFp
=
pWrapper
->
msgFps
[
TMSG_INDEX
(
pMsg
->
msgType
)];
NodeMsgFp
msgFp
=
pWrapper
->
msgFps
[
TMSG_INDEX
(
pMsg
->
msgType
)];
if
(
msgFp
==
NULL
)
{
if
(
msgFp
==
NULL
)
{
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
dGError
(
"msg:%p, not processed since no handler
"
,
pMsg
);
dGError
(
"msg:%p, not processed since no handler
, type:%s"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
)
);
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
03dc6e55
...
@@ -59,6 +59,7 @@ int32_t mndInitVgroup(SMnode *pMnode) {
...
@@ -59,6 +59,7 @@ int32_t mndInitVgroup(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_VND_ALTER_HASHRANGE_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_ALTER_HASHRANGE_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_DND_DROP_VNODE_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_DND_DROP_VNODE_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_COMPACT_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_COMPACT_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_DISABLE_WRITE_RSP
,
mndTransProcessRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_REDISTRIBUTE_VGROUP
,
mndProcessRedistributeVgroupMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_REDISTRIBUTE_VGROUP
,
mndProcessRedistributeVgroupMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_SPLIT_VGROUP
,
mndProcessSplitVgroupMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_SPLIT_VGROUP
,
mndProcessSplitVgroupMsg
);
...
@@ -355,9 +356,7 @@ static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p
...
@@ -355,9 +356,7 @@ static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p
SReplica
*
pReplica
=
&
alterReq
.
replicas
[
v
];
SReplica
*
pReplica
=
&
alterReq
.
replicas
[
v
];
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
v
];
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
v
];
SDnodeObj
*
pVgidDnode
=
mndAcquireDnode
(
pMnode
,
pVgid
->
dnodeId
);
SDnodeObj
*
pVgidDnode
=
mndAcquireDnode
(
pMnode
,
pVgid
->
dnodeId
);
if
(
pVgidDnode
==
NULL
)
{
if
(
pVgidDnode
==
NULL
)
return
NULL
;
return
NULL
;
}
pReplica
->
id
=
pVgidDnode
->
id
;
pReplica
->
id
=
pVgidDnode
->
id
;
pReplica
->
port
=
pVgidDnode
->
port
;
pReplica
->
port
=
pVgidDnode
->
port
;
...
@@ -397,6 +396,30 @@ static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p
...
@@ -397,6 +396,30 @@ static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p
return
pReq
;
return
pReq
;
}
}
static
void
*
mndBuildDisableVnodeWriteReq
(
SMnode
*
pMnode
,
SDbObj
*
pDb
,
int32_t
vgId
,
int32_t
*
pContLen
)
{
SDisableVnodeWriteReq
disableReq
=
{
.
vgId
=
vgId
,
.
disable
=
1
,
};
mInfo
(
"vgId:%d, build disable vnode write req"
,
vgId
);
int32_t
contLen
=
tSerializeSDisableVnodeWriteReq
(
NULL
,
0
,
&
disableReq
);
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
;
}
tSerializeSDisableVnodeWriteReq
(
pReq
,
contLen
,
&
disableReq
);
*
pContLen
=
contLen
;
return
pReq
;
}
void
*
mndBuildDropVnodeReq
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
int32_t
*
pContLen
)
{
void
*
mndBuildDropVnodeReq
(
SMnode
*
pMnode
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
int32_t
*
pContLen
)
{
SDropVnodeReq
dropReq
=
{
0
};
SDropVnodeReq
dropReq
=
{
0
};
dropReq
.
dnodeId
=
pDnode
->
id
;
dropReq
.
dnodeId
=
pDnode
->
id
;
...
@@ -1029,6 +1052,7 @@ int32_t mndAddAlterVnodeConfirmAction(SMnode *pMnode, STrans *pTrans, SDbObj *pD
...
@@ -1029,6 +1052,7 @@ int32_t mndAddAlterVnodeConfirmAction(SMnode *pMnode, STrans *pTrans, SDbObj *pD
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
mInfo
(
"vgId:%d, build alter vnode confirm req"
,
pVgroup
->
vgId
);
int32_t
contLen
=
sizeof
(
SMsgHead
);
int32_t
contLen
=
sizeof
(
SMsgHead
);
SMsgHead
*
pHead
=
taosMemoryMalloc
(
contLen
);
SMsgHead
*
pHead
=
taosMemoryMalloc
(
contLen
);
if
(
pHead
==
NULL
)
{
if
(
pHead
==
NULL
)
{
...
@@ -1099,6 +1123,30 @@ int32_t mndAddAlterVnodeReplicaAction(SMnode *pMnode, STrans *pTrans, SDbObj *pD
...
@@ -1099,6 +1123,30 @@ int32_t mndAddAlterVnodeReplicaAction(SMnode *pMnode, STrans *pTrans, SDbObj *pD
return
0
;
return
0
;
}
}
static
int32_t
mndAddDisableVnodeWriteAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
int32_t
dnodeId
)
{
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
dnodeId
);
if
(
pDnode
==
NULL
)
return
-
1
;
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildDisableVnodeWriteReq
(
pMnode
,
pDb
,
pVgroup
->
vgId
,
&
contLen
);
if
(
pReq
==
NULL
)
return
-
1
;
action
.
pCont
=
pReq
;
action
.
contLen
=
contLen
;
action
.
msgType
=
TDMT_VND_DISABLE_WRITE
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
taosMemoryFree
(
pReq
);
return
-
1
;
}
return
0
;
}
int32_t
mndAddDropVnodeAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
SVnodeGid
*
pVgid
,
int32_t
mndAddDropVnodeAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
SVnodeGid
*
pVgid
,
bool
isRedo
)
{
bool
isRedo
)
{
STransAction
action
=
{
0
};
STransAction
action
=
{
0
};
...
@@ -1785,18 +1833,21 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
...
@@ -1785,18 +1833,21 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
if
(
mndAddVnodeToVgroup
(
pMnode
,
pTrans
,
&
newVg1
,
pArray
)
!=
0
)
goto
_OVER
;
if
(
mndAddVnodeToVgroup
(
pMnode
,
pTrans
,
&
newVg1
,
pArray
)
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeReplicaAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
,
newVg1
.
vnodeGid
[
0
].
dnodeId
)
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeReplicaAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
,
newVg1
.
vnodeGid
[
0
].
dnodeId
)
!=
0
)
goto
_OVER
;
if
(
mndAddCreateVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
,
&
newVg1
.
vnodeGid
[
1
])
!=
0
)
goto
_OVER
;
if
(
mndAddCreateVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
,
&
newVg1
.
vnodeGid
[
1
])
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
)
!=
0
)
goto
_OVER
;
}
else
if
(
newVg1
.
replica
==
3
)
{
}
else
if
(
newVg1
.
replica
==
3
)
{
SVnodeGid
del1
=
{
0
};
SVnodeGid
del1
=
{
0
};
if
(
mndRemoveVnodeFromVgroup
(
pMnode
,
pTrans
,
&
newVg1
,
pArray
,
&
del1
)
!=
0
)
goto
_OVER
;
if
(
mndRemoveVnodeFromVgroup
(
pMnode
,
pTrans
,
&
newVg1
,
pArray
,
&
del1
)
!=
0
)
goto
_OVER
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
,
&
del1
,
true
)
!=
0
)
goto
_OVER
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
,
&
del1
,
true
)
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeReplicaAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
,
newVg1
.
vnodeGid
[
0
].
dnodeId
)
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeReplicaAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
,
newVg1
.
vnodeGid
[
0
].
dnodeId
)
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeReplicaAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
,
newVg1
.
vnodeGid
[
1
].
dnodeId
)
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeReplicaAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
,
newVg1
.
vnodeGid
[
1
].
dnodeId
)
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
)
!=
0
)
goto
_OVER
;
}
else
{
}
else
{
goto
_OVER
;
goto
_OVER
;
}
}
for
(
int32_t
i
=
0
;
i
<
newVg1
.
replica
;
++
i
)
{
if
(
mndAddDisableVnodeWriteAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
,
newVg1
.
vnodeGid
[
i
].
dnodeId
)
!=
0
)
goto
_OVER
;
}
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
)
!=
0
)
goto
_OVER
;
mInfo
(
"vgId:%d, vgroup info after adjust replica, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d"
,
newVg1
.
vgId
,
mInfo
(
"vgId:%d, vgroup info after adjust replica, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d"
,
newVg1
.
vgId
,
newVg1
.
replica
,
newVg1
.
hashBegin
,
newVg1
.
hashEnd
,
newVg1
.
vnodeGid
[
0
].
dnodeId
);
newVg1
.
replica
,
newVg1
.
hashBegin
,
newVg1
.
hashEnd
,
newVg1
.
vnodeGid
[
0
].
dnodeId
);
for
(
int32_t
i
=
0
;
i
<
newVg1
.
replica
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
newVg1
.
replica
;
++
i
)
{
...
@@ -1822,8 +1873,14 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
...
@@ -1822,8 +1873,14 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
mInfo
(
"vgId:%d, vgroup info after adjust hash, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d"
,
newVg1
.
vgId
,
mInfo
(
"vgId:%d, vgroup info after adjust hash, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d"
,
newVg1
.
vgId
,
newVg1
.
replica
,
newVg1
.
hashBegin
,
newVg1
.
hashEnd
,
newVg1
.
vnodeGid
[
0
].
dnodeId
);
newVg1
.
replica
,
newVg1
.
hashBegin
,
newVg1
.
hashEnd
,
newVg1
.
vnodeGid
[
0
].
dnodeId
);
for
(
int32_t
i
=
0
;
i
<
newVg1
.
replica
;
++
i
)
{
mInfo
(
"vgId:%d, vnode:%d dnode:%d"
,
newVg1
.
vgId
,
i
,
newVg1
.
vnodeGid
[
i
].
dnodeId
);
}
mInfo
(
"vgId:%d, vgroup info after adjust hash, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d"
,
newVg2
.
vgId
,
mInfo
(
"vgId:%d, vgroup info after adjust hash, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d"
,
newVg2
.
vgId
,
newVg2
.
replica
,
newVg2
.
hashBegin
,
newVg2
.
hashEnd
,
newVg2
.
vnodeGid
[
0
].
dnodeId
);
newVg2
.
replica
,
newVg2
.
hashBegin
,
newVg2
.
hashEnd
,
newVg2
.
vnodeGid
[
0
].
dnodeId
);
for
(
int32_t
i
=
0
;
i
<
newVg1
.
replica
;
++
i
)
{
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
,
&
newVg1
)
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeHashRangeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg2
)
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeHashRangeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg2
)
!=
0
)
goto
_OVER
;
...
@@ -1854,17 +1911,6 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
...
@@ -1854,17 +1911,6 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
(
void
)
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_DROPPED
);
(
void
)
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_DROPPED
);
pRaw
=
NULL
;
pRaw
=
NULL
;
mInfo
(
"vgId:%d, vgroup info after adjust hash, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d"
,
newVg1
.
vgId
,
newVg1
.
replica
,
newVg1
.
hashBegin
,
newVg1
.
hashEnd
,
newVg1
.
vnodeGid
[
0
].
dnodeId
);
for
(
int32_t
i
=
0
;
i
<
newVg1
.
replica
;
++
i
)
{
mInfo
(
"vgId:%d, vnode:%d dnode:%d"
,
newVg1
.
vgId
,
i
,
newVg1
.
vnodeGid
[
i
].
dnodeId
);
}
mInfo
(
"vgId:%d, vgroup info after adjust hash, replica:%d hashBegin:%u hashEnd:%u vnode:0 dnode:%d"
,
newVg2
.
vgId
,
newVg2
.
replica
,
newVg2
.
hashBegin
,
newVg2
.
hashEnd
,
newVg2
.
vnodeGid
[
0
].
dnodeId
);
for
(
int32_t
i
=
0
;
i
<
newVg1
.
replica
;
++
i
)
{
mInfo
(
"vgId:%d, vnode:%d dnode:%d"
,
newVg2
.
vgId
,
i
,
newVg2
.
vnodeGid
[
i
].
dnodeId
);
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
code
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录