Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
dbae9a47
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,发现更多精彩内容 >>
提交
dbae9a47
编写于
10月 11, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: check memory while alter db buffer
上级
37c193b3
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
131 addition
and
80 deletion
+131
-80
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+34
-25
source/dnode/mnode/impl/inc/mndVgroup.h
source/dnode/mnode/impl/inc/mndVgroup.h
+2
-1
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+3
-3
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+62
-25
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+30
-26
未找到文件。
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
dbae9a47
...
...
@@ -212,38 +212,47 @@ static int32_t vmTsmaProcessCreate(SVnode *pVnode, SCreateVnodeReq *pReq) {
}
int32_t
vmProcessCreateVnodeReq
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
SCreateVnodeReq
createR
eq
=
{
0
};
SCreateVnodeReq
r
eq
=
{
0
};
SVnodeCfg
vnodeCfg
=
{
0
};
SWrapperCfg
wrapperCfg
=
{
0
};
int32_t
code
=
-
1
;
char
path
[
TSDB_FILENAME_LEN
]
=
{
0
};
if
(
tDeserializeSCreateVnodeReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
createR
eq
)
!=
0
)
{
if
(
tDeserializeSCreateVnodeReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
r
eq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
dInfo
(
"vgId:%d, start to create vnode, tsma:%d standby:%d cacheLast:%d cacheLastSize:%d sstTrigger:%d "
"tsdbPageSize:%d"
,
createReq
.
vgId
,
createReq
.
isTsma
,
createReq
.
standby
,
createReq
.
cacheLast
,
createReq
.
cacheLastSize
,
createReq
.
sstTrigger
,
createReq
.
tsdbPageSize
);
dInfo
(
"vgId:%d, hashMethod:%d begin:%u end:%u prefix:%d surfix:%d"
,
createReq
.
vgId
,
createReq
.
hashMethod
,
createReq
.
hashBegin
,
createReq
.
hashEnd
,
createReq
.
hashPrefix
,
createReq
.
hashSuffix
);
vmGenerateVnodeCfg
(
&
createReq
,
&
vnodeCfg
);
if
(
vmTsmaAdjustDays
(
&
vnodeCfg
,
&
createReq
)
<
0
)
{
dError
(
"vgId:%d, failed to adjust tsma days since %s"
,
createReq
.
vgId
,
terrstr
());
"vgId:%d, start to create vnode, page:%d pageSize:%d buffer:%d szPage:%d szBuf:%"
PRIu64
" cacheLast:%d cacheLastSize:%d sstTrigger:%d tsdbPageSize:%d %d dbname:%s dbId:%"
PRId64
"days:%d keep0:%d keep1:%d keep2:%d tsma:%d precision:%d compression:%d minRows:%d maxRows:%d, wal "
"fsync:%d level:%d retentionPeriod:%d retentionSize:%d rollPeriod:%d segSize:%d, hash method:%d begin:%u end:%u "
"prefix:%d surfix:%d replica:%d selfIndex:%d strict:%d"
,
req
.
vgId
,
req
.
pages
,
req
.
pageSize
,
req
.
buffer
,
req
.
pageSize
*
1024
,
(
uint64_t
)
req
.
buffer
*
1024
*
1024
,
req
.
cacheLast
,
req
.
cacheLastSize
,
req
.
sstTrigger
,
req
.
tsdbPageSize
,
req
.
tsdbPageSize
*
1024
,
req
.
db
,
req
.
dbUid
,
req
.
daysPerFile
,
req
.
daysToKeep0
,
req
.
daysToKeep1
,
req
.
daysToKeep2
,
req
.
isTsma
,
req
.
precision
,
req
.
compression
,
req
.
minRows
,
req
.
maxRows
,
req
.
walFsyncPeriod
,
req
.
walLevel
,
req
.
walRetentionPeriod
,
req
.
walRetentionSize
,
req
.
walRollPeriod
,
req
.
walSegmentSize
,
req
.
hashMethod
,
req
.
hashBegin
,
req
.
hashEnd
,
req
.
hashPrefix
,
req
.
hashSuffix
,
req
.
replica
,
req
.
selfIndex
,
req
.
strict
);
for
(
int32_t
i
=
0
;
i
<
req
.
replica
;
++
i
)
{
dInfo
(
"vgId:%d, replica:%d fqdn:%s port:%u"
,
req
.
vgId
,
req
.
replicas
[
i
].
id
,
req
.
replicas
[
i
].
fqdn
,
req
.
replicas
[
i
].
port
);
}
vmGenerateVnodeCfg
(
&
req
,
&
vnodeCfg
);
if
(
vmTsmaAdjustDays
(
&
vnodeCfg
,
&
req
)
<
0
)
{
dError
(
"vgId:%d, failed to adjust tsma days since %s"
,
req
.
vgId
,
terrstr
());
code
=
terrno
;
goto
_OVER
;
}
vmGenerateWrapperCfg
(
pMgmt
,
&
createR
eq
,
&
wrapperCfg
);
vmGenerateWrapperCfg
(
pMgmt
,
&
r
eq
,
&
wrapperCfg
);
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
createR
eq
.
vgId
);
SVnodeObj
*
pVnode
=
vmAcquireVnode
(
pMgmt
,
r
eq
.
vgId
);
if
(
pVnode
!=
NULL
)
{
dDebug
(
"vgId:%d, already exist"
,
createR
eq
.
vgId
);
tFreeSCreateVnodeReq
(
&
createR
eq
);
dDebug
(
"vgId:%d, already exist"
,
r
eq
.
vgId
);
tFreeSCreateVnodeReq
(
&
r
eq
);
vmReleaseVnode
(
pMgmt
,
pVnode
);
terrno
=
TSDB_CODE_NODE_ALREADY_DEPLOYED
;
code
=
terrno
;
...
...
@@ -252,36 +261,36 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
snprintf
(
path
,
TSDB_FILENAME_LEN
,
"vnode%svnode%d"
,
TD_DIRSEP
,
vnodeCfg
.
vgId
);
if
(
vnodeCreate
(
path
,
&
vnodeCfg
,
pMgmt
->
pTfs
)
<
0
)
{
tFreeSCreateVnodeReq
(
&
createR
eq
);
dError
(
"vgId:%d, failed to create vnode since %s"
,
createR
eq
.
vgId
,
terrstr
());
tFreeSCreateVnodeReq
(
&
r
eq
);
dError
(
"vgId:%d, failed to create vnode since %s"
,
r
eq
.
vgId
,
terrstr
());
code
=
terrno
;
goto
_OVER
;
}
SVnode
*
pImpl
=
vnodeOpen
(
path
,
pMgmt
->
pTfs
,
pMgmt
->
msgCb
);
if
(
pImpl
==
NULL
)
{
dError
(
"vgId:%d, failed to open vnode since %s"
,
createR
eq
.
vgId
,
terrstr
());
dError
(
"vgId:%d, failed to open vnode since %s"
,
r
eq
.
vgId
,
terrstr
());
code
=
terrno
;
goto
_OVER
;
}
code
=
vmOpenVnode
(
pMgmt
,
&
wrapperCfg
,
pImpl
);
if
(
code
!=
0
)
{
dError
(
"vgId:%d, failed to open vnode since %s"
,
createR
eq
.
vgId
,
terrstr
());
dError
(
"vgId:%d, failed to open vnode since %s"
,
r
eq
.
vgId
,
terrstr
());
code
=
terrno
;
goto
_OVER
;
}
code
=
vmTsmaProcessCreate
(
pImpl
,
&
createR
eq
);
code
=
vmTsmaProcessCreate
(
pImpl
,
&
r
eq
);
if
(
code
!=
0
)
{
dError
(
"vgId:%d, failed to create tsma since %s"
,
createR
eq
.
vgId
,
terrstr
());
dError
(
"vgId:%d, failed to create tsma since %s"
,
r
eq
.
vgId
,
terrstr
());
code
=
terrno
;
goto
_OVER
;
}
code
=
vnodeStart
(
pImpl
);
if
(
code
!=
0
)
{
dError
(
"vgId:%d, failed to start sync since %s"
,
createR
eq
.
vgId
,
terrstr
());
dError
(
"vgId:%d, failed to start sync since %s"
,
r
eq
.
vgId
,
terrstr
());
goto
_OVER
;
}
...
...
@@ -296,10 +305,10 @@ _OVER:
vnodeClose
(
pImpl
);
vnodeDestroy
(
path
,
pMgmt
->
pTfs
);
}
else
{
dInfo
(
"vgId:%d, vnode is created"
,
createR
eq
.
vgId
);
dInfo
(
"vgId:%d, vnode is created"
,
r
eq
.
vgId
);
}
tFreeSCreateVnodeReq
(
&
createR
eq
);
tFreeSCreateVnodeReq
(
&
r
eq
);
terrno
=
code
;
return
code
;
}
...
...
source/dnode/mnode/impl/inc/mndVgroup.h
浏览文件 @
dbae9a47
...
...
@@ -44,7 +44,8 @@ int32_t mndAddAlterVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pV
int32_t
mndAddDropVnodeAction
(
SMnode
*
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
SVnodeGid
*
pVgid
,
bool
isRedo
);
int32_t
mndSetMoveVgroupInfoToTrans
(
SMnode
*
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
int32_t
vn
,
SArray
*
pArray
);
int32_t
mndSetMoveVgroupsInfoToTrans
(
SMnode
*
,
STrans
*
pTrans
,
int32_t
dropDnodeId
);
int32_t
mndBuildAlterVgroupAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
SArray
*
pArray
);
int32_t
mndBuildAlterVgroupAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pOldDb
,
SDbObj
*
pNewDb
,
SVgObj
*
pVgroup
,
SArray
*
pArray
);
void
*
mndBuildCreateVnodeReq
(
SMnode
*
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
int32_t
*
cntlen
,
bool
standby
);
void
*
mndBuildDropVnodeReq
(
SMnode
*
,
SDnodeObj
*
pDnode
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
int32_t
*
pContLen
);
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
dbae9a47
...
...
@@ -746,7 +746,7 @@ static int32_t mndSetAlterDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *p
return
0
;
}
static
int32_t
mndSetAlterDbRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pOld
,
SDbObj
*
pNew
)
{
static
int32_t
mndSetAlterDbRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pOld
Db
,
SDbObj
*
pNewDb
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
SArray
*
pArray
=
mndBuildDnodesArray
(
pMnode
,
0
);
...
...
@@ -756,8 +756,8 @@ static int32_t mndSetAlterDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj *
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
if
(
mndVgroupInDb
(
pVgroup
,
pNew
->
uid
))
{
if
(
mndBuildAlterVgroupAction
(
pMnode
,
pTrans
,
p
New
,
pVgroup
,
pArray
)
!=
0
)
{
if
(
mndVgroupInDb
(
pVgroup
,
pNew
Db
->
uid
))
{
if
(
mndBuildAlterVgroupAction
(
pMnode
,
pTrans
,
p
OldDb
,
pNewDb
,
pVgroup
,
pArray
)
!=
0
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
taosArrayDestroy
(
pArray
);
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
dbae9a47
...
...
@@ -1530,44 +1530,81 @@ _OVER:
#endif
}
int32_t
mndBuildAlterVgroupAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
SArray
*
pArray
)
{
if
(
pVgroup
->
replica
<=
0
||
pVgroup
->
replica
==
pDb
->
cfg
.
replications
)
{
return
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
TDMT_VND_ALTER_CONFIG
);
static
int32_t
mndCheckDnodeMemory
(
SMnode
*
pMnode
,
SDbObj
*
pOldDb
,
SDbObj
*
pNewDb
,
SVgObj
*
pOldVgroup
,
SVgObj
*
pNewVgroup
,
SArray
*
pArray
)
{
for
(
int32_t
i
=
0
;
i
<
(
int32_t
)
taosArrayGetSize
(
pArray
);
++
i
)
{
SDnodeObj
*
pDnode
=
taosArrayGet
(
pArray
,
i
);
bool
inVgroup
=
false
;
for
(
int32_t
j
=
0
;
j
<
pOldVgroup
->
replica
;
++
j
)
{
SVnodeGid
*
pVgId
=
&
pOldVgroup
->
vnodeGid
[
i
];
if
(
pDnode
->
id
==
pVgId
->
dnodeId
)
{
pDnode
->
memUsed
-=
mndGetVgroupMemory
(
pMnode
,
pOldDb
,
pOldVgroup
);
inVgroup
=
true
;
}
}
for
(
int32_t
j
=
0
;
j
<
pNewVgroup
->
replica
;
++
j
)
{
SVnodeGid
*
pVgId
=
&
pNewVgroup
->
vnodeGid
[
i
];
if
(
pDnode
->
id
==
pVgId
->
dnodeId
)
{
pDnode
->
memUsed
+=
mndGetVgroupMemory
(
pMnode
,
pNewDb
,
pNewVgroup
);
inVgroup
=
true
;
}
}
if
(
pDnode
->
memAvail
-
pDnode
->
memUsed
<=
0
)
{
mError
(
"db:%s, vgId:%d, no enough memory in dnode:%d, avail:%"
PRId64
" used:%"
PRId64
,
pNewVgroup
->
dbName
,
pNewVgroup
->
vgId
,
pDnode
->
id
,
pDnode
->
memAvail
,
pDnode
->
memUsed
);
terrno
=
TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE
;
return
-
1
;
}
else
if
(
inVgroup
)
{
mInfo
(
"db:%s, vgId:%d, memory in dnode:%d, avail:%"
PRId64
" used:%"
PRId64
,
pNewVgroup
->
dbName
,
pNewVgroup
->
vgId
,
pDnode
->
id
,
pDnode
->
memAvail
,
pDnode
->
memUsed
);
}
else
{
}
}
return
0
;
}
int32_t
mndBuildAlterVgroupAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pOldDb
,
SDbObj
*
pNewDb
,
SVgObj
*
pVgroup
,
SArray
*
pArray
)
{
SVgObj
newVgroup
=
{
0
};
memcpy
(
&
newVgroup
,
pVgroup
,
sizeof
(
SVgObj
));
if
(
pVgroup
->
replica
<=
0
||
pVgroup
->
replica
==
pNewDb
->
cfg
.
replications
)
{
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
pNewDb
,
pVgroup
,
TDMT_VND_ALTER_CONFIG
)
!=
0
)
return
-
1
;
if
(
mndCheckDnodeMemory
(
pMnode
,
pOldDb
,
pNewDb
,
&
newVgroup
,
pVgroup
,
pArray
)
!=
0
)
return
-
1
;
return
0
;
}
mndTransSetSerial
(
pTrans
);
if
(
newVgroup
.
replica
<
pDb
->
cfg
.
replications
)
{
if
(
newVgroup
.
replica
<
p
New
Db
->
cfg
.
replications
)
{
mInfo
(
"db:%s, vgId:%d, vn:0 dnode:%d, will add 2 vnodes"
,
pVgroup
->
dbName
,
pVgroup
->
vgId
,
pVgroup
->
vnodeGid
[
0
].
dnodeId
);
if
(
mndAddVnodeToVgroup
(
pMnode
,
&
newVgroup
,
pArray
)
!=
0
)
return
-
1
;
if
(
mndAddCreateVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
,
&
newVgroup
.
vnodeGid
[
1
],
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
,
TDMT_VND_ALTER_REPLICA
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
)
!=
0
)
return
-
1
;
if
(
mndAddCreateVnodeAction
(
pMnode
,
pTrans
,
p
New
Db
,
&
newVgroup
,
&
newVgroup
.
vnodeGid
[
1
],
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
p
New
Db
,
&
newVgroup
,
TDMT_VND_ALTER_REPLICA
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
p
New
Db
,
&
newVgroup
)
!=
0
)
return
-
1
;
if
(
mndAddVnodeToVgroup
(
pMnode
,
&
newVgroup
,
pArray
)
!=
0
)
return
-
1
;
if
(
mndAddCreateVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
,
&
newVgroup
.
vnodeGid
[
2
],
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
,
TDMT_VND_ALTER_REPLICA
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
)
!=
0
)
return
-
1
;
}
else
if
(
newVgroup
.
replica
>
pDb
->
cfg
.
replications
)
{
if
(
mndAddCreateVnodeAction
(
pMnode
,
pTrans
,
p
New
Db
,
&
newVgroup
,
&
newVgroup
.
vnodeGid
[
2
],
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
p
New
Db
,
&
newVgroup
,
TDMT_VND_ALTER_REPLICA
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
p
New
Db
,
&
newVgroup
)
!=
0
)
return
-
1
;
}
else
if
(
newVgroup
.
replica
>
p
New
Db
->
cfg
.
replications
)
{
mInfo
(
"db:%s, vgId:%d, will remove 2 vnodes"
,
pVgroup
->
dbName
,
pVgroup
->
vgId
);
SVnodeGid
del1
=
{
0
};
if
(
mndRemoveVnodeFromVgroup
(
pMnode
,
&
newVgroup
,
pArray
,
&
del1
)
!=
0
)
return
-
1
;
if
(
mndAddSetVnodeStandByAction
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
&
del1
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
,
TDMT_VND_ALTER_REPLICA
)
!=
0
)
return
-
1
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
,
&
del1
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
)
!=
0
)
return
-
1
;
if
(
mndAddSetVnodeStandByAction
(
pMnode
,
pTrans
,
p
New
Db
,
pVgroup
,
&
del1
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
p
New
Db
,
&
newVgroup
,
TDMT_VND_ALTER_REPLICA
)
!=
0
)
return
-
1
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
p
New
Db
,
&
newVgroup
,
&
del1
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
p
New
Db
,
&
newVgroup
)
!=
0
)
return
-
1
;
SVnodeGid
del2
=
{
0
};
if
(
mndRemoveVnodeFromVgroup
(
pMnode
,
&
newVgroup
,
pArray
,
&
del2
)
!=
0
)
return
-
1
;
if
(
mndAddSetVnodeStandByAction
(
pMnode
,
pTrans
,
pDb
,
pVgroup
,
&
del2
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
,
TDMT_VND_ALTER_REPLICA
)
!=
0
)
return
-
1
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
,
&
del2
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
&
newVgroup
)
!=
0
)
return
-
1
;
if
(
mndAddSetVnodeStandByAction
(
pMnode
,
pTrans
,
p
New
Db
,
pVgroup
,
&
del2
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
p
New
Db
,
&
newVgroup
,
TDMT_VND_ALTER_REPLICA
)
!=
0
)
return
-
1
;
if
(
mndAddDropVnodeAction
(
pMnode
,
pTrans
,
p
New
Db
,
&
newVgroup
,
&
del2
,
true
)
!=
0
)
return
-
1
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
p
New
Db
,
&
newVgroup
)
!=
0
)
return
-
1
;
}
else
{
}
...
...
@@ -1648,8 +1685,8 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
if
(
mndAddAlterVnodeAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg2
,
TDMT_VND_ALTER_HASHRANGE
)
!=
0
)
goto
_OVER
;
// adjust vgroup
if
(
mndBuildAlterVgroupAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
,
pArray
)
!=
0
)
goto
_OVER
;
if
(
mndBuildAlterVgroupAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg2
,
pArray
)
!=
0
)
goto
_OVER
;
if
(
mndBuildAlterVgroupAction
(
pMnode
,
pTrans
,
pDb
,
pDb
,
&
newVg1
,
pArray
)
!=
0
)
goto
_OVER
;
if
(
mndBuildAlterVgroupAction
(
pMnode
,
pTrans
,
pDb
,
pDb
,
&
newVg2
,
pArray
)
!=
0
)
goto
_OVER
;
_OVER:
mndTransDrop
(
pTrans
);
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
dbae9a47
...
...
@@ -1024,71 +1024,75 @@ static int32_t vnodeProcessAlterHashRangeReq(SVnode *pVnode, int64_t version, vo
}
static
int32_t
vnodeProcessAlterConfigReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
)
{
SAlterVnodeReq
alterR
eq
=
{
0
};
SAlterVnodeReq
r
eq
=
{
0
};
bool
walChanged
=
false
;
bool
tsdbChanged
=
false
;
if
(
tDeserializeSAlterVnodeReq
(
pReq
,
len
,
&
alterR
eq
)
!=
0
)
{
if
(
tDeserializeSAlterVnodeReq
(
pReq
,
len
,
&
r
eq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
TSDB_CODE_INVALID_MSG
;
}
vInfo
(
"vgId:%d, start to alter vnode config, cacheLast:%d cacheLastSize:%d"
,
TD_VID
(
pVnode
),
alterReq
.
cacheLast
,
alterReq
.
cacheLastSize
);
if
(
pVnode
->
config
.
cacheLastSize
!=
alterReq
.
cacheLastSize
)
{
pVnode
->
config
.
cacheLastSize
=
alterReq
.
cacheLastSize
;
vInfo
(
"vgId:%d, start to alter vnode config, page:%d pageSize:%d buffer:%d szPage:%d szBuf:%"
PRIu64
" cacheLast:%d cacheLastSize:%d days:%d keep0:%d keep1:%d keep2:%d fsync:%d level:%d strict:%d"
,
TD_VID
(
pVnode
),
req
.
pages
,
req
.
pageSize
,
req
.
buffer
,
req
.
pageSize
*
1024
,
(
uint64_t
)
req
.
buffer
*
1024
*
1024
,
req
.
cacheLast
,
req
.
cacheLastSize
,
req
.
daysPerFile
,
req
.
daysToKeep0
,
req
.
daysToKeep1
,
req
.
daysToKeep2
,
req
.
walFsyncPeriod
,
req
.
walLevel
,
req
.
strict
);
if
(
pVnode
->
config
.
cacheLastSize
!=
req
.
cacheLastSize
)
{
pVnode
->
config
.
cacheLastSize
=
req
.
cacheLastSize
;
tsdbCacheSetCapacity
(
pVnode
,
(
size_t
)
pVnode
->
config
.
cacheLastSize
*
1024
*
1024
);
}
if
(
pVnode
->
config
.
szBuf
!=
alterR
eq
.
buffer
*
1024LL
*
1024LL
)
{
if
(
pVnode
->
config
.
szBuf
!=
r
eq
.
buffer
*
1024LL
*
1024LL
)
{
vInfo
(
"vgId:%d vnode buffer is changed from %"
PRId64
" to %"
PRId64
,
TD_VID
(
pVnode
),
pVnode
->
config
.
szBuf
,
alterR
eq
.
buffer
*
1024LL
*
1024LL
);
pVnode
->
config
.
szBuf
=
alterR
eq
.
buffer
*
1024LL
*
1024LL
;
r
eq
.
buffer
*
1024LL
*
1024LL
);
pVnode
->
config
.
szBuf
=
r
eq
.
buffer
*
1024LL
*
1024LL
;
}
if
(
pVnode
->
config
.
szCache
!=
alterR
eq
.
pages
)
{
if
(
metaAlterCache
(
pVnode
->
pMeta
,
alterR
eq
.
pages
)
<
0
)
{
if
(
pVnode
->
config
.
szCache
!=
r
eq
.
pages
)
{
if
(
metaAlterCache
(
pVnode
->
pMeta
,
r
eq
.
pages
)
<
0
)
{
vError
(
"vgId:%d failed to change vnode pages from %d to %d failed since %s"
,
TD_VID
(
pVnode
),
pVnode
->
config
.
szCache
,
alterR
eq
.
pages
,
tstrerror
(
errno
));
pVnode
->
config
.
szCache
,
r
eq
.
pages
,
tstrerror
(
errno
));
return
errno
;
}
else
{
vInfo
(
"vgId:%d vnode pages is changed from %d to %d"
,
TD_VID
(
pVnode
),
pVnode
->
config
.
szCache
,
alterR
eq
.
pages
);
pVnode
->
config
.
szCache
=
alterR
eq
.
pages
;
vInfo
(
"vgId:%d vnode pages is changed from %d to %d"
,
TD_VID
(
pVnode
),
pVnode
->
config
.
szCache
,
r
eq
.
pages
);
pVnode
->
config
.
szCache
=
r
eq
.
pages
;
}
}
if
(
pVnode
->
config
.
cacheLast
!=
alterR
eq
.
cacheLast
)
{
pVnode
->
config
.
cacheLast
=
alterR
eq
.
cacheLast
;
if
(
pVnode
->
config
.
cacheLast
!=
r
eq
.
cacheLast
)
{
pVnode
->
config
.
cacheLast
=
r
eq
.
cacheLast
;
}
if
(
pVnode
->
config
.
walCfg
.
fsyncPeriod
!=
alterR
eq
.
walFsyncPeriod
)
{
pVnode
->
config
.
walCfg
.
fsyncPeriod
=
alterR
eq
.
walFsyncPeriod
;
if
(
pVnode
->
config
.
walCfg
.
fsyncPeriod
!=
r
eq
.
walFsyncPeriod
)
{
pVnode
->
config
.
walCfg
.
fsyncPeriod
=
r
eq
.
walFsyncPeriod
;
walChanged
=
true
;
}
if
(
pVnode
->
config
.
walCfg
.
level
!=
alterR
eq
.
walLevel
)
{
pVnode
->
config
.
walCfg
.
level
=
alterR
eq
.
walLevel
;
if
(
pVnode
->
config
.
walCfg
.
level
!=
r
eq
.
walLevel
)
{
pVnode
->
config
.
walCfg
.
level
=
r
eq
.
walLevel
;
walChanged
=
true
;
}
if
(
pVnode
->
config
.
tsdbCfg
.
keep0
!=
alterR
eq
.
daysToKeep0
)
{
pVnode
->
config
.
tsdbCfg
.
keep0
=
alterR
eq
.
daysToKeep0
;
if
(
pVnode
->
config
.
tsdbCfg
.
keep0
!=
r
eq
.
daysToKeep0
)
{
pVnode
->
config
.
tsdbCfg
.
keep0
=
r
eq
.
daysToKeep0
;
if
(
!
VND_IS_RSMA
(
pVnode
))
{
tsdbChanged
=
true
;
}
}
if
(
pVnode
->
config
.
tsdbCfg
.
keep1
!=
alterR
eq
.
daysToKeep1
)
{
pVnode
->
config
.
tsdbCfg
.
keep1
=
alterR
eq
.
daysToKeep1
;
if
(
pVnode
->
config
.
tsdbCfg
.
keep1
!=
r
eq
.
daysToKeep1
)
{
pVnode
->
config
.
tsdbCfg
.
keep1
=
r
eq
.
daysToKeep1
;
if
(
!
VND_IS_RSMA
(
pVnode
))
{
tsdbChanged
=
true
;
}
}
if
(
pVnode
->
config
.
tsdbCfg
.
keep2
!=
alterR
eq
.
daysToKeep2
)
{
pVnode
->
config
.
tsdbCfg
.
keep2
=
alterR
eq
.
daysToKeep2
;
if
(
pVnode
->
config
.
tsdbCfg
.
keep2
!=
r
eq
.
daysToKeep2
)
{
pVnode
->
config
.
tsdbCfg
.
keep2
=
r
eq
.
daysToKeep2
;
if
(
!
VND_IS_RSMA
(
pVnode
))
{
tsdbChanged
=
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录