Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2b7ec574
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看板
提交
2b7ec574
编写于
4月 15, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: reopen transTest
上级
1e73923c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
56 addition
and
94 deletion
+56
-94
source/dnode/mnode/impl/inc/mndDb.h
source/dnode/mnode/impl/inc/mndDb.h
+1
-1
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+2
-2
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+8
-1
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+25
-25
source/dnode/mnode/impl/test/trans/CMakeLists.txt
source/dnode/mnode/impl/test/trans/CMakeLists.txt
+5
-5
source/dnode/mnode/impl/test/trans/trans.cpp
source/dnode/mnode/impl/test/trans/trans.cpp
+15
-60
未找到文件。
source/dnode/mnode/impl/inc/mndDb.h
浏览文件 @
2b7ec574
...
...
@@ -27,7 +27,7 @@ void mndCleanupDb(SMnode *pMnode);
SDbObj
*
mndAcquireDb
(
SMnode
*
pMnode
,
const
char
*
db
);
void
mndReleaseDb
(
SMnode
*
pMnode
,
SDbObj
*
pDb
);
int32_t
mndValidateDbInfo
(
SMnode
*
pMnode
,
SDbVgVersion
*
pDbs
,
int32_t
numOfDbs
,
void
**
ppRsp
,
int32_t
*
pRspLen
);
char
*
mnGetDbStr
(
char
*
src
);
char
*
mn
d
GetDbStr
(
char
*
src
);
int32_t
mndExtractDbInfo
(
SMnode
*
pMnode
,
SDbObj
*
pDb
,
SUseDbRsp
*
pRsp
,
const
SUseDbReq
*
pReq
);
#ifdef __cplusplus
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
2b7ec574
...
...
@@ -1340,7 +1340,7 @@ SYNC_DB_OVER:
return
code
;
}
char
*
mnGetDbStr
(
char
*
src
)
{
char
*
mn
d
GetDbStr
(
char
*
src
)
{
char
*
pos
=
strstr
(
src
,
TS_PATH_DELIMITER
);
if
(
pos
!=
NULL
)
++
pos
;
...
...
@@ -1355,7 +1355,7 @@ static void dumpDbInfoData(SSDataBlock* pBlock, SDbObj *pDb, SShowObj *pShow, in
int32_t
cols
=
0
;
char
*
buf
=
taosMemoryMalloc
(
pShow
->
bytes
[
cols
]);
char
*
name
=
mnGetDbStr
(
pDb
->
name
);
char
*
name
=
mn
d
GetDbStr
(
pDb
->
name
);
if
(
name
!=
NULL
)
{
STR_WITH_MAXSIZE_TO_VARSTR
(
buf
,
name
,
pShow
->
bytes
[
cols
]);
}
else
{
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
2b7ec574
...
...
@@ -131,6 +131,13 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
req
.
type
=
retrieveReq
.
type
;
strncpy
(
req
.
db
,
retrieveReq
.
db
,
tListLen
(
req
.
db
));
STableMetaRsp
*
pMeta
=
(
STableMetaRsp
*
)
taosHashGet
(
pMnode
->
infosMeta
,
retrieveReq
.
tb
,
strlen
(
retrieveReq
.
tb
)
+
1
);
if
(
pMeta
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_INFOS_TBL
;
mError
(
"failed to process show-retrieve req:%p since %s"
,
pShow
,
terrstr
());
return
-
1
;
}
pShow
=
mndCreateShowObj
(
pMnode
,
&
req
);
if
(
pShow
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -138,7 +145,7 @@ static int32_t mndProcessRetrieveSysTableReq(SNodeMsg *pReq) {
return
-
1
;
}
pShow
->
pMeta
=
(
STableMetaRsp
*
)
taosHashGet
(
pMnode
->
infosMeta
,
retrieveReq
.
tb
,
strlen
(
retrieveReq
.
tb
)
+
1
)
;
pShow
->
pMeta
=
pMeta
;
pShow
->
numOfColumns
=
pShow
->
pMeta
->
numOfColumns
;
int32_t
offset
=
0
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
2b7ec574
...
...
@@ -58,7 +58,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans);
static
int32_t
mndProcessTransReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessKillTransReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndRetrieveTrans
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndRetrieveTrans
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextTrans
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitTrans
(
SMnode
*
pMnode
)
{
...
...
@@ -73,7 +73,7 @@ int32_t mndInitTrans(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TRANS_TIMER
,
mndProcessTransReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_KILL_TRANS
,
mndProcessKillTransReq
);
//
mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TRANS, mndRetrieveTrans);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_TRANS
,
mndRetrieveTrans
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_TRANS
,
mndCancelGetNextTrans
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
}
...
...
@@ -1259,7 +1259,7 @@ void mndTransPullup(SMnode *pMnode) {
sdbWriteFile
(
pMnode
->
pSdb
);
}
static
int32_t
mndRetrieveTrans
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
static
int32_t
mndRetrieveTrans
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
...
...
@@ -1273,34 +1273,34 @@ static int32_t mndRetrieveTrans(SNodeMsg *pReq, SShowObj *pShow, char *data, int
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
pTrans
->
id
;
cols
++
;
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pTrans
->
id
,
false
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int64_t
*
)
pWrite
=
pTrans
->
createdTime
;
cols
++
;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pTrans
->
createdTime
,
false
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_TO_VARSTR
(
pWrite
,
mndTransStr
(
pTrans
->
stage
));
cols
++
;
char
stage
[
TSDB_TRANS_STAGE_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
stage
,
mndTransStr
(
pTrans
->
stage
),
pShow
->
bytes
[
cols
]);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
stage
,
false
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
char
*
name
=
mnGetDbStr
(
pTrans
->
dbname
);
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
name
,
pShow
->
bytes
[
cols
]
);
col
s
++
;
char
dbname
[
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
}
;
STR_WITH_MAXSIZE_TO_VARSTR
(
dbname
,
mndGetDbStr
(
pTrans
->
dbname
),
pShow
->
bytes
[
cols
]
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
col
DataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
dbname
,
false
)
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_TO_VARSTR
(
pWrite
,
mndTransType
(
pTrans
->
transType
));
cols
++
;
char
transType
[
TSDB_TRANS_TYPE_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
dbname
,
mndTransType
(
pTrans
->
transType
),
pShow
->
bytes
[
cols
]);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
transType
,
false
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int64_t
*
)
pWrite
=
pTrans
->
lastExecTime
;
cols
++
;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pTrans
->
lastExecTime
,
false
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_TO_VARSTR
(
pWrite
,
pTrans
->
lastError
);
cols
++
;
char
lastError
[
TSDB_TRANS_ERROR_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
dbname
,
pTrans
->
lastError
,
pShow
->
bytes
[
cols
]);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
lastError
,
false
);
numOfRows
++
;
sdbRelease
(
pSdb
,
pTrans
);
...
...
source/dnode/mnode/impl/test/trans/CMakeLists.txt
浏览文件 @
2b7ec574
aux_source_directory
(
.
TRANS
_SRC
)
add_executable
(
mnode_test_trans
${
TRANS
_SRC
}
)
aux_source_directory
(
.
MNODE_TRANS_TEST
_SRC
)
add_executable
(
transTest
${
MNODE_TRANS_TEST
_SRC
}
)
target_link_libraries
(
mnode_test_trans
transTest
PUBLIC sut
)
add_test
(
NAME
mnode_test_trans
COMMAND
mnode_test_trans
NAME
transTest
COMMAND
transTest
)
source/dnode/mnode/impl/test/trans/trans.cpp
浏览文件 @
2b7ec574
...
...
@@ -26,11 +26,11 @@ class MndTestTrans : public ::testing::Test {
}
static
void
KillThenRestartServer
()
{
char
file
[
PATH_MAX
]
=
"/tmp/mnode_test_trans/mnode/data/sdb.data"
;
char
file
[
PATH_MAX
]
=
"/tmp/mnode_test_trans/mnode/data/sdb.data"
;
TdFilePtr
pFile
=
taosOpenFile
(
file
,
TD_FILE_READ
);
int32_t
size
=
3
*
1024
*
1024
;
void
*
buffer
=
taosMemoryMalloc
(
size
);
int32_t
readLen
=
taosReadFile
(
pFile
,
buffer
,
size
);
int32_t
size
=
3
*
1024
*
1024
;
void
*
buffer
=
taosMemoryMalloc
(
size
);
int32_t
readLen
=
taosReadFile
(
pFile
,
buffer
,
size
);
if
(
readLen
<
0
||
readLen
==
size
)
{
ASSERT
(
1
);
}
...
...
@@ -65,18 +65,7 @@ TestServer MndTestTrans::server2;
TEST_F
(
MndTestTrans
,
00
_Create_User_Crash
)
{
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_TRANS
,
""
);
CHECK_META
(
"show trans"
,
7
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_INT
,
4
,
"id"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TRANS_STAGE_LEN
+
VARSTR_HEADER_SIZE
,
"stage"
);
CHECK_SCHEMA
(
3
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
-
1
+
VARSTR_HEADER_SIZE
,
"db"
);
CHECK_SCHEMA
(
4
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TRANS_TYPE_LEN
+
VARSTR_HEADER_SIZE
,
"type"
);
CHECK_SCHEMA
(
5
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"last_exec_time"
);
CHECK_SCHEMA
(
6
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TRANS_ERROR_LEN
-
1
+
VARSTR_HEADER_SIZE
,
"last_error"
);
test
.
SendShowRetrieveReq
();
test
.
SendShowReq
(
TSDB_MGMT_TABLE_TRANS
,
"trans"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
...
...
@@ -109,26 +98,13 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieveReq
();
test
.
SendShowReq
(
TSDB_MGMT_TABLE_USER
,
"user_users"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
KillThenRestartServer
();
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieveReq
();
test
.
SendShowReq
(
TSDB_MGMT_TABLE_USER
,
"user_users"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckBinary
(
"u1"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"normal"
,
10
);
CheckBinary
(
"super"
,
10
);
CheckTimestamp
();
CheckTimestamp
();
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
TEST_F
(
MndTestTrans
,
02
_Create_Qnode1_Crash
)
{
...
...
@@ -144,9 +120,7 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_QNODE
,
""
);
CHECK_META
(
"show qnodes"
,
3
);
test
.
SendShowRetrieveReq
();
test
.
SendShowReq
(
TSDB_MGMT_TABLE_QNODE
,
"qnodes"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
...
...
@@ -163,9 +137,7 @@ TEST_F(MndTestTrans, 02_Create_Qnode1_Crash) {
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_QNODE_ALREADY_EXIST
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_QNODE
,
""
);
CHECK_META
(
"show qnodes"
,
3
);
test
.
SendShowRetrieveReq
();
test
.
SendShowReq
(
TSDB_MGMT_TABLE_QNODE
,
"qnodes"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
}
...
...
@@ -185,8 +157,7 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
ASSERT_EQ
(
pRsp
->
code
,
0
);
taosMsleep
(
1300
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieveReq
();
test
.
SendShowReq
(
TSDB_MGMT_TABLE_DNODE
,
"dnodes"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
...
...
@@ -208,18 +179,8 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
{
// show trans
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_TRANS
,
""
);
CHECK_META
(
"show trans"
,
7
);
test
.
SendShowRetrieveReq
();
test
.
SendShowReq
(
TSDB_MGMT_TABLE_TRANS
,
"trans"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt32
(
4
);
CheckTimestamp
();
CheckBinary
(
"undoAction"
,
TSDB_TRANS_STAGE_LEN
);
CheckBinary
(
""
,
TSDB_DB_NAME_LEN
-
1
);
CheckBinary
(
"create-qnode"
,
TSDB_TRANS_TYPE_LEN
);
CheckTimestamp
();
CheckBinary
(
"Unable to establish connection"
,
TSDB_TRANS_ERROR_LEN
-
1
);
}
// kill trans
...
...
@@ -238,8 +199,7 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
// show trans
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_TRANS
,
""
);
test
.
SendShowRetrieveReq
();
test
.
SendShowReq
(
TSDB_MGMT_TABLE_TRANS
,
"trans"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
...
...
@@ -258,11 +218,9 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
uInfo
(
"======== kill and restart server"
)
KillThenRestartServer
();
uInfo
(
"======== kill and restart server"
)
KillThenRestartServer
();
uInfo
(
"======== server2 start"
)
server2
.
DoStart
();
uInfo
(
"======== server2 start"
)
server2
.
DoStart
();
uInfo
(
"======== server2 started"
)
...
...
@@ -286,14 +244,11 @@ TEST_F(MndTestTrans, 03_Create_Qnode2_Crash) {
ASSERT_NE
(
retry
,
retryMax
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_QNODE
,
""
);
CHECK_META
(
"show qnodes"
,
3
);
test
.
SendShowRetrieveReq
();
test
.
SendShowReq
(
TSDB_MGMT_TABLE_QNODE
,
"qnodes"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
}
// create db
// partial create stb
// drop db failed
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录