Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
70b513c0
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看板
提交
70b513c0
编写于
1月 03, 2023
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: vnode set the wrong replica info after snapshot transfered
上级
650ea06b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
35 addition
and
18 deletion
+35
-18
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+3
-2
source/dnode/vnode/src/vnd/vnodeCfg.c
source/dnode/vnode/src/vnd/vnodeCfg.c
+20
-10
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+4
-2
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+3
-2
source/dnode/vnode/src/vnd/vnodeSnapshot.c
source/dnode/vnode/src/vnd/vnodeSnapshot.c
+4
-0
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+1
-2
未找到文件。
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
70b513c0
...
...
@@ -132,7 +132,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
pCfg
->
syncCfg
.
myIndex
=
pCreate
->
selfIndex
;
pCfg
->
syncCfg
.
replicaNum
=
pCreate
->
replica
;
memset
(
&
pCfg
->
syncCfg
.
nodeInfo
,
0
,
sizeof
(
pCfg
->
syncCfg
.
nodeInfo
));
for
(
int
i
=
0
;
i
<
pCreate
->
replica
;
++
i
)
{
for
(
int
32_t
i
=
0
;
i
<
pCreate
->
replica
;
++
i
)
{
SNodeInfo
*
pNode
=
&
pCfg
->
syncCfg
.
nodeInfo
[
i
];
pNode
->
nodeId
=
pCreate
->
replicas
[
i
].
id
;
pNode
->
nodePort
=
pCreate
->
replicas
[
i
].
port
;
...
...
@@ -288,7 +288,8 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
dInfo
(
"vgId:%d, start to alter vnode, replica:%d selfIndex:%d strict:%d"
,
alterReq
.
vgId
,
alterReq
.
replica
,
alterReq
.
selfIndex
,
alterReq
.
strict
);
for
(
int32_t
i
=
0
;
i
<
alterReq
.
replica
;
++
i
)
{
dInfo
(
"vgId:%d, replica:%d ep:%s:%u"
,
alterReq
.
vgId
,
i
,
alterReq
.
replicas
[
i
].
fqdn
,
alterReq
.
replicas
[
i
].
port
);
SReplica
*
pReplica
=
&
alterReq
.
replicas
[
i
];
dInfo
(
"vgId:%d, replica:%d ep:%s:%u dnode:%d"
,
alterReq
.
vgId
,
i
,
pReplica
->
fqdn
,
pReplica
->
port
,
pReplica
->
port
);
}
if
(
alterReq
.
replica
<=
0
||
alterReq
.
selfIndex
<
0
||
alterReq
.
selfIndex
>=
alterReq
.
replica
)
{
...
...
source/dnode/vnode/src/vnd/vnodeCfg.c
浏览文件 @
70b513c0
...
...
@@ -128,14 +128,19 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
SJson
*
nodeInfo
=
tjsonCreateArray
();
if
(
nodeInfo
==
NULL
)
return
-
1
;
if
(
tjsonAddItemToObject
(
pJson
,
"syncCfg.nodeInfo"
,
nodeInfo
)
<
0
)
return
-
1
;
vDebug
(
"vgId:%d, encode config, replicas:%d selfIndex:%d"
,
pCfg
->
vgId
,
pCfg
->
syncCfg
.
replicaNum
,
pCfg
->
syncCfg
.
myIndex
);
for
(
int
i
=
0
;
i
<
pCfg
->
syncCfg
.
replicaNum
;
++
i
)
{
SJson
*
info
=
tjsonCreateObject
();
SJson
*
info
=
tjsonCreateObject
();
SNodeInfo
*
pNode
=
(
SNodeInfo
*
)
&
pCfg
->
syncCfg
.
nodeInfo
[
i
];
if
(
info
==
NULL
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
info
,
"nodePort"
,
p
Cfg
->
syncCfg
.
nodeInfo
[
i
].
nodePort
)
<
0
)
return
-
1
;
if
(
tjsonAddStringToObject
(
info
,
"nodeFqdn"
,
p
Cfg
->
syncCfg
.
nodeInfo
[
i
].
nodeFqdn
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
info
,
"nodeId"
,
p
Cfg
->
syncCfg
.
nodeInfo
[
i
].
nodeId
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
info
,
"clusterId"
,
p
Cfg
->
syncCfg
.
nodeInfo
[
i
].
clusterId
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
info
,
"nodePort"
,
p
Node
->
nodePort
)
<
0
)
return
-
1
;
if
(
tjsonAddStringToObject
(
info
,
"nodeFqdn"
,
p
Node
->
nodeFqdn
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
info
,
"nodeId"
,
p
Node
->
nodeId
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
info
,
"clusterId"
,
p
Node
->
clusterId
)
<
0
)
return
-
1
;
if
(
tjsonAddItemToArray
(
nodeInfo
,
info
)
<
0
)
return
-
1
;
vDebug
(
"vgId:%d, encode config, replica:%d ep:%s:%u dnode:%d"
,
pCfg
->
vgId
,
i
,
pNode
->
nodeFqdn
,
pNode
->
nodePort
,
pNode
->
nodeId
);
}
return
0
;
...
...
@@ -248,15 +253,20 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
int
arraySize
=
tjsonGetArraySize
(
nodeInfo
);
if
(
arraySize
!=
pCfg
->
syncCfg
.
replicaNum
)
return
-
1
;
vDebug
(
"vgId:%d, decode config, replicas:%d selfIndex:%d"
,
pCfg
->
vgId
,
pCfg
->
syncCfg
.
replicaNum
,
pCfg
->
syncCfg
.
myIndex
);
for
(
int
i
=
0
;
i
<
arraySize
;
++
i
)
{
SJson
*
info
=
tjsonGetArrayItem
(
nodeInfo
,
i
);
SJson
*
info
=
tjsonGetArrayItem
(
nodeInfo
,
i
);
SNodeInfo
*
pNode
=
&
pCfg
->
syncCfg
.
nodeInfo
[
i
];
if
(
info
==
NULL
)
return
-
1
;
tjsonGetNumberValue
(
info
,
"nodePort"
,
p
Cfg
->
syncCfg
.
nodeInfo
[
i
].
nodePort
,
code
);
tjsonGetNumberValue
(
info
,
"nodePort"
,
p
Node
->
nodePort
,
code
);
if
(
code
<
0
)
return
-
1
;
tjsonGetStringValue
(
info
,
"nodeFqdn"
,
p
Cfg
->
syncCfg
.
nodeInfo
[
i
].
nodeFqdn
);
tjsonGetStringValue
(
info
,
"nodeFqdn"
,
p
Node
->
nodeFqdn
);
if
(
code
<
0
)
return
-
1
;
tjsonGetNumberValue
(
info
,
"nodeId"
,
pCfg
->
syncCfg
.
nodeInfo
[
i
].
nodeId
,
code
);
tjsonGetNumberValue
(
info
,
"clusterId"
,
pCfg
->
syncCfg
.
nodeInfo
[
i
].
clusterId
,
code
);
tjsonGetNumberValue
(
info
,
"nodeId"
,
pNode
->
nodeId
,
code
);
tjsonGetNumberValue
(
info
,
"clusterId"
,
pNode
->
clusterId
,
code
);
vDebug
(
"vgId:%d, decode config, replica:%d ep:%s:%u dnode:%d"
,
pCfg
->
vgId
,
i
,
pNode
->
nodeFqdn
,
pNode
->
nodePort
,
pNode
->
nodeId
);
}
tjsonGetNumberValue
(
pJson
,
"tsdbPageSize"
,
pCfg
->
tsdbPageSize
,
code
);
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
70b513c0
...
...
@@ -105,8 +105,8 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) {
// free info binary
taosMemoryFree
(
data
);
vInfo
(
"vgId:%d, vnode info is saved, fname:%s replica:%d"
,
pInfo
->
config
.
vgId
,
fname
,
pInfo
->
config
.
syncCfg
.
replicaNum
);
vInfo
(
"vgId:%d, vnode info is saved, fname:%s replica:%d
selfIndex:%d
"
,
pInfo
->
config
.
vgId
,
fname
,
pInfo
->
config
.
syncCfg
.
replicaNum
,
pInfo
->
config
.
syncCfg
.
myIndex
);
return
0
;
...
...
@@ -206,6 +206,8 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
}
else
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s"
,
pVnode
->
path
);
}
vDebug
(
"vgId:%d, save config while prepare commit"
,
TD_VID
(
pVnode
));
if
(
vnodeSaveInfo
(
dir
,
&
pInfo
->
info
)
<
0
)
{
code
=
terrno
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
70b513c0
...
...
@@ -48,6 +48,7 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
info
.
state
.
applied
=
-
1
;
info
.
state
.
commitID
=
0
;
vInfo
(
"vgId:%d, save config while create"
,
pCfg
->
vgId
);
if
(
vnodeSaveInfo
(
dir
,
&
info
)
<
0
||
vnodeCommitInfo
(
dir
,
&
info
)
<
0
)
{
vError
(
"vgId:%d, failed to save vnode config since %s"
,
pCfg
?
pCfg
->
vgId
:
0
,
tstrerror
(
terrno
));
return
-
1
;
...
...
@@ -79,14 +80,14 @@ int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs) {
pCfg
->
replicaNum
=
pReq
->
replica
;
memset
(
&
pCfg
->
nodeInfo
,
0
,
sizeof
(
pCfg
->
nodeInfo
));
vInfo
(
"vgId:%d, save config, replicas:%d selfIndex:%d"
,
pReq
->
vgId
,
pCfg
->
replicaNum
,
pCfg
->
myIndex
);
vInfo
(
"vgId:%d, save config
while alter
, replicas:%d selfIndex:%d"
,
pReq
->
vgId
,
pCfg
->
replicaNum
,
pCfg
->
myIndex
);
for
(
int
i
=
0
;
i
<
pReq
->
replica
;
++
i
)
{
SNodeInfo
*
pNode
=
&
pCfg
->
nodeInfo
[
i
];
pNode
->
nodeId
=
pReq
->
replicas
[
i
].
id
;
pNode
->
nodePort
=
pReq
->
replicas
[
i
].
port
;
tstrncpy
(
pNode
->
nodeFqdn
,
pReq
->
replicas
[
i
].
fqdn
,
sizeof
(
pNode
->
nodeFqdn
));
(
void
)
tmsgUpdateDnodeInfo
(
&
pNode
->
nodeId
,
&
pNode
->
clusterId
,
pNode
->
nodeFqdn
,
&
pNode
->
nodePort
);
vInfo
(
"vgId:%d,
save config, replica:%d ep:%s:%u"
,
pReq
->
vgId
,
i
,
pNode
->
nodeFqdn
,
pNode
->
nodePort
);
vInfo
(
"vgId:%d,
replica:%d ep:%s:%u dnode:%d"
,
pReq
->
vgId
,
i
,
pNode
->
nodeFqdn
,
pNode
->
nodePort
,
pNode
->
nodeId
);
}
info
.
config
.
syncCfg
=
*
pCfg
;
...
...
source/dnode/vnode/src/vnd/vnodeSnapshot.c
浏览文件 @
70b513c0
...
...
@@ -405,6 +405,10 @@ static int32_t vnodeSnapWriteInfo(SVSnapWriter *pWriter, uint8_t *pData, uint32_
}
else
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s"
,
pWriter
->
pVnode
->
path
);
}
SVnode
*
pVnode
=
pWriter
->
pVnode
;
pWriter
->
info
.
config
=
pVnode
->
config
;
vDebug
(
"vgId:%d, save config while write snapshot"
,
pWriter
->
pVnode
->
config
.
vgId
);
if
(
vnodeSaveInfo
(
dir
,
&
pWriter
->
info
)
<
0
)
{
code
=
terrno
;
goto
_exit
;
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
70b513c0
...
...
@@ -851,6 +851,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
if
(
!
taosCheckExistFile
(
pSyncNode
->
configPath
))
{
// create a new raft config file
sInfo
(
"vgId:%d, create a new raft config file"
,
pSyncNode
->
vgId
);
pSyncNode
->
raftCfg
.
isStandBy
=
pSyncInfo
->
isStandBy
;
pSyncNode
->
raftCfg
.
snapshotStrategy
=
pSyncInfo
->
snapshotStrategy
;
pSyncNode
->
raftCfg
.
lastConfigIndex
=
SYNC_INDEX_INVALID
;
...
...
@@ -894,7 +895,6 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
pNode
->
nodeId
,
pNode
->
clusterId
);
}
pSyncNode
->
pWal
=
pSyncInfo
->
pWal
;
pSyncNode
->
msgcb
=
pSyncInfo
->
msgcb
;
pSyncNode
->
syncSendMSg
=
pSyncInfo
->
syncSendMSg
;
...
...
@@ -1656,7 +1656,6 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
// persist cfg
syncWriteCfgFile
(
pSyncNode
);
// change isStandBy to normal (election timeout)
if
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
syncNodeBecomeLeader
(
pSyncNode
,
""
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录