Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3152824a
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看板
提交
3152824a
编写于
1月 27, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
return uid when deleting db
上级
001cab2d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
66 addition
and
16 deletion
+66
-16
include/common/tmsg.h
include/common/tmsg.h
+9
-4
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+2
-0
source/dnode/mnode/impl/inc/mndTrans.h
source/dnode/mnode/impl/inc/mndTrans.h
+3
-2
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+8
-0
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+31
-10
source/dnode/mnode/impl/test/db/db.cpp
source/dnode/mnode/impl/test/db/db.cpp
+13
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
3152824a
...
...
@@ -506,21 +506,26 @@ typedef struct {
}
SAlterDbReq
;
typedef
struct
{
char
db
[
TSDB_
TABLE
_FNAME_LEN
];
char
db
[
TSDB_
DB
_FNAME_LEN
];
int8_t
ignoreNotExists
;
}
SDropDbReq
;
typedef
struct
{
char
db
[
TSDB_TABLE_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
uint64_t
uid
;
}
SDropDbRsp
;
typedef
struct
{
char
db
[
TSDB_DB_FNAME_LEN
];
int32_t
vgVersion
;
}
SUseDbReq
;
typedef
struct
{
char
db
[
TSDB_
TABLE
_FNAME_LEN
];
char
db
[
TSDB_
DB
_FNAME_LEN
];
}
SSyncDbReq
;
typedef
struct
{
char
db
[
TSDB_
TABLE
_FNAME_LEN
];
char
db
[
TSDB_
DB
_FNAME_LEN
];
}
SCompactDbReq
;
typedef
struct
{
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
3152824a
...
...
@@ -128,6 +128,8 @@ typedef struct {
int32_t
failedTimes
;
void
*
rpcHandle
;
void
*
rpcAHandle
;
void
*
rpcRsp
;
int32_t
rpcRspLen
;
SArray
*
redoLogs
;
SArray
*
undoLogs
;
SArray
*
commitLogs
;
...
...
source/dnode/mnode/impl/inc/mndTrans.h
浏览文件 @
3152824a
...
...
@@ -36,16 +36,17 @@ typedef struct {
int32_t
mndInitTrans
(
SMnode
*
pMnode
);
void
mndCleanupTrans
(
SMnode
*
pMnode
);
STrans
*
mndTransCreate
(
SMnode
*
pMnode
,
ETrnPolicy
policy
,
SRpcMsg
*
pMsg
);
STrans
*
mndTransCreate
(
SMnode
*
pMnode
,
ETrnPolicy
policy
,
const
SRpcMsg
*
pReq
);
void
mndTransDrop
(
STrans
*
pTrans
);
int32_t
mndTransAppendRedolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendUndolog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendCommitlog
(
STrans
*
pTrans
,
SSdbRaw
*
pRaw
);
int32_t
mndTransAppendRedoAction
(
STrans
*
pTrans
,
STransAction
*
pAction
);
int32_t
mndTransAppendUndoAction
(
STrans
*
pTrans
,
STransAction
*
pAction
);
void
mndTransSetRpcRsp
(
STrans
*
pTrans
,
void
*
pCont
,
int32_t
contLen
);
int32_t
mndTransPrepare
(
SMnode
*
pMnode
,
STrans
*
pTrans
);
void
mndTransProcessRsp
(
SMnodeMsg
*
p
Msg
);
void
mndTransProcessRsp
(
SMnodeMsg
*
p
Rsp
);
void
mndTransPullup
(
SMnode
*
pMnode
);
#ifdef __cplusplus
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
3152824a
...
...
@@ -767,6 +767,14 @@ static int32_t mndDropDb(SMnode *pMnode, SMnodeMsg *pReq, SDbObj *pDb) {
if
(
mndSetDropDbRedoLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
DROP_DB_OVER
;
if
(
mndSetDropDbCommitLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
DROP_DB_OVER
;
if
(
mndSetDropDbRedoActions
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
DROP_DB_OVER
;
int32_t
rspLen
=
sizeof
(
SDropDbRsp
);
SDropDbRsp
*
pRsp
=
rpcMallocCont
(
rspLen
);
if
(
pRsp
==
NULL
)
goto
DROP_DB_OVER
;
memcpy
(
pRsp
->
db
,
pDb
->
name
,
TSDB_DB_FNAME_LEN
);
pRsp
->
uid
=
htobe64
(
pDb
->
uid
);
mndTransSetRpcRsp
(
pTrans
,
pRsp
,
rspLen
);
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
DROP_DB_OVER
;
code
=
0
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
3152824a
...
...
@@ -308,6 +308,11 @@ static void mndTransDropData(STrans *pTrans) {
mndTransDropLogs
(
pTrans
->
commitLogs
);
mndTransDropActions
(
pTrans
->
redoActions
);
mndTransDropActions
(
pTrans
->
undoActions
);
if
(
pTrans
->
rpcRsp
!=
NULL
)
{
rpcFreeCont
(
pTrans
->
rpcRsp
);
pTrans
->
rpcRsp
=
NULL
;
pTrans
->
rpcRspLen
=
0
;
}
}
static
int32_t
mndTransActionDelete
(
SSdb
*
pSdb
,
STrans
*
pTrans
)
{
...
...
@@ -339,7 +344,7 @@ void mndReleaseTrans(SMnode *pMnode, STrans *pTrans) {
sdbRelease
(
pSdb
,
pTrans
);
}
STrans
*
mndTransCreate
(
SMnode
*
pMnode
,
ETrnPolicy
policy
,
SRpcMsg
*
pMsg
)
{
STrans
*
mndTransCreate
(
SMnode
*
pMnode
,
ETrnPolicy
policy
,
const
SRpcMsg
*
pReq
)
{
STrans
*
pTrans
=
calloc
(
1
,
sizeof
(
STrans
));
if
(
pTrans
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -350,8 +355,8 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, SRpcMsg *pMsg) {
pTrans
->
id
=
sdbGetMaxId
(
pMnode
->
pSdb
,
SDB_TRANS
);
pTrans
->
stage
=
TRN_STAGE_PREPARE
;
pTrans
->
policy
=
policy
;
pTrans
->
rpcHandle
=
p
Msg
->
handle
;
pTrans
->
rpcAHandle
=
p
Msg
->
ahandle
;
pTrans
->
rpcHandle
=
p
Req
->
handle
;
pTrans
->
rpcAHandle
=
p
Req
->
ahandle
;
pTrans
->
redoLogs
=
taosArrayInit
(
MND_TRANS_ARRAY_SIZE
,
sizeof
(
void
*
));
pTrans
->
undoLogs
=
taosArrayInit
(
MND_TRANS_ARRAY_SIZE
,
sizeof
(
void
*
));
pTrans
->
commitLogs
=
taosArrayInit
(
MND_TRANS_ARRAY_SIZE
,
sizeof
(
void
*
));
...
...
@@ -436,6 +441,11 @@ int32_t mndTransAppendUndoAction(STrans *pTrans, STransAction *pAction) {
return
mndTransAppendAction
(
pTrans
->
undoActions
,
pAction
);
}
void
mndTransSetRpcRsp
(
STrans
*
pTrans
,
void
*
pCont
,
int32_t
contLen
)
{
pTrans
->
rpcRsp
=
pCont
;
pTrans
->
rpcRspLen
=
contLen
;
}
static
int32_t
mndTransSync
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
SSdbRaw
*
pRaw
=
mndTransActionEncode
(
pTrans
);
if
(
pRaw
==
NULL
)
{
...
...
@@ -479,6 +489,11 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
pNew
->
rpcHandle
=
pTrans
->
rpcHandle
;
pNew
->
rpcAHandle
=
pTrans
->
rpcAHandle
;
pNew
->
rpcRsp
=
pTrans
->
rpcRsp
;
pNew
->
rpcRspLen
=
pTrans
->
rpcRspLen
;
pTrans
->
rpcRsp
=
NULL
;
pTrans
->
rpcRspLen
=
0
;
mndTransExecute
(
pMnode
,
pNew
);
mndReleaseTrans
(
pMnode
,
pNew
);
return
0
;
...
...
@@ -529,15 +544,21 @@ static void mndTransSendRpcRsp(STrans *pTrans) {
if
(
sendRsp
&&
pTrans
->
rpcHandle
!=
NULL
)
{
mDebug
(
"trans:%d, send rsp, code:0x%x stage:%d app:%p"
,
pTrans
->
id
,
pTrans
->
code
&
0xFFFF
,
pTrans
->
stage
,
pTrans
->
rpcAHandle
);
SRpcMsg
rspMsg
=
{.
handle
=
pTrans
->
rpcHandle
,
.
code
=
pTrans
->
code
,
.
ahandle
=
pTrans
->
rpcAHandle
};
SRpcMsg
rspMsg
=
{.
handle
=
pTrans
->
rpcHandle
,
.
code
=
pTrans
->
code
,
.
ahandle
=
pTrans
->
rpcAHandle
,
.
pCont
=
pTrans
->
rpcRsp
,
.
contLen
=
pTrans
->
rpcRspLen
};
rpcSendResponse
(
&
rspMsg
);
pTrans
->
rpcHandle
=
NULL
;
pTrans
->
rpcRsp
=
NULL
;
pTrans
->
rpcRspLen
=
0
;
}
}
void
mndTransProcessRsp
(
SMnodeMsg
*
p
Msg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
int64_t
signature
=
(
int64_t
)(
p
Msg
->
rpcMsg
.
ahandle
);
void
mndTransProcessRsp
(
SMnodeMsg
*
p
Rsp
)
{
SMnode
*
pMnode
=
p
Rsp
->
pMnode
;
int64_t
signature
=
(
int64_t
)(
p
Rsp
->
rpcMsg
.
ahandle
);
int32_t
transId
=
(
int32_t
)(
signature
>>
32
);
int32_t
action
=
(
int32_t
)((
signature
<<
32
)
>>
32
);
...
...
@@ -571,10 +592,10 @@ void mndTransProcessRsp(SMnodeMsg *pMsg) {
STransAction
*
pAction
=
taosArrayGet
(
pArray
,
action
);
if
(
pAction
!=
NULL
)
{
pAction
->
msgReceived
=
1
;
pAction
->
errCode
=
p
Msg
->
rpcMsg
.
code
;
pAction
->
errCode
=
p
Rsp
->
rpcMsg
.
code
;
}
mDebug
(
"trans:%d, action:%d response is received, code:0x%x, accept:0x%x"
,
transId
,
action
,
p
Msg
->
rpcMsg
.
code
,
mDebug
(
"trans:%d, action:%d response is received, code:0x%x, accept:0x%x"
,
transId
,
action
,
p
Rsp
->
rpcMsg
.
code
,
pAction
->
acceptableCode
);
mndTransExecute
(
pMnode
,
pTrans
);
...
...
@@ -921,7 +942,7 @@ static int32_t mndProcessTransMsg(SMnodeMsg *pMsg) {
void
mndTransPullup
(
SMnode
*
pMnode
)
{
STrans
*
pTrans
=
NULL
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
while
(
1
)
{
pIter
=
sdbFetch
(
pMnode
->
pSdb
,
SDB_TRANS
,
pIter
,
(
void
**
)
&
pTrans
);
...
...
source/dnode/mnode/impl/test/db/db.cpp
浏览文件 @
3152824a
...
...
@@ -202,6 +202,10 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
SDropDbRsp
*
pDrop
=
(
SDropDbRsp
*
)
pRsp
->
pCont
;
pDrop
->
uid
=
htobe64
(
pDrop
->
uid
);
EXPECT_STREQ
(
pDrop
->
db
,
"1.d1"
);
}
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DB
,
""
);
...
...
@@ -249,6 +253,8 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"d2"
,
TSDB_DB_NAME_LEN
-
1
);
uint64_t
d2_uid
=
0
;
{
int32_t
contLen
=
sizeof
(
SUseDbReq
);
...
...
@@ -262,6 +268,8 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
SUseDbRsp
*
pRsp
=
(
SUseDbRsp
*
)
pMsg
->
pCont
;
EXPECT_STREQ
(
pRsp
->
db
,
"1.d2"
);
pRsp
->
uid
=
htobe64
(
pRsp
->
uid
);
d2_uid
=
pRsp
->
uid
;
pRsp
->
vgVersion
=
htonl
(
pRsp
->
vgVersion
);
pRsp
->
vgNum
=
htonl
(
pRsp
->
vgNum
);
pRsp
->
hashMethod
=
pRsp
->
hashMethod
;
...
...
@@ -311,5 +319,10 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
SDropDbRsp
*
pDrop
=
(
SDropDbRsp
*
)
pRsp
->
pCont
;
pDrop
->
uid
=
htobe64
(
pDrop
->
uid
);
EXPECT_STREQ
(
pDrop
->
db
,
"1.d2"
);
EXPECT_EQ
(
pDrop
->
uid
,
d2_uid
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录