Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7f3c6042
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7f3c6042
编写于
5月 24, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: mnode sync
上级
907ff2e4
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
76 addition
and
90 deletion
+76
-90
include/dnode/mnode/mnode.h
include/dnode/mnode/mnode.h
+1
-1
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
+47
-43
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
+18
-37
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+1
-1
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+5
-5
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+1
-1
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+3
-2
未找到文件。
include/dnode/mnode/mnode.h
浏览文件 @
7f3c6042
...
...
@@ -29,7 +29,7 @@ extern "C" {
typedef
struct
SMnode
SMnode
;
typedef
struct
{
bool
isStandB
y
;
bool
standb
y
;
bool
deploy
;
int8_t
replica
;
int8_t
selfIndex
;
...
...
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
浏览文件 @
7f3c6042
...
...
@@ -53,43 +53,45 @@ int32_t mmReadFile(SMnodeMgmt *pMgmt, bool *pDeployed) {
*
pDeployed
=
deployed
->
valueint
;
cJSON
*
mnodes
=
cJSON_GetObjectItem
(
root
,
"mnodes"
);
if
(
!
mnodes
||
mnodes
->
type
!=
cJSON_Array
)
{
dError
(
"failed to read %s since nodes not found"
,
file
);
goto
_OVER
;
}
pMgmt
->
replica
=
cJSON_GetArraySize
(
mnodes
);
if
(
pMgmt
->
replica
<=
0
||
pMgmt
->
replica
>
TSDB_MAX_REPLICA
)
{
dError
(
"failed to read %s since mnodes size %d invalid"
,
file
,
pMgmt
->
replica
);
goto
_OVER
;
}
for
(
int32_t
i
=
0
;
i
<
pMgmt
->
replica
;
++
i
)
{
cJSON
*
node
=
cJSON_GetArrayItem
(
mnodes
,
i
);
if
(
node
==
NULL
)
break
;
SReplica
*
pReplica
=
&
pMgmt
->
replicas
[
i
];
cJSON
*
id
=
cJSON_GetObjectItem
(
node
,
"id"
);
if
(
!
id
||
id
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s since id not found"
,
file
);
if
(
mnodes
!=
NULL
)
{
if
(
!
mnodes
||
mnodes
->
type
!=
cJSON_Array
)
{
dError
(
"failed to read %s since nodes not found"
,
file
);
goto
_OVER
;
}
pReplica
->
id
=
id
->
valueint
;
cJSON
*
fqdn
=
cJSON_GetObjectItem
(
node
,
"fqdn"
);
if
(
!
fqdn
||
fqdn
->
type
!=
cJSON_String
||
fqdn
->
valuestring
==
NULL
)
{
dError
(
"failed to read %s since
fqdn not found"
,
file
);
pMgmt
->
replica
=
cJSON_GetArraySize
(
mnodes
);
if
(
pMgmt
->
replica
<=
0
||
pMgmt
->
replica
>
TSDB_MAX_REPLICA
)
{
dError
(
"failed to read %s since
mnodes size %d invalid"
,
file
,
pMgmt
->
replica
);
goto
_OVER
;
}
tstrncpy
(
pReplica
->
fqdn
,
fqdn
->
valuestring
,
TSDB_FQDN_LEN
);
cJSON
*
port
=
cJSON_GetObjectItem
(
node
,
"port"
);
if
(
!
port
||
port
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s since port not found"
,
file
);
goto
_OVER
;
for
(
int32_t
i
=
0
;
i
<
pMgmt
->
replica
;
++
i
)
{
cJSON
*
node
=
cJSON_GetArrayItem
(
mnodes
,
i
);
if
(
node
==
NULL
)
break
;
SReplica
*
pReplica
=
&
pMgmt
->
replicas
[
i
];
cJSON
*
id
=
cJSON_GetObjectItem
(
node
,
"id"
);
if
(
!
id
||
id
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s since id not found"
,
file
);
goto
_OVER
;
}
pReplica
->
id
=
id
->
valueint
;
cJSON
*
fqdn
=
cJSON_GetObjectItem
(
node
,
"fqdn"
);
if
(
!
fqdn
||
fqdn
->
type
!=
cJSON_String
||
fqdn
->
valuestring
==
NULL
)
{
dError
(
"failed to read %s since fqdn not found"
,
file
);
goto
_OVER
;
}
tstrncpy
(
pReplica
->
fqdn
,
fqdn
->
valuestring
,
TSDB_FQDN_LEN
);
cJSON
*
port
=
cJSON_GetObjectItem
(
node
,
"port"
);
if
(
!
port
||
port
->
type
!=
cJSON_Number
)
{
dError
(
"failed to read %s since port not found"
,
file
);
goto
_OVER
;
}
pReplica
->
port
=
port
->
valueint
;
}
pReplica
->
port
=
port
->
valueint
;
}
code
=
0
;
...
...
@@ -122,21 +124,23 @@ int32_t mmWriteFile(SMnodeMgmt *pMgmt, SDCreateMnodeReq *pMsg, bool deployed) {
char
*
content
=
taosMemoryCalloc
(
1
,
maxLen
+
1
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
mnodes
\"
: [{
\n
"
);
int8_t
replica
=
(
pMsg
!=
NULL
?
pMsg
->
replica
:
pMgmt
->
replica
);
for
(
int32_t
i
=
0
;
i
<
replica
;
++
i
)
{
SReplica
*
pReplica
=
&
pMgmt
->
replicas
[
i
];
if
(
pMsg
!=
NULL
)
{
pReplica
=
&
pMsg
->
replicas
[
i
];
}
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
id
\"
: %d,
\n
"
,
pReplica
->
id
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
fqdn
\"
:
\"
%s
\"
,
\n
"
,
pReplica
->
fqdn
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
port
\"
: %u
\n
"
,
pReplica
->
port
);
if
(
i
<
replica
-
1
)
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
" },{
\n
"
);
}
else
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
" }],
\n
"
);
if
(
replica
>
0
)
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
mnodes
\"
: [{
\n
"
);
for
(
int32_t
i
=
0
;
i
<
replica
;
++
i
)
{
SReplica
*
pReplica
=
&
pMgmt
->
replicas
[
i
];
if
(
pMsg
!=
NULL
)
{
pReplica
=
&
pMsg
->
replicas
[
i
];
}
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
id
\"
: %d,
\n
"
,
pReplica
->
id
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
fqdn
\"
:
\"
%s
\"
,
\n
"
,
pReplica
->
fqdn
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
port
\"
: %u
\n
"
,
pReplica
->
port
);
if
(
i
<
replica
-
1
)
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
" },{
\n
"
);
}
else
{
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
" }],
\n
"
);
}
}
}
...
...
source/dnode/mgmt/mgmt_mnode/src/mmInt.c
浏览文件 @
7f3c6042
...
...
@@ -39,54 +39,44 @@ static int32_t mmRequire(const SMgmtInputOpt *pInput, bool *required) {
}
static
void
mmBuildOptionForDeploy
(
SMnodeMgmt
*
pMgmt
,
const
SMgmtInputOpt
*
pInput
,
SMnodeOpt
*
pOption
)
{
pOption
->
standby
=
false
;
pOption
->
deploy
=
true
;
pOption
->
msgCb
=
pMgmt
->
msgCb
;
pOption
->
replica
=
1
;
pOption
->
selfIndex
=
0
;
SReplica
*
pReplica
=
&
pOption
->
replicas
[
0
];
pReplica
->
id
=
1
;
pReplica
->
port
=
tsServerPort
;
tstrncpy
(
pReplica
->
fqdn
,
tsLocalFqdn
,
TSDB_FQDN_LEN
);
pOption
->
deploy
=
true
;
pMgmt
->
selfIndex
=
pOption
->
selfIndex
;
pMgmt
->
replica
=
pOption
->
replica
;
memcpy
(
&
pMgmt
->
replicas
,
pOption
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
}
static
void
mmBuildOptionForOpen
(
SMnodeMgmt
*
pMgmt
,
SMnodeOpt
*
pOption
)
{
pOption
->
msgCb
=
pMgmt
->
msgCb
;
pOption
->
deploy
=
false
;
pOption
->
standby
=
false
;
if
(
pMgmt
->
replica
>
1
)
{
if
(
pMgmt
->
replica
>
0
)
{
pOption
->
standby
=
true
;
pOption
->
replica
=
1
;
pOption
->
selfIndex
=
0
;
SReplica
*
pReplica
=
&
pOption
->
replicas
[
0
];
for
(
int32_t
i
=
0
;
i
<
pMgmt
->
replica
;
++
i
)
{
if
(
pMgmt
->
replicas
[
i
].
id
==
pMgmt
->
pData
->
dnodeId
)
{
pReplica
->
id
=
pMgmt
->
replicas
[
i
].
id
;
pReplica
->
port
=
pMgmt
->
replicas
[
i
].
port
;
memcpy
(
pReplica
->
fqdn
,
pMgmt
->
replicas
[
i
].
fqdn
,
TSDB_FQDN_LEN
);
}
}
pMgmt
->
selfIndex
=
pOption
->
selfIndex
;
pOption
->
isStandBy
=
1
;
}
else
{
pOption
->
replica
=
pMgmt
->
replica
;
pOption
->
selfIndex
=
-
1
;
memcpy
(
&
pOption
->
replicas
,
pMgmt
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
for
(
int32_t
i
=
0
;
i
<
pOption
->
replica
;
++
i
)
{
if
(
pOption
->
replicas
[
i
].
id
==
pMgmt
->
pData
->
dnodeId
)
{
pOption
->
selfIndex
=
i
;
}
if
(
pMgmt
->
replicas
[
i
].
id
!=
pMgmt
->
pData
->
dnodeId
)
continue
;
pReplica
->
id
=
pMgmt
->
replicas
[
i
].
id
;
pReplica
->
port
=
pMgmt
->
replicas
[
i
].
port
;
memcpy
(
pReplica
->
fqdn
,
pMgmt
->
replicas
[
i
].
fqdn
,
TSDB_FQDN_LEN
);
}
pMgmt
->
selfIndex
=
pOption
->
selfIndex
;
}
pOption
->
deploy
=
false
;
}
static
int32_t
mmBuildOptionF
romReq
(
SMnodeMgmt
*
pMgmt
,
SMnodeOpt
*
pOption
,
SDCreateMnodeReq
*
pCreate
)
{
static
int32_t
mmBuildOptionF
orAlter
(
SMnodeMgmt
*
pMgmt
,
SMnodeOpt
*
pOption
,
SDCreateMnodeReq
*
pCreate
)
{
pOption
->
msgCb
=
pMgmt
->
msgCb
;
pOption
->
standby
=
false
;
pOption
->
deploy
=
false
;
pOption
->
replica
=
pCreate
->
replica
;
pOption
->
selfIndex
=
-
1
;
for
(
int32_t
i
=
0
;
i
<
pCreate
->
replica
;
++
i
)
{
SReplica
*
pReplica
=
&
pOption
->
replicas
[
i
];
pReplica
->
id
=
pCreate
->
replicas
[
i
].
id
;
...
...
@@ -101,17 +91,13 @@ static int32_t mmBuildOptionFromReq(SMnodeMgmt *pMgmt, SMnodeOpt *pOption, SDCre
dError
(
"failed to build mnode options since %s"
,
terrstr
());
return
-
1
;
}
pOption
->
deploy
=
true
;
pMgmt
->
selfIndex
=
pOption
->
selfIndex
;
pMgmt
->
replica
=
pOption
->
replica
;
memcpy
(
&
pMgmt
->
replicas
,
pOption
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
return
0
;
}
int32_t
mmAlter
(
SMnodeMgmt
*
pMgmt
,
SDAlterMnodeReq
*
pMsg
)
{
SMnodeOpt
option
=
{
0
};
if
(
mmBuildOptionF
romReq
(
pMgmt
,
&
option
,
pMsg
)
!=
0
)
{
if
(
mmBuildOptionF
orAlter
(
pMgmt
,
&
option
,
pMsg
)
!=
0
)
{
return
-
1
;
}
...
...
@@ -119,12 +105,6 @@ int32_t mmAlter(SMnodeMgmt *pMgmt, SDAlterMnodeReq *pMsg) {
return
-
1
;
}
bool
deployed
=
true
;
if
(
mmWriteFile
(
pMgmt
,
pMsg
,
deployed
)
!=
0
)
{
dError
(
"failed to write mnode file since %s"
,
terrstr
());
return
-
1
;
}
return
0
;
}
...
...
@@ -199,7 +179,8 @@ static int32_t mmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
}
tmsgReportStartup
(
"mnode-worker"
,
"initialized"
);
if
(
!
deployed
)
{
if
(
!
deployed
||
pMgmt
->
replica
>
0
)
{
pMgmt
->
replica
=
0
;
deployed
=
true
;
if
(
mmWriteFile
(
pMgmt
,
NULL
,
deployed
)
!=
0
)
{
dError
(
"failed to write mnode file since %s"
,
terrstr
());
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
7f3c6042
...
...
@@ -79,7 +79,7 @@ typedef struct {
sem_t
syncSem
;
int64_t
sync
;
ESyncState
state
;
bool
isStandB
y
;
bool
standb
y
;
bool
restored
;
int32_t
errCode
;
}
SSyncMgmt
;
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
7f3c6042
...
...
@@ -120,8 +120,8 @@ int32_t mndInitSync(SMnode *pMnode) {
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
pCfg
->
replicaNum
=
pMnode
->
replica
;
pCfg
->
myIndex
=
pMnode
->
selfIndex
;
mInfo
(
"start to open mnode sync, replica:%d my
Index:%d standB
y:%d"
,
pCfg
->
replicaNum
,
pCfg
->
myIndex
,
pMgmt
->
isStandB
y
);
mInfo
(
"start to open mnode sync, replica:%d my
index:%d standb
y:%d"
,
pCfg
->
replicaNum
,
pCfg
->
myIndex
,
pMgmt
->
standb
y
);
for
(
int32_t
i
=
0
;
i
<
pMnode
->
replica
;
++
i
)
{
SNodeInfo
*
pNode
=
&
pCfg
->
nodeInfo
[
i
];
tstrncpy
(
pNode
->
nodeFqdn
,
pMnode
->
replicas
[
i
].
fqdn
,
sizeof
(
pNode
->
nodeFqdn
));
...
...
@@ -182,7 +182,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw) {
void
mndSyncStart
(
SMnode
*
pMnode
)
{
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
syncSetMsgCb
(
pMgmt
->
sync
,
&
pMnode
->
msgCb
);
if
(
pMgmt
->
isStandB
y
)
{
if
(
pMgmt
->
standb
y
)
{
syncStartStandBy
(
pMgmt
->
sync
);
}
else
{
syncStart
(
pMgmt
->
sync
);
...
...
@@ -201,7 +201,7 @@ bool mndIsMaster(SMnode *pMnode) {
int32_t
mndAlter
(
SMnode
*
pMnode
,
const
SMnodeOpt
*
pOption
)
{
SSyncCfg
cfg
=
{.
replicaNum
=
pOption
->
replica
,
.
myIndex
=
pOption
->
selfIndex
};
mInfo
(
"start to alter mnode sync, replica:%d my
Index:%d standBy:%d"
,
cfg
.
replicaNum
,
cfg
.
myIndex
,
pOption
->
isStandB
y
);
mInfo
(
"start to alter mnode sync, replica:%d my
index:%d standby:%d"
,
cfg
.
replicaNum
,
cfg
.
myIndex
,
pOption
->
standb
y
);
for
(
int32_t
i
=
0
;
i
<
pOption
->
replica
;
++
i
)
{
SNodeInfo
*
pNode
=
&
cfg
.
nodeInfo
[
i
];
tstrncpy
(
pNode
->
nodeFqdn
,
pOption
->
replicas
[
i
].
fqdn
,
sizeof
(
pNode
->
nodeFqdn
));
...
...
@@ -210,6 +210,6 @@ int32_t mndAlter(SMnode *pMnode, const SMnodeOpt *pOption) {
}
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
pMgmt
->
isStandBy
=
pOption
->
isStandB
y
;
pMgmt
->
standby
=
pOption
->
standb
y
;
return
syncReconfig
(
pMgmt
->
sync
,
&
cfg
);
}
\ No newline at end of file
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
7f3c6042
...
...
@@ -263,7 +263,7 @@ static void mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
memcpy
(
&
pMnode
->
replicas
,
pOption
->
replicas
,
sizeof
(
SReplica
)
*
TSDB_MAX_REPLICA
);
pMnode
->
msgCb
=
pOption
->
msgCb
;
pMnode
->
selfId
=
pOption
->
replicas
[
pOption
->
selfIndex
].
id
;
pMnode
->
syncMgmt
.
isStandBy
=
pOption
->
isStandB
y
;
pMnode
->
syncMgmt
.
standby
=
pOption
->
standb
y
;
}
SMnode
*
mndOpen
(
const
char
*
path
,
const
SMnodeOpt
*
pOption
)
{
...
...
tests/script/jenkins/basic.txt
浏览文件 @
7f3c6042
...
...
@@ -55,7 +55,8 @@
./test.sh -f tsim/bnode/basic1.sim
# ---- mnode
./test.sh -f tsim/mnode/basic1.sim
#./test.sh -f tsim/mnode/basic1.sim
./test.sh -f tsim/mnode/basic2.sim
# ---- show
./test.sh -f tsim/show/basic.sim
...
...
@@ -104,7 +105,7 @@
./test.sh -f tsim/tmq/basic3.sim -m
./test.sh -f tsim/stable/vnode3.sim -m
./test.sh -f tsim/qnode/basic1.sim -m
./test.sh -f tsim/mnode/basic1.sim -m
#
./test.sh -f tsim/mnode/basic1.sim -m
# --- sma
./test.sh -f tsim/sma/tsmaCreateInsertData.sim
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录