Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9a0d27c6
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,发现更多精彩内容 >>
提交
9a0d27c6
编写于
12月 14, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-10431 test for create user
上级
2348b6e2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
97 addition
and
93 deletion
+97
-93
source/dnode/mgmt/impl/test/dnode/dnode.cpp
source/dnode/mgmt/impl/test/dnode/dnode.cpp
+34
-34
source/dnode/mgmt/impl/test/sut/deploy.cpp
source/dnode/mgmt/impl/test/sut/deploy.cpp
+1
-1
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+2
-1
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+53
-35
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+1
-17
source/dnode/mnode/sdb/src/sdbHash.c
source/dnode/mnode/sdb/src/sdbHash.c
+6
-5
未找到文件。
source/dnode/mgmt/impl/test/dnode/dnode.cpp
浏览文件 @
9a0d27c6
...
...
@@ -379,41 +379,41 @@ TEST_F(DndTestDnode, RestartDnode_01) {
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:9521"
;
pServer1
=
startServer
(
"/tmp/dndTestDnode1"
,
fqdn
,
9521
,
firstEp
);
// pServer1
= startServer("/tmp/dndTestDnode3", fqdn, 9523, firstEp);
// pServer1
= startServer("/tmp/dndTestDnode4", fqdn, 9524, firstEp);
// pServer1
= startServer("/tmp/dndTestDnode5", fqdn, 9525, firstEp);
pServer3
=
startServer
(
"/tmp/dndTestDnode3"
,
fqdn
,
9523
,
firstEp
);
pServer4
=
startServer
(
"/tmp/dndTestDnode4"
,
fqdn
,
9524
,
firstEp
);
pServer5
=
startServer
(
"/tmp/dndTestDnode5"
,
fqdn
,
9525
,
firstEp
);
uInfo
(
"all server is running"
);
//
taosMsleep(1300);
//
SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "show dnodes", 7);
//
SendThenCheckShowRetrieveMsg(4);
//
CheckInt16(1);
//
CheckInt16(3);
//
CheckInt16(4);
//
CheckInt16(5);
//
CheckBinary("localhost:9521", TSDB_EP_LEN);
//
CheckBinary("localhost:9523", TSDB_EP_LEN);
//
CheckBinary("localhost:9524", TSDB_EP_LEN);
//
CheckBinary("localhost:9525", TSDB_EP_LEN);
//
CheckInt16(0);
//
CheckInt16(0);
//
CheckInt16(0);
//
CheckInt16(0);
//
CheckInt16(1);
//
CheckInt16(1);
//
CheckInt16(1);
//
CheckInt16(1);
//
CheckBinary("ready", 10);
//
CheckBinary("ready", 10);
//
CheckBinary("ready", 10);
//
CheckBinary("ready", 10);
//
CheckTimestamp();
//
CheckTimestamp();
//
CheckTimestamp();
//
CheckTimestamp();
//
CheckBinary("", 24);
//
CheckBinary("", 24);
//
CheckBinary("", 24);
//
CheckBinary("", 24);
taosMsleep
(
1300
);
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DNODE
,
"show dnodes"
,
7
);
SendThenCheckShowRetrieveMsg
(
4
);
CheckInt16
(
1
);
CheckInt16
(
3
);
CheckInt16
(
4
);
CheckInt16
(
5
);
CheckBinary
(
"localhost:9521"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:9523"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:9524"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:9525"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckBinary
(
"ready"
,
10
);
CheckBinary
(
"ready"
,
10
);
CheckBinary
(
"ready"
,
10
);
CheckBinary
(
"ready"
,
10
);
CheckTimestamp
();
CheckTimestamp
();
CheckTimestamp
();
CheckTimestamp
();
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
}
source/dnode/mgmt/impl/test/sut/deploy.cpp
浏览文件 @
9a0d27c6
...
...
@@ -18,7 +18,7 @@
void
initLog
(
const
char
*
path
)
{
dDebugFlag
=
143
;
vDebugFlag
=
0
;
mDebugFlag
=
143
;
mDebugFlag
=
207
;
cDebugFlag
=
0
;
jniDebugFlag
=
0
;
tmrDebugFlag
=
0
;
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
9a0d27c6
...
...
@@ -73,7 +73,8 @@ typedef enum {
TRN_STAGE_EXECUTE
=
2
,
TRN_STAGE_COMMIT
=
3
,
TRN_STAGE_ROLLBACK
=
4
,
TRN_STAGE_RETRY
=
5
TRN_STAGE_RETRY
=
5
,
TRN_STAGE_OVER
=
6
,
}
ETrnStage
;
typedef
enum
{
TRN_POLICY_ROLLBACK
=
1
,
TRN_POLICY_RETRY
=
2
}
ETrnPolicy
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
9a0d27c6
...
...
@@ -58,7 +58,7 @@ int32_t mndInitTrans(SMnode *pMnode) {
void
mndCleanupTrans
(
SMnode
*
pMnode
)
{}
static
SSdbRaw
*
mndTransActionEncode
(
STrans
*
pTrans
)
{
int32_t
rawDataLen
=
16
*
sizeof
(
int32_t
);
int32_t
rawDataLen
=
16
*
sizeof
(
int32_t
)
+
TSDB_TRN_RESERVE_SIZE
;
int32_t
redoLogNum
=
taosArrayGetSize
(
pTrans
->
redoLogs
);
int32_t
undoLogNum
=
taosArrayGetSize
(
pTrans
->
undoLogs
);
int32_t
commitLogNum
=
taosArrayGetSize
(
pTrans
->
commitLogs
);
...
...
@@ -88,7 +88,6 @@ static SSdbRaw *mndTransActionEncode(STrans *pTrans) {
int32_t
dataPos
=
0
;
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTrans
->
id
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTrans
->
stage
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pTrans
->
policy
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
redoLogNum
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
undoLogNum
)
...
...
@@ -166,7 +165,6 @@ static SSdbRow *mndTransActionDecode(SSdbRaw *pRaw) {
int32_t
dataPos
=
0
;
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
pTrans
->
id
)
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
(
int8_t
*
)
&
pTrans
->
stage
)
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
(
int8_t
*
)
&
pTrans
->
policy
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
redoLogNum
)
SDB_GET_INT32
(
pRaw
,
pRow
,
dataPos
,
&
undoLogNum
)
...
...
@@ -231,6 +229,7 @@ TRANS_DECODE_OVER:
}
static
int32_t
mndTransActionInsert
(
SSdb
*
pSdb
,
STrans
*
pTrans
)
{
pTrans
->
stage
=
TRN_STAGE_PREPARE
;
mTrace
(
"trans:%d, perform insert action, stage:%s"
,
pTrans
->
id
,
mndTransStageStr
(
pTrans
->
stage
));
return
0
;
}
...
...
@@ -263,7 +262,7 @@ void mndReleaseTrans(SMnode *pMnode, STrans *pTrans) {
sdbRelease
(
pSdb
,
pTrans
);
}
static
int32_t
trn
GenerateTransId
()
{
static
int32_t
mnd
GenerateTransId
()
{
static
int32_t
tmp
=
0
;
return
++
tmp
;
}
...
...
@@ -304,7 +303,7 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, void *rpcHandle) {
return
NULL
;
}
pTrans
->
id
=
trn
GenerateTransId
();
pTrans
->
id
=
mnd
GenerateTransId
();
pTrans
->
stage
=
TRN_STAGE_PREPARE
;
pTrans
->
policy
=
policy
;
pTrans
->
rpcHandle
=
rpcHandle
;
...
...
@@ -428,6 +427,7 @@ int32_t mndTransPrepare(SMnode *pMnode, STrans *pTrans) {
}
mDebug
(
"trans:%d, prepare finished"
,
pNewTrans
->
id
);
pNewTrans
->
rpcHandle
=
pTrans
->
rpcHandle
;
mndTransExecute
(
pMnode
,
pNewTrans
);
mndReleaseTrans
(
pMnode
,
pNewTrans
);
return
0
;
...
...
@@ -443,19 +443,21 @@ int32_t mndTransCommit(SMnode *pMnode, STrans *pTrans) {
}
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_DROPPED
);
mTrace
(
"trans:%d, start sync"
,
pTrans
->
id
);
int32_t
code
=
mndSyncPropose
(
pMnode
,
pRaw
);
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to sync since %s"
,
pTrans
->
id
,
terrstr
());
sdbFreeRaw
(
pRaw
);
return
-
1
;
}
if
(
taosArrayGetSize
(
pTrans
->
commitLogs
)
!=
0
)
{
mTrace
(
"trans:%d, start sync"
,
pTrans
->
id
);
int32_t
code
=
mndSyncPropose
(
pMnode
,
pRaw
);
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to sync since %s"
,
pTrans
->
id
,
terrstr
());
sdbFreeRaw
(
pRaw
);
return
-
1
;
}
mTrace
(
"trans:%d, sync finished"
,
pTrans
->
id
);
code
=
sdbWrite
(
pMnode
->
pSdb
,
pRaw
);
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to write sdb since %s"
,
pTrans
->
id
,
terrstr
());
return
-
1
;
mTrace
(
"trans:%d, sync finished"
,
pTrans
->
id
);
code
=
sdbWrite
(
pMnode
->
pSdb
,
pRaw
);
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to write sdb since %s"
,
pTrans
->
id
,
terrstr
());
return
-
1
;
}
}
mDebug
(
"trans:%d, commit finished"
,
pTrans
->
id
);
...
...
@@ -521,45 +523,58 @@ static int32_t mndTransExecuteArray(SMnode *pMnode, SArray *pArray) {
}
static
int32_t
mndTransExecuteRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
int32_t
code
=
mndTransExecuteArray
(
pMnode
,
pTrans
->
redoLogs
);
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to execute redo logs since %s"
,
pTrans
->
id
,
terrstr
())
}
else
{
mTrace
(
"trans:%d, execute redo logs finished"
,
pTrans
->
id
)
int32_t
code
=
0
;
if
(
taosArrayGetSize
(
pTrans
->
redoLogs
)
!=
0
)
{
code
=
mndTransExecuteArray
(
pMnode
,
pTrans
->
redoLogs
);
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to execute redo logs since %s"
,
pTrans
->
id
,
terrstr
())
}
else
{
mTrace
(
"trans:%d, execute redo logs finished"
,
pTrans
->
id
)
}
}
return
code
;
}
static
int32_t
mndTransExecuteUndoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
int32_t
code
=
mndTransExecuteArray
(
pMnode
,
pTrans
->
undoLogs
);
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to execute undo logs since %s"
,
pTrans
->
id
,
terrstr
())
}
else
{
mTrace
(
"trans:%d, execute undo logs finished"
,
pTrans
->
id
)
int32_t
code
=
0
;
if
(
taosArrayGetSize
(
pTrans
->
undoLogs
)
!=
0
)
{
code
=
mndTransExecuteArray
(
pMnode
,
pTrans
->
undoLogs
);
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to execute undo logs since %s"
,
pTrans
->
id
,
terrstr
())
}
else
{
mTrace
(
"trans:%d, execute undo logs finished"
,
pTrans
->
id
)
}
}
return
code
;
}
static
int32_t
mndTransExecuteCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
int32_t
code
=
mndTransExecuteArray
(
pMnode
,
pTrans
->
commitLogs
);
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to execute commit logs since %s"
,
pTrans
->
id
,
terrstr
())
}
else
{
mTrace
(
"trans:%d, execute commit logs finished"
,
pTrans
->
id
)
int32_t
code
=
0
;
if
(
taosArrayGetSize
(
pTrans
->
commitLogs
)
!=
0
)
{
code
=
mndTransExecuteArray
(
pMnode
,
pTrans
->
commitLogs
);
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to execute commit logs since %s"
,
pTrans
->
id
,
terrstr
())
}
else
{
mTrace
(
"trans:%d, execute commit logs finished"
,
pTrans
->
id
)
}
}
return
code
;
}
static
int32_t
mndTransExecuteRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
mTrace
(
"trans:%d, execute redo actions finished"
,
pTrans
->
id
);
if
(
taosArrayGetSize
(
pTrans
->
redoActions
)
!=
0
)
{
mTrace
(
"trans:%d, execute redo actions finished"
,
pTrans
->
id
);
}
return
0
;
}
static
int32_t
mndTransExecuteUndoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
mTrace
(
"trans:%d, execute undo actions finished"
,
pTrans
->
id
);
if
(
taosArrayGetSize
(
pTrans
->
undoActions
)
!=
0
)
{
mTrace
(
"trans:%d, execute undo actions finished"
,
pTrans
->
id
);
}
return
0
;
}
...
...
@@ -603,7 +618,7 @@ static int32_t mndTransPerformCommitStage(SMnode *pMnode, STrans *pTrans) {
int32_t
code
=
mndTransExecuteCommitLogs
(
pMnode
,
pTrans
);
if
(
code
==
0
)
{
pTrans
->
stage
=
TRN_STAGE_
COMMIT
;
pTrans
->
stage
=
TRN_STAGE_
OVER
;
mTrace
(
"trans:%d, commit stage finished"
,
pTrans
->
id
);
}
else
{
if
(
pTrans
->
policy
==
TRN_POLICY_ROLLBACK
)
{
...
...
@@ -671,6 +686,9 @@ static void mndTransExecute(SMnode *pMnode, STrans *pTrans) {
case
TRN_STAGE_RETRY
:
code
=
mndTransPerformRetryStage
(
pMnode
,
pTrans
);
break
;
default:
mndTransSendRpcRsp
(
pTrans
,
0
);
return
;
}
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
9a0d27c6
...
...
@@ -217,23 +217,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass,
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_CREATING
);
SSdbRaw
*
pUndoRaw
=
mndUserActionEncode
(
&
userObj
);
if
(
pUndoRaw
==
NULL
||
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append undo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_DROPPED
);
SSdbRaw
*
pCommitRaw
=
mndUserActionEncode
(
&
userObj
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append commit log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
);
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_READY
);
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
...
...
source/dnode/mnode/sdb/src/sdbHash.c
浏览文件 @
9a0d27c6
...
...
@@ -132,11 +132,6 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
taosHashRemove
(
hash
,
pOldRow
->
pObj
,
keySize
);
taosWUnLockLatch
(
pLock
);
SdbDeleteFp
deleteFp
=
pSdb
->
deleteFps
[
pOldRow
->
type
];
if
(
deleteFp
!=
NULL
)
{
code
=
(
*
deleteFp
)(
pSdb
,
pOldRow
->
pObj
);
}
sdbRelease
(
pSdb
,
pOldRow
->
pObj
);
sdbFreeRow
(
pRow
);
return
code
;
...
...
@@ -161,6 +156,7 @@ int32_t sdbWriteNotFree(SSdb *pSdb, SSdbRaw *pRaw) {
case
SDB_STATUS_CREATING
:
code
=
sdbInsertRow
(
pSdb
,
hash
,
pRaw
,
pRow
,
keySize
);
break
;
case
SDB_STATUS_UPDATING
:
case
SDB_STATUS_READY
:
case
SDB_STATUS_DROPPING
:
code
=
sdbUpdateRow
(
pSdb
,
hash
,
pRaw
,
pRow
,
keySize
);
...
...
@@ -228,6 +224,11 @@ void sdbRelease(SSdb *pSdb, void *pObj) {
int32_t
ref
=
atomic_sub_fetch_32
(
&
pRow
->
refCount
,
1
);
if
(
ref
<=
0
&&
pRow
->
status
==
SDB_STATUS_DROPPED
)
{
SdbDeleteFp
deleteFp
=
pSdb
->
deleteFps
[
pRow
->
type
];
if
(
deleteFp
!=
NULL
)
{
(
*
deleteFp
)(
pSdb
,
pRow
->
pObj
);
}
sdbFreeRow
(
pRow
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录