Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3c698b24
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看板
提交
3c698b24
编写于
5月 24, 2023
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: add mndAddPrepareNewVgAction
上级
873ad883
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
55 addition
and
12 deletion
+55
-12
source/dnode/mnode/impl/inc/mndTrans.h
source/dnode/mnode/impl/inc/mndTrans.h
+1
-1
source/dnode/mnode/impl/inc/mndVgroup.h
source/dnode/mnode/impl/inc/mndVgroup.h
+1
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+9
-1
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+2
-2
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+13
-0
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+27
-8
source/dnode/mnode/sdb/inc/sdb.h
source/dnode/mnode/sdb/inc/sdb.h
+1
-0
source/dnode/mnode/sdb/src/sdbHash.c
source/dnode/mnode/sdb/src/sdbHash.c
+1
-0
未找到文件。
source/dnode/mnode/impl/inc/mndTrans.h
浏览文件 @
3c698b24
...
...
@@ -70,7 +70,7 @@ int32_t mndTransAppendRedolog(STrans *pTrans, SSdbRaw *pRaw);
int32_t
mndTransAppendUndolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendCommitlog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendNullLog
(
STrans
*
pTrans
);
int32_t
mndTransAppendPrepareAction
(
STrans
*
pTrans
,
STransAction
*
p
Raw
);
int32_t
mndTransAppendPrepareAction
(
STrans
*
pTrans
,
STransAction
*
p
Action
);
int32_t
mndTransAppendRedoAction
(
STrans
*
pTrans
,
STransAction
*
pAction
);
int32_t
mndTransAppendUndoAction
(
STrans
*
pTrans
,
STransAction
*
pAction
);
void
mndTransSetRpcRsp
(
STrans
*
pTrans
,
void
*
pCont
,
int32_t
contLen
);
...
...
source/dnode/mnode/impl/inc/mndVgroup.h
浏览文件 @
3c698b24
...
...
@@ -36,6 +36,7 @@ int64_t mndGetVgroupMemory(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup);
SArray
*
mndBuildDnodesArray
(
SMnode
*
,
int32_t
exceptDnodeId
);
int32_t
mndAllocSmaVgroup
(
SMnode
*
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
);
int32_t
mndAllocVgroup
(
SMnode
*
,
SDbObj
*
pDb
,
SVgObj
**
ppVgroups
);
int32_t
mndAddPrepareNewVgAction
(
SMnode
*
,
STrans
*
pTrans
,
SVgObj
*
pVg
);
int32_t
mndAddCreateVnodeAction
(
SMnode
*
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
SVnodeGid
*
pVgid
);
int32_t
mndAddAlterVnodeConfirmAction
(
SMnode
*
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
);
int32_t
mndAddAlterVnodeAction
(
SMnode
*
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
tmsg_t
msgType
);
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
3c698b24
...
...
@@ -414,6 +414,13 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
if
(
pCfg
->
tsdbPageSize
<=
0
)
pCfg
->
tsdbPageSize
=
TSDB_DEFAULT_TSDB_PAGESIZE
;
}
static
int32_t
mndSetPrepareNewVgActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroups
)
{
for
(
int32_t
v
=
0
;
v
<
pDb
->
cfg
.
numOfVgroups
;
++
v
)
{
if
(
mndAddPrepareNewVgAction
(
pMnode
,
pTrans
,
(
pVgroups
+
v
))
!=
0
)
return
-
1
;
}
return
0
;
}
static
int32_t
mndSetCreateDbRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroups
)
{
SSdbRaw
*
pDbRaw
=
mndDbActionEncode
(
pDb
);
if
(
pDbRaw
==
NULL
)
return
-
1
;
...
...
@@ -424,7 +431,7 @@ static int32_t mndSetCreateDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD
SSdbRaw
*
pVgRaw
=
mndVgroupActionEncode
(
pVgroups
+
v
);
if
(
pVgRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendRedolog
(
pTrans
,
pVgRaw
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pVgRaw
,
SDB_STATUS_
CREATING
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pVgRaw
,
SDB_STATUS_
UPDATE
)
!=
0
)
return
-
1
;
}
return
0
;
...
...
@@ -575,6 +582,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
if
(
mndTransCheckConflict
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
mndTransSetOper
(
pTrans
,
MND_OPER_CREATE_DB
);
if
(
mndSetPrepareNewVgActions
(
pMnode
,
pTrans
,
&
dbObj
,
pVgroups
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateDbRedoLogs
(
pMnode
,
pTrans
,
&
dbObj
,
pVgroups
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateDbUndoLogs
(
pMnode
,
pTrans
,
&
dbObj
,
pVgroups
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateDbCommitLogs
(
pMnode
,
pTrans
,
&
dbObj
,
pVgroups
)
!=
0
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
3c698b24
...
...
@@ -388,7 +388,7 @@ static int32_t mndSetCreateSmaVgroupRedoLogs(SMnode *pMnode, STrans *pTrans, SVg
SSdbRaw
*
pVgRaw
=
mndVgroupActionEncode
(
pVgroup
);
if
(
pVgRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendRedolog
(
pTrans
,
pVgRaw
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pVgRaw
,
SDB_STATUS_
CREATING
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pVgRaw
,
SDB_STATUS_
UPDATE
)
!=
0
)
return
-
1
;
return
0
;
}
...
...
@@ -626,7 +626,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
mndTransSetSerial
(
pTrans
);
mInfo
(
"trans:%d, used to create sma:%s stream:%s"
,
pTrans
->
id
,
pCreate
->
name
,
streamObj
.
name
);
if
(
mndAddPrepareNewVgAction
(
pMnode
,
pTrans
,
&
streamObj
.
fixedSinkVg
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateSmaRedoLogs
(
pMnode
,
pTrans
,
&
smaObj
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateSmaVgroupRedoLogs
(
pMnode
,
pTrans
,
&
streamObj
.
fixedSinkVg
)
!=
0
)
goto
_OVER
;
if
(
mndSetCreateSmaCommitLogs
(
pMnode
,
pTrans
,
&
smaObj
)
!=
0
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
3c698b24
...
...
@@ -1333,6 +1333,19 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
static
bool
mndTransPerformPrepareStage
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
bool
continueExec
=
true
;
int32_t
code
=
0
;
int32_t
numOfActions
=
taosArrayGetSize
(
pTrans
->
prepareActions
);
if
(
numOfActions
==
0
)
goto
_OVER
;
mInfo
(
"trans:%d, execute %d prepare actions."
,
pTrans
->
id
,
numOfActions
);
for
(
int32_t
action
=
0
;
action
<
numOfActions
;
++
action
)
{
STransAction
*
pAction
=
taosArrayGet
(
pTrans
->
prepareActions
,
action
);
mndTransExecSingleAction
(
pMnode
,
pTrans
,
pAction
);
}
_OVER:
pTrans
->
stage
=
TRN_STAGE_REDO_ACTION
;
mInfo
(
"trans:%d, stage from prepare to redoAction"
,
pTrans
->
id
);
return
continueExec
;
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
3c698b24
...
...
@@ -483,15 +483,15 @@ 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
)
{
static
void
*
mndBuildAlterVnodeHashRangeReq
(
SMnode
*
pMnode
,
int32_t
srcVgId
,
SVgObj
*
pVgroup
,
int32_t
*
pContLen
)
{
SAlterVnodeHashRangeReq
alterReq
=
{
.
srcVgId
=
pVgroup
->
v
gId
,
.
dstVgId
=
dstV
gId
,
.
srcVgId
=
srcV
gId
,
.
dstVgId
=
pVgroup
->
v
gId
,
.
hashBegin
=
pVgroup
->
hashBegin
,
.
hashEnd
=
pVgroup
->
hashEnd
,
};
mInfo
(
"vgId:%d, build alter vnode hashrange req, dstVgId:%d, hashrange:[%u, %u]"
,
pVgroup
->
vgId
,
dstV
gId
,
mInfo
(
"vgId:%d, build alter vnode hashrange req, dstVgId:%d, hashrange:[%u, %u]"
,
srcVgId
,
pVgroup
->
v
gId
,
pVgroup
->
hashBegin
,
pVgroup
->
hashEnd
);
int32_t
contLen
=
tSerializeSAlterVnodeHashRangeReq
(
NULL
,
0
,
&
alterReq
);
if
(
contLen
<
0
)
{
...
...
@@ -1207,12 +1207,12 @@ int32_t mndAddAlterVnodeConfirmAction(SMnode *pMnode, STrans *pTrans, SDbObj *pD
return
0
;
}
static
int32_t
mndAddAlterVnodeHashRangeAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SVgObj
*
pVgroup
,
int32_t
dstVgId
)
{
static
int32_t
mndAddAlterVnodeHashRangeAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
int32_t
srcVgId
,
SVgObj
*
pVgroup
)
{
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildAlterVnodeHashRangeReq
(
pMnode
,
pVgroup
,
dstVgId
,
&
contLen
);
void
*
pReq
=
mndBuildAlterVnodeHashRangeReq
(
pMnode
,
srcVgId
,
pVgroup
,
&
contLen
);
if
(
pReq
==
NULL
)
return
-
1
;
action
.
pCont
=
pReq
;
...
...
@@ -1247,6 +1247,21 @@ int32_t mndAddAlterVnodeConfigAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb
return
0
;
}
int32_t
mndAddPrepareNewVgAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SVgObj
*
pVg
)
{
SSdbRaw
*
pRaw
=
mndVgroupActionEncode
(
pVg
);
if
(
pRaw
==
NULL
)
goto
_err
;
STransAction
action
=
{.
pRaw
=
pRaw
};
if
(
mndTransAppendPrepareAction
(
pTrans
,
&
action
)
!=
0
)
goto
_err
;
(
void
)
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_CREATING
);
pRaw
=
NULL
;
return
0
;
_err:
sdbFreeRaw
(
pRaw
);
return
-
1
;
}
int32_t
mndAddAlterVnodeReplicaAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
,
int32_t
dnodeId
)
{
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
dnodeId
);
if
(
pDnode
==
NULL
)
return
-
1
;
...
...
@@ -2313,12 +2328,16 @@ int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj *pVgro
// alter vgId and hash range
int32_t
maxVgId
=
sdbGetMaxId
(
pMnode
->
pSdb
,
SDB_VGROUP
);
i
f
(
mndAddAlterVnodeHashRangeAction
(
pMnode
,
pTrans
,
&
newVg1
,
maxVgId
)
!=
0
)
goto
_OVER
;
i
nt32_t
srcVgId
=
newVg1
.
vgId
;
newVg1
.
vgId
=
maxVgId
;
if
(
mndAddPrepareNewVgAction
(
pMnode
,
pTrans
,
&
newVg1
)
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeHashRangeAction
(
pMnode
,
pTrans
,
srcVgId
,
&
newVg1
)
!=
0
)
goto
_OVER
;
maxVgId
++
;
if
(
mndAddAlterVnodeHashRangeAction
(
pMnode
,
pTrans
,
&
newVg2
,
maxVgId
)
!=
0
)
goto
_OVER
;
srcVgId
=
newVg2
.
vgId
;
newVg2
.
vgId
=
maxVgId
;
if
(
mndAddPrepareNewVgAction
(
pMnode
,
pTrans
,
&
newVg2
)
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeHashRangeAction
(
pMnode
,
pTrans
,
srcVgId
,
&
newVg2
)
!=
0
)
goto
_OVER
;
if
(
mndAddAlterVnodeConfirmAction
(
pMnode
,
pTrans
,
pDb
,
&
newVg1
)
!=
0
)
goto
_OVER
;
...
...
source/dnode/mnode/sdb/inc/sdb.h
浏览文件 @
3c698b24
...
...
@@ -122,6 +122,7 @@ typedef enum {
SDB_STATUS_DROPPING
=
2
,
SDB_STATUS_DROPPED
=
3
,
SDB_STATUS_READY
=
4
,
SDB_STATUS_UPDATE
=
5
,
}
ESdbStatus
;
typedef
enum
{
...
...
source/dnode/mnode/sdb/src/sdbHash.c
浏览文件 @
3c698b24
...
...
@@ -256,6 +256,7 @@ int32_t sdbWriteWithoutFree(SSdb *pSdb, SSdbRaw *pRaw) {
code
=
sdbInsertRow
(
pSdb
,
hash
,
pRaw
,
pRow
,
keySize
);
break
;
case
SDB_STATUS_READY
:
case
SDB_STATUS_UPDATE
:
case
SDB_STATUS_DROPPING
:
code
=
sdbUpdateRow
(
pSdb
,
hash
,
pRaw
,
pRow
,
keySize
);
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录