Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f5d998ee
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
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,发现更多精彩内容 >>
提交
f5d998ee
编写于
1月 17, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into feature/vnode
上级
32d2b1cc
66f54097
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
141 addition
and
182 deletion
+141
-182
include/common/tmsg.h
include/common/tmsg.h
+1
-1
source/dnode/mgmt/impl/src/dndVnodes.c
source/dnode/mgmt/impl/src/dndVnodes.c
+4
-0
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+38
-32
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+98
-149
未找到文件。
include/common/tmsg.h
浏览文件 @
f5d998ee
...
...
@@ -1332,7 +1332,7 @@ typedef struct {
typedef
struct
{
SMsgHead
head
;
char
name
[
TSDB_TABLE_FNAME_LEN
];
int
8_t
ignoreNotExists
;
int
64_t
suid
;
}
SVDropTbReq
;
typedef
struct
{
...
...
source/dnode/mgmt/impl/src/dndVnodes.c
浏览文件 @
f5d998ee
...
...
@@ -421,6 +421,10 @@ static int32_t dndOpenVnodes(SDnode *pDnode) {
pMgmt
->
totalVnodes
=
numOfVnodes
;
int32_t
threadNum
=
pDnode
->
env
.
numOfCores
;
#if 1
threadNum
=
1
;
#endif
int32_t
vnodesPerThread
=
numOfVnodes
/
threadNum
+
1
;
SVnodeThread
*
threads
=
calloc
(
threadNum
,
sizeof
(
SVnodeThread
));
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
f5d998ee
...
...
@@ -179,7 +179,12 @@ static void mndCancelGetNextConn(SMnode *pMnode, void *pIter) {
}
static
int32_t
mndProcessConnectReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMnode
*
pMnode
=
pReq
->
pMnode
;
SUserObj
*
pUser
=
NULL
;
SDbObj
*
pDb
=
NULL
;
SConnObj
*
pConn
=
NULL
;
int32_t
code
=
-
1
;
SConnectReq
*
pConnReq
=
pReq
->
rpcMsg
.
pCont
;
pConnReq
->
pid
=
htonl
(
pConnReq
->
pid
);
pConnReq
->
startTime
=
htobe64
(
pConnReq
->
startTime
);
...
...
@@ -187,54 +192,61 @@ static int32_t mndProcessConnectReq(SMnodeMsg *pReq) {
SRpcConnInfo
info
=
{
0
};
if
(
rpcGetConnInfo
(
pReq
->
rpcMsg
.
handle
,
&
info
)
!=
0
)
{
mError
(
"user:%s, failed to login while get connection info since %s"
,
pReq
->
user
,
terrstr
());
return
-
1
;
goto
CONN_OVER
;
}
char
ip
[
30
];
taosIp2String
(
info
.
clientIp
,
ip
);
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
pUser
==
NULL
)
{
mError
(
"user:%s, failed to login while acquire user since %s"
,
pReq
->
user
,
terrstr
());
goto
CONN_OVER
;
}
if
(
pConnReq
->
db
[
0
])
{
snprintf
(
pReq
->
db
,
TSDB_DB_FNAME_LEN
,
"%d%s%s"
,
p
Req
->
acctId
,
TS_PATH_DELIMITER
,
pConnReq
->
db
);
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
pReq
->
db
);
snprintf
(
pReq
->
db
,
TSDB_DB_FNAME_LEN
,
"%d%s%s"
,
p
User
->
acctId
,
TS_PATH_DELIMITER
,
pConnReq
->
db
);
pDb
=
mndAcquireDb
(
pMnode
,
pReq
->
db
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_DB
;
mError
(
"user:%s, failed to login from %s while use db:%s since %s"
,
pReq
->
user
,
ip
,
pConnReq
->
db
,
terrstr
());
return
-
1
;
goto
CONN_OVER
;
}
mndReleaseDb
(
pMnode
,
pDb
);
}
SConnObj
*
pConn
=
mndCreateConn
(
pMnode
,
&
info
,
pConnReq
->
pid
,
pConnReq
->
app
,
pConnReq
->
startTime
);
pConn
=
mndCreateConn
(
pMnode
,
&
info
,
pConnReq
->
pid
,
pConnReq
->
app
,
pConnReq
->
startTime
);
if
(
pConn
==
NULL
)
{
mError
(
"user:%s, failed to login from %s while create connection since %s"
,
pReq
->
user
,
ip
,
terrstr
());
return
-
1
;
goto
CONN_OVER
;
}
SConnectRsp
*
pRsp
=
rpcMallocCont
(
sizeof
(
SConnectRsp
));
if
(
pRsp
==
NULL
)
{
mndReleaseConn
(
pMnode
,
pConn
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mError
(
"user:%s, failed to login from %s while create rsp since %s"
,
pReq
->
user
,
ip
,
terrstr
());
return
-
1
;
}
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
pUser
!=
NULL
)
{
pRsp
->
acctId
=
htonl
(
pUser
->
acctId
);
pRsp
->
superUser
=
pUser
->
superUser
;
mndReleaseUser
(
pMnode
,
pUser
);
goto
CONN_OVER
;
}
pRsp
->
acctId
=
htonl
(
pUser
->
acctId
);
pRsp
->
superUser
=
pUser
->
superUser
;
pRsp
->
clusterId
=
htobe64
(
pMnode
->
clusterId
);
pRsp
->
connId
=
htonl
(
pConn
->
id
);
mndGetMnodeEpSet
(
pMnode
,
&
pRsp
->
epSet
);
mndReleaseConn
(
pMnode
,
pConn
);
pReq
->
contLen
=
sizeof
(
SConnectRsp
);
pReq
->
pCont
=
pRsp
;
mDebug
(
"user:%s, login from %s, conn:%d, app:%s"
,
info
.
user
,
ip
,
pConn
->
id
,
pConnReq
->
app
);
return
0
;
code
=
0
;
CONN_OVER:
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseConn
(
pMnode
,
pConn
);
return
code
;
}
static
int32_t
mndSaveQueryStreamList
(
SConnObj
*
pConn
,
SHeartBeatReq
*
pReq
)
{
...
...
@@ -258,33 +270,27 @@ static int32_t mndSaveQueryStreamList(SConnObj *pConn, SHeartBeatReq *pReq) {
}
static
int32_t
mndProcessHeartBeatReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
char
*
batchReqStr
=
pReq
->
rpcMsg
.
pCont
;
SMnode
*
pMnode
=
pReq
->
pMnode
;
char
*
batchReqStr
=
pReq
->
rpcMsg
.
pCont
;
SClientHbBatchReq
batchReq
=
{
0
};
tDeserializeSClientHbBatchReq
(
batchReqStr
,
&
batchReq
);
SArray
*
pArray
=
batchReq
.
reqs
;
int
sz
=
taosArrayGetSize
(
pArray
);
int
sz
=
taosArrayGetSize
(
pArray
);
SClientHbBatchRsp
batchRsp
=
{
0
};
batchRsp
.
rsps
=
taosArrayInit
(
0
,
sizeof
(
SClientHbRsp
));
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
SClientHbReq
*
pHbReq
=
taosArrayGet
(
pArray
,
i
);
SClientHbReq
*
pHbReq
=
taosArrayGet
(
pArray
,
i
);
if
(
pHbReq
->
connKey
.
hbType
==
HEARTBEAT_TYPE_QUERY
)
{
}
else
if
(
pHbReq
->
connKey
.
hbType
==
HEARTBEAT_TYPE_MQ
)
{
SClientHbRsp
rsp
=
{
.
status
=
0
,
.
connKey
=
pHbReq
->
connKey
,
.
bodyLen
=
0
,
.
body
=
NULL
};
SClientHbRsp
rsp
=
{.
status
=
0
,
.
connKey
=
pHbReq
->
connKey
,
.
bodyLen
=
0
,
.
body
=
NULL
};
taosArrayPush
(
batchRsp
.
rsps
,
&
rsp
);
}
}
int32_t
tlen
=
tSerializeSClientHbBatchRsp
(
NULL
,
&
batchRsp
);
void
*
buf
=
rpcMallocCont
(
tlen
);
void
*
bufCopy
=
buf
;
void
*
buf
=
rpcMallocCont
(
tlen
);
void
*
bufCopy
=
buf
;
tSerializeSClientHbBatchRsp
(
&
bufCopy
,
&
batchRsp
);
pReq
->
contLen
=
tlen
;
pReq
->
pCont
=
buf
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
f5d998ee
...
...
@@ -31,16 +31,16 @@ static SSdbRaw *mndStbActionEncode(SStbObj *pStb);
static
SSdbRow
*
mndStbActionDecode
(
SSdbRaw
*
pRaw
);
static
int32_t
mndStbActionInsert
(
SSdb
*
pSdb
,
SStbObj
*
pStb
);
static
int32_t
mndStbActionDelete
(
SSdb
*
pSdb
,
SStbObj
*
pStb
);
static
int32_t
mndStbActionUpdate
(
SSdb
*
pSdb
,
SStbObj
*
pOld
Stb
,
SStbObj
*
pNewStb
);
static
int32_t
mndProces
SMCreateStbReq
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProces
SMAlterStbReq
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProces
SMDropStbReq
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcess
CreateStbInRsp
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcess
AlterStbInRsp
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcess
DropStbInRsp
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndProcessStbMeta
Msg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mndGetStbMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
);
static
int32_t
mndRetrieveStb
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndStbActionUpdate
(
SSdb
*
pSdb
,
SStbObj
*
pOld
,
SStbObj
*
pNew
);
static
int32_t
mndProces
sMCreateStbReq
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProces
sMAlterStbReq
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProces
sMDropStbReq
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcess
VCreateStbRsp
(
SMnodeMsg
*
pRsp
);
static
int32_t
mndProcess
VAlterStbRsp
(
SMnodeMsg
*
pRsp
);
static
int32_t
mndProcess
VDropStbRsp
(
SMnodeMsg
*
pRsp
);
static
int32_t
mndProcessStbMeta
Req
(
SMnodeMsg
*
pReq
);
static
int32_t
mndGetStbMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
);
static
int32_t
mndRetrieveStb
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextStb
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitStb
(
SMnode
*
pMnode
)
{
...
...
@@ -52,13 +52,13 @@ int32_t mndInitStb(SMnode *pMnode) {
.
updateFp
=
(
SdbUpdateFp
)
mndStbActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndStbActionDelete
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_STB
,
mndProces
S
MCreateStbReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_STB
,
mndProces
S
MAlterStbReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_STB
,
mndProces
S
MDropStbReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_CREATE_STB_RSP
,
mndProcess
CreateStbIn
Rsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_ALTER_STB_RSP
,
mndProcess
AlterStbIn
Rsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_DROP_STB_RSP
,
mndProcess
DropStbIn
Rsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_STB_META
,
mndProcessStbMeta
Msg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_STB
,
mndProces
s
MCreateStbReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_STB
,
mndProces
s
MAlterStbReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_STB
,
mndProces
s
MDropStbReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_CREATE_STB_RSP
,
mndProcess
VCreateStb
Rsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_ALTER_STB_RSP
,
mndProcess
VAlterStb
Rsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_DROP_STB_RSP
,
mndProcess
VDropStb
Rsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_STB_META
,
mndProcessStbMeta
Req
);
mndAddShowMetaHandle
(
pMnode
,
TSDB_MGMT_TABLE_STB
,
mndGetStbMeta
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_STB
,
mndRetrieveStb
);
...
...
@@ -177,27 +177,27 @@ static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb) {
return
0
;
}
static
int32_t
mndStbActionUpdate
(
SSdb
*
pSdb
,
SStbObj
*
pOld
Stb
,
SStbObj
*
pNewStb
)
{
mTrace
(
"stb:%s, perform update action, old row:%p new row:%p"
,
pOld
Stb
->
name
,
pOldStb
,
pNewStb
);
atomic_exchange_32
(
&
pOld
Stb
->
updateTime
,
pNewStb
->
updateTime
);
atomic_exchange_32
(
&
pOld
Stb
->
version
,
pNewStb
->
version
);
static
int32_t
mndStbActionUpdate
(
SSdb
*
pSdb
,
SStbObj
*
pOld
,
SStbObj
*
pNew
)
{
mTrace
(
"stb:%s, perform update action, old row:%p new row:%p"
,
pOld
->
name
,
pOld
,
pNew
);
atomic_exchange_32
(
&
pOld
->
updateTime
,
pNew
->
updateTime
);
atomic_exchange_32
(
&
pOld
->
version
,
pNew
->
version
);
taosWLockLatch
(
&
pOld
Stb
->
lock
);
pOld
Stb
->
numOfColumns
=
pNewStb
->
numOfColumns
;
pOld
Stb
->
numOfTags
=
pNewStb
->
numOfTags
;
int32_t
totalCols
=
pNew
Stb
->
numOfTags
+
pNewStb
->
numOfColumns
;
taosWLockLatch
(
&
pOld
->
lock
);
pOld
->
numOfColumns
=
pNew
->
numOfColumns
;
pOld
->
numOfTags
=
pNew
->
numOfTags
;
int32_t
totalCols
=
pNew
->
numOfTags
+
pNew
->
numOfColumns
;
int32_t
totalSize
=
totalCols
*
sizeof
(
SSchema
);
if
(
pOld
Stb
->
numOfTags
+
pOldStb
->
numOfColumns
<
totalCols
)
{
if
(
pOld
->
numOfTags
+
pOld
->
numOfColumns
<
totalCols
)
{
void
*
pSchema
=
malloc
(
totalSize
);
if
(
pSchema
!=
NULL
)
{
free
(
pOld
Stb
->
pSchema
);
pOld
Stb
->
pSchema
=
pSchema
;
free
(
pOld
->
pSchema
);
pOld
->
pSchema
=
pSchema
;
}
}
memcpy
(
pOld
Stb
->
pSchema
,
pNewStb
->
pSchema
,
totalSize
);
taosWUnLockLatch
(
&
pOld
Stb
->
lock
);
memcpy
(
pOld
->
pSchema
,
pNew
->
pSchema
,
totalSize
);
taosWUnLockLatch
(
&
pOld
->
lock
);
return
0
;
}
...
...
@@ -215,7 +215,7 @@ void mndReleaseStb(SMnode *pMnode, SStbObj *pStb) {
sdbRelease
(
pSdb
,
pStb
);
}
static
SDbObj
*
mndAcquireDbByStb
(
SMnode
*
pMnode
,
char
*
stbName
)
{
static
SDbObj
*
mndAcquireDbByStb
(
SMnode
*
pMnode
,
c
onst
c
har
*
stbName
)
{
SName
name
=
{
0
};
tNameFromString
(
&
name
,
stbName
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
...
...
@@ -225,17 +225,17 @@ static SDbObj *mndAcquireDbByStb(SMnode *pMnode, char *stbName) {
return
mndAcquireDb
(
pMnode
,
db
);
}
static
void
*
mndBuildCreateStb
Msg
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
in
t
*
pContLen
)
{
static
void
*
mndBuildCreateStb
Req
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_
t
*
pContLen
)
{
SVCreateTbReq
req
;
void
*
buf
;
int
bsize
;
int
32_t
bsize
;
SMsgHead
*
pMsgHead
;
req
.
ver
=
0
;
SName
name
=
{
0
};
tNameFromString
(
&
name
,
pStb
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
tNameFromString
(
&
name
,
pStb
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
req
.
name
=
(
char
*
)
tNameGetTableName
(
&
name
);
req
.
name
=
(
char
*
)
tNameGetTableName
(
&
name
);
req
.
ttl
=
0
;
req
.
keep
=
0
;
req
.
type
=
TD_SUPER_TABLE
;
...
...
@@ -264,7 +264,7 @@ static void *mndBuildCreateStbMsg(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb
return
buf
;
}
static
SVDropTbReq
*
mndBuildDropStb
Msg
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
)
{
static
SVDropTbReq
*
mndBuildDropStb
Req
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
)
{
int32_t
contLen
=
sizeof
(
SVDropTbReq
);
SVDropTbReq
*
pDrop
=
calloc
(
1
,
contLen
);
...
...
@@ -276,12 +276,12 @@ static SVDropTbReq *mndBuildDropStbMsg(SMnode *pMnode, SVgObj *pVgroup, SStbObj
pDrop
->
head
.
contLen
=
htonl
(
contLen
);
pDrop
->
head
.
vgId
=
htonl
(
pVgroup
->
vgId
);
memcpy
(
pDrop
->
name
,
pStb
->
name
,
TSDB_TABLE_FNAME_LEN
);
//
pDrop->suid = htobe64(pStb->uid);
pDrop
->
suid
=
htobe64
(
pStb
->
uid
);
return
pDrop
;
}
static
int32_t
mndCheckCreateStb
Msg
(
SMCreateStbReq
*
pCreate
)
{
static
int32_t
mndCheckCreateStb
Req
(
SMCreateStbReq
*
pCreate
)
{
pCreate
->
numOfColumns
=
htonl
(
pCreate
->
numOfColumns
);
pCreate
->
numOfTags
=
htonl
(
pCreate
->
numOfTags
);
int32_t
totalCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
...
...
@@ -356,15 +356,15 @@ static int32_t mndSetCreateStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SVgObj
*
pVgroup
=
NULL
;
void
*
pIter
=
NULL
;
int
contLen
;
int
32_t
contLen
;
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
if
(
pVgroup
->
dbUid
!=
pDb
->
uid
)
continue
;
void
*
p
Msg
=
mndBuildCreateStbMsg
(
pMnode
,
pVgroup
,
pStb
,
&
contLen
);
if
(
p
Msg
==
NULL
)
{
void
*
p
Req
=
mndBuildCreateStbReq
(
pMnode
,
pVgroup
,
pStb
,
&
contLen
);
if
(
p
Req
==
NULL
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -373,11 +373,11 @@ static int32_t mndSetCreateStbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
contLen
;
action
.
msgType
=
TDMT_VND_CREATE_STB
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
return
-
1
;
...
...
@@ -398,8 +398,8 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
if
(
pIter
==
NULL
)
break
;
if
(
pVgroup
->
dbUid
!=
pDb
->
uid
)
continue
;
SVDropTbReq
*
p
Msg
=
mndBuildDropStbMsg
(
pMnode
,
pVgroup
,
pStb
);
if
(
p
Msg
==
NULL
)
{
SVDropTbReq
*
p
Req
=
mndBuildDropStbReq
(
pMnode
,
pVgroup
,
pStb
);
if
(
p
Req
==
NULL
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -408,11 +408,11 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SVDropTbReq
);
action
.
msgType
=
TDMT_VND_DROP_STB
;
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
return
-
1
;
...
...
@@ -423,7 +423,7 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
return
0
;
}
static
int32_t
mndCreateStb
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SMCreateStbReq
*
pCreate
,
SDbObj
*
pDb
)
{
static
int32_t
mndCreateStb
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SMCreateStbReq
*
pCreate
,
SDbObj
*
pDb
)
{
SStbObj
stbObj
=
{
0
};
tstrncpy
(
stbObj
.
name
,
pCreate
->
name
,
TSDB_TABLE_FNAME_LEN
);
tstrncpy
(
stbObj
.
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
...
...
@@ -449,43 +449,17 @@ static int32_t mndCreateStb(SMnode *pMnode, SMnodeMsg *pMsg, SMCreateStbReq *pCr
}
int32_t
code
=
0
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
pMsg
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
mError
(
"stb:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to create stb:%s"
,
pTrans
->
id
,
pCreate
->
name
);
if
(
mndSetCreateStbRedoLogs
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo log since %s"
,
pTrans
->
id
,
terrstr
());
goto
CREATE_STB_OVER
;
}
if
(
mndSetCreateStbUndoLogs
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set undo log since %s"
,
pTrans
->
id
,
terrstr
());
goto
CREATE_STB_OVER
;
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
CREATE_STB_OVER
;
if
(
mndSetCreateStbCommitLogs
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set commit log since %s"
,
pTrans
->
id
,
terrstr
());
goto
CREATE_STB_OVER
;
}
if
(
mndSetCreateStbRedoActions
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo actions since %s"
,
pTrans
->
id
,
terrstr
());
goto
CREATE_STB_OVER
;
}
if
(
mndSetCreateStbUndoActions
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo actions since %s"
,
pTrans
->
id
,
terrstr
());
goto
CREATE_STB_OVER
;
}
mDebug
(
"trans:%d, used to create stb:%s"
,
pTrans
->
id
,
pCreate
->
name
);
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
if
(
mndSetCreateStbRedoLogs
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
goto
CREATE_STB_OVER
;
if
(
mndSetCreateStbUndoLogs
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
goto
CREATE_STB_OVER
;
if
(
mndSetCreateStbCommitLogs
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
goto
CREATE_STB_OVER
;
if
(
mndSetCreateStbRedoActions
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
goto
CREATE_STB_OVER
;
if
(
mndSetCreateStbUndoActions
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
!=
0
)
goto
CREATE_STB_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
CREATE_STB_OVER
;
code
=
0
;
...
...
@@ -494,13 +468,13 @@ CREATE_STB_OVER:
return
code
;
}
static
int32_t
mndProces
SMCreateStbReq
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMCreateStbReq
*
pCreate
=
p
Msg
->
rpcMsg
.
pCont
;
static
int32_t
mndProces
sMCreateStbReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMCreateStbReq
*
pCreate
=
p
Req
->
rpcMsg
.
pCont
;
mDebug
(
"stb:%s, start to create"
,
pCreate
->
name
);
if
(
mndCheckCreateStb
Msg
(
pCreate
)
!=
0
)
{
if
(
mndCheckCreateStb
Req
(
pCreate
)
!=
0
)
{
mError
(
"stb:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
...
...
@@ -536,7 +510,7 @@ static int32_t mndProcesSMCreateStbReq(SMnodeMsg *pMsg) {
return
-
1
;
}
int32_t
code
=
mndCreateStb
(
pMnode
,
p
Msg
,
pCreate
,
pDb
);
int32_t
code
=
mndCreateStb
(
pMnode
,
p
Req
,
pCreate
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
if
(
code
!=
0
)
{
...
...
@@ -548,12 +522,12 @@ static int32_t mndProcesSMCreateStbReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndProcess
CreateStbInRsp
(
SMnodeMsg
*
pMsg
)
{
mndTransProcessRsp
(
p
Msg
);
static
int32_t
mndProcess
VCreateStbRsp
(
SMnodeMsg
*
pRsp
)
{
mndTransProcessRsp
(
p
Rsp
);
return
0
;
}
static
int32_t
mndCheckAlterStb
Msg
(
SMAlterStbReq
*
pAlter
)
{
static
int32_t
mndCheckAlterStb
Req
(
SMAlterStbReq
*
pAlter
)
{
SSchema
*
pSchema
=
&
pAlter
->
schema
;
pSchema
->
colId
=
htonl
(
pSchema
->
colId
);
pSchema
->
bytes
=
htonl
(
pSchema
->
bytes
);
...
...
@@ -578,15 +552,15 @@ static int32_t mndCheckAlterStbMsg(SMAlterStbReq *pAlter) {
return
0
;
}
static
int32_t
mndUpdateStb
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SStbObj
*
pOldStb
,
SStbObj
*
pNewStb
)
{
return
0
;
}
static
int32_t
mndUpdateStb
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SStbObj
*
pOld
,
SStbObj
*
pNew
)
{
return
0
;
}
static
int32_t
mndProces
SMAlterStbReq
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMAlterStbReq
*
pAlter
=
p
Msg
->
rpcMsg
.
pCont
;
static
int32_t
mndProces
sMAlterStbReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMAlterStbReq
*
pAlter
=
p
Req
->
rpcMsg
.
pCont
;
mDebug
(
"stb:%s, start to alter"
,
pAlter
->
name
);
if
(
mndCheckAlterStb
Msg
(
pAlter
)
!=
0
)
{
if
(
mndCheckAlterStb
Req
(
pAlter
)
!=
0
)
{
mError
(
"stb:%s, failed to alter since %s"
,
pAlter
->
name
,
terrstr
());
return
-
1
;
}
...
...
@@ -601,7 +575,7 @@ static int32_t mndProcesSMAlterStbReq(SMnodeMsg *pMsg) {
SStbObj
stbObj
=
{
0
};
memcpy
(
&
stbObj
,
pStb
,
sizeof
(
SStbObj
));
int32_t
code
=
mndUpdateStb
(
pMnode
,
p
Msg
,
pStb
,
&
stbObj
);
int32_t
code
=
mndUpdateStb
(
pMnode
,
p
Req
,
pStb
,
&
stbObj
);
mndReleaseStb
(
pMnode
,
pStb
);
if
(
code
!=
0
)
{
...
...
@@ -612,8 +586,8 @@ static int32_t mndProcesSMAlterStbReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndProcess
AlterStbInRsp
(
SMnodeMsg
*
pMsg
)
{
mndTransProcessRsp
(
p
Msg
);
static
int32_t
mndProcess
VAlterStbRsp
(
SMnodeMsg
*
pRsp
)
{
mndTransProcessRsp
(
p
Rsp
);
return
0
;
}
...
...
@@ -648,44 +622,19 @@ static int32_t mndSetDropStbRedoActions(SMnode *pMnode, STrans *pTrans, SStbObj
static
int32_t
mndSetDropStbUndoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStbObj
*
pStb
)
{
return
0
;
}
static
int32_t
mndDropStb
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SStbObj
*
pStb
)
{
static
int32_t
mndDropStb
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SStbObj
*
pStb
)
{
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
pMsg
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
mError
(
"stb:%s, failed to drop since %s"
,
pStb
->
name
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to drop stb:%s"
,
pTrans
->
id
,
pStb
->
name
);
if
(
mndSetDropStbRedoLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo log since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_STB_OVER
;
}
if
(
mndSetDropStbUndoLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
{
mError
(
"trans:%d, failed to set undo log since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_STB_OVER
;
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
DROP_STB_OVER
;
if
(
mndSetDropStbCommitLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
{
mError
(
"trans:%d, failed to set commit log since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_STB_OVER
;
}
if
(
mndSetDropStbRedoActions
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo actions since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_STB_OVER
;
}
if
(
mndSetDropStbUndoActions
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo actions since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_STB_OVER
;
}
mDebug
(
"trans:%d, used to drop stb:%s"
,
pTrans
->
id
,
pStb
->
name
);
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_STB_OVER
;
}
if
(
mndSetDropStbRedoLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
DROP_STB_OVER
;
if
(
mndSetDropStbUndoLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
DROP_STB_OVER
;
if
(
mndSetDropStbCommitLogs
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
DROP_STB_OVER
;
if
(
mndSetDropStbRedoActions
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
DROP_STB_OVER
;
if
(
mndSetDropStbUndoActions
(
pMnode
,
pTrans
,
pStb
)
!=
0
)
goto
DROP_STB_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
DROP_STB_OVER
;
code
=
0
;
...
...
@@ -694,9 +643,9 @@ DROP_STB_OVER:
return
0
;
}
static
int32_t
mndProces
SMDropStbReq
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
pMnode
;
SMDropStbReq
*
pDrop
=
p
Msg
->
rpcMsg
.
pCont
;
static
int32_t
mndProces
sMDropStbReq
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
pMnode
;
SMDropStbReq
*
pDrop
=
p
Req
->
rpcMsg
.
pCont
;
mDebug
(
"stb:%s, start to drop"
,
pDrop
->
name
);
...
...
@@ -712,7 +661,7 @@ static int32_t mndProcesSMDropStbReq(SMnodeMsg *pMsg) {
}
}
int32_t
code
=
mndDropStb
(
pMnode
,
p
Msg
,
pStb
);
int32_t
code
=
mndDropStb
(
pMnode
,
p
Req
,
pStb
);
mndReleaseStb
(
pMnode
,
pStb
);
if
(
code
!=
0
)
{
...
...
@@ -724,14 +673,14 @@ static int32_t mndProcesSMDropStbReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndProcess
DropStbInRsp
(
SMnodeMsg
*
pMsg
)
{
mndTransProcessRsp
(
p
Msg
);
static
int32_t
mndProcess
VDropStbRsp
(
SMnodeMsg
*
pRsp
)
{
mndTransProcessRsp
(
p
Rsp
);
return
0
;
}
static
int32_t
mndProcessStbMeta
Msg
(
SMnodeMsg
*
pMsg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
STableInfoReq
*
pInfo
=
p
Msg
->
rpcMsg
.
pCont
;
static
int32_t
mndProcessStbMeta
Req
(
SMnodeMsg
*
pReq
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
STableInfoReq
*
pInfo
=
p
Req
->
rpcMsg
.
pCont
;
mDebug
(
"stb:%s, start to retrieve meta"
,
pInfo
->
tableFname
);
...
...
@@ -786,8 +735,8 @@ static int32_t mndProcessStbMetaMsg(SMnodeMsg *pMsg) {
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseStb
(
pMnode
,
pStb
);
p
Msg
->
pCont
=
pMeta
;
p
Msg
->
contLen
=
contLen
;
p
Req
->
pCont
=
pMeta
;
p
Req
->
contLen
=
contLen
;
mDebug
(
"stb:%s, meta is retrieved, cols:%d tags:%d"
,
pInfo
->
tableFname
,
pStb
->
numOfColumns
,
pStb
->
numOfTags
);
return
0
;
...
...
@@ -820,8 +769,8 @@ static int32_t mndGetNumOfStbs(SMnode *pMnode, char *dbName, int32_t *pNumOfStbs
return
0
;
}
static
int32_t
mndGetStbMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndGetStbMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaRsp
*
pMeta
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
if
(
mndGetNumOfStbs
(
pMnode
,
pShow
->
db
,
&
pShow
->
numOfRows
)
!=
0
)
{
...
...
@@ -883,8 +832,8 @@ static void mndExtractTableName(char *tableId, char *name) {
}
}
static
int32_t
mndRetrieveStb
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndRetrieveStb
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
SStbObj
*
pStb
=
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录