Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7ee2e5a3
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7ee2e5a3
编写于
5月 25, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: let all operations of mnode into the sync log
上级
229cb7b7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
115 addition
and
82 deletion
+115
-82
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+27
-24
source/dnode/mnode/impl/src/mndAcct.c
source/dnode/mnode/impl/src/mndAcct.c
+50
-20
source/dnode/mnode/impl/src/mndCluster.c
source/dnode/mnode/impl/src/mndCluster.c
+26
-0
tests/script/tsim/mnode/basic2.sim
tests/script/tsim/mnode/basic2.sim
+9
-35
tests/script/tsim/trans/create_db.sim
tests/script/tsim/trans/create_db.sim
+3
-3
未找到文件。
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
7ee2e5a3
...
@@ -67,30 +67,33 @@ typedef enum {
...
@@ -67,30 +67,33 @@ typedef enum {
typedef
enum
{
typedef
enum
{
TRN_TYPE_BASIC_SCOPE
=
1000
,
TRN_TYPE_BASIC_SCOPE
=
1000
,
TRN_TYPE_CREATE_USER
=
1001
,
TRN_TYPE_CREATE_ACCT
=
1001
,
TRN_TYPE_ALTER_USER
=
1002
,
TRN_TYPE_CREATE_CLUSTER
=
1002
,
TRN_TYPE_DROP_USER
=
1003
,
TRN_TYPE_CREATE_USER
=
1003
,
TRN_TYPE_CREATE_FUNC
=
1004
,
TRN_TYPE_ALTER_USER
=
1004
,
TRN_TYPE_DROP_FUNC
=
1005
,
TRN_TYPE_DROP_USER
=
1005
,
TRN_TYPE_CREATE_FUNC
=
1006
,
TRN_TYPE_CREATE_SNODE
=
1006
,
TRN_TYPE_DROP_FUNC
=
1007
,
TRN_TYPE_DROP_SNODE
=
1007
,
TRN_TYPE_CREATE_QNODE
=
1008
,
TRN_TYPE_CREATE_SNODE
=
1010
,
TRN_TYPE_DROP_QNODE
=
1009
,
TRN_TYPE_DROP_SNODE
=
1011
,
TRN_TYPE_CREATE_BNODE
=
1010
,
TRN_TYPE_CREATE_QNODE
=
1012
,
TRN_TYPE_DROP_BNODE
=
1011
,
TRN_TYPE_DROP_QNODE
=
10013
,
TRN_TYPE_CREATE_MNODE
=
1012
,
TRN_TYPE_CREATE_BNODE
=
1014
,
TRN_TYPE_DROP_MNODE
=
1013
,
TRN_TYPE_DROP_BNODE
=
1015
,
TRN_TYPE_CREATE_TOPIC
=
1014
,
TRN_TYPE_CREATE_MNODE
=
1016
,
TRN_TYPE_DROP_TOPIC
=
1015
,
TRN_TYPE_DROP_MNODE
=
1017
,
TRN_TYPE_SUBSCRIBE
=
1016
,
TRN_TYPE_REBALANCE
=
1017
,
TRN_TYPE_CREATE_TOPIC
=
1020
,
TRN_TYPE_COMMIT_OFFSET
=
1018
,
TRN_TYPE_DROP_TOPIC
=
1021
,
TRN_TYPE_CREATE_STREAM
=
1019
,
TRN_TYPE_SUBSCRIBE
=
1022
,
TRN_TYPE_DROP_STREAM
=
1020
,
TRN_TYPE_REBALANCE
=
1023
,
TRN_TYPE_ALTER_STREAM
=
1021
,
TRN_TYPE_COMMIT_OFFSET
=
1024
,
TRN_TYPE_CONSUMER_LOST
=
1022
,
TRN_TYPE_CREATE_STREAM
=
1025
,
TRN_TYPE_CONSUMER_RECOVER
=
1023
,
TRN_TYPE_DROP_STREAM
=
1026
,
TRN_TYPE_ALTER_STREAM
=
1027
,
TRN_TYPE_CONSUMER_LOST
=
1028
,
TRN_TYPE_CONSUMER_RECOVER
=
1029
,
TRN_TYPE_BASIC_SCOPE_END
,
TRN_TYPE_BASIC_SCOPE_END
,
TRN_TYPE_GLOBAL_SCOPE
=
2000
,
TRN_TYPE_GLOBAL_SCOPE
=
2000
,
...
...
source/dnode/mnode/impl/src/mndAcct.c
浏览文件 @
7ee2e5a3
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "mndAcct.h"
#include "mndAcct.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndTrans.h"
#define ACCT_VER_NUMBER 1
#define ACCT_VER_NUMBER 1
#define ACCT_RESERVE_SIZE 128
#define ACCT_RESERVE_SIZE 128
...
@@ -31,14 +32,16 @@ static int32_t mndProcessAlterAcctReq(SRpcMsg *pReq);
...
@@ -31,14 +32,16 @@ static int32_t mndProcessAlterAcctReq(SRpcMsg *pReq);
static
int32_t
mndProcessDropAcctReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessDropAcctReq
(
SRpcMsg
*
pReq
);
int32_t
mndInitAcct
(
SMnode
*
pMnode
)
{
int32_t
mndInitAcct
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_ACCT
,
SSdbTable
table
=
{
.
keyType
=
SDB_KEY_BINARY
,
.
sdbType
=
SDB_ACCT
,
.
deployFp
=
mndCreateDefaultAcct
,
.
keyType
=
SDB_KEY_BINARY
,
.
encodeFp
=
(
SdbEncodeFp
)
mndAcctActionEncode
,
.
deployFp
=
mndCreateDefaultAcct
,
.
decodeFp
=
(
SdbDecodeFp
)
mndAcctActionDecode
,
.
encodeFp
=
(
SdbEncodeFp
)
mndAcctActionEncode
,
.
insertFp
=
(
SdbInsertFp
)
mndAcctActionInsert
,
.
decodeFp
=
(
SdbDecodeFp
)
mndAcctActionDecode
,
.
updateFp
=
(
SdbUpdateFp
)
mndAcctActionUpdate
,
.
insertFp
=
(
SdbInsertFp
)
mndAcctActionInsert
,
.
deleteFp
=
(
SdbDeleteFp
)
mndAcctActionDelete
};
.
updateFp
=
(
SdbUpdateFp
)
mndAcctActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndAcctActionDelete
,
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_ACCT
,
mndProcessCreateAcctReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_ACCT
,
mndProcessCreateAcctReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_ACCT
,
mndProcessAlterAcctReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_ALTER_ACCT
,
mndProcessAlterAcctReq
);
...
@@ -56,25 +59,52 @@ static int32_t mndCreateDefaultAcct(SMnode *pMnode) {
...
@@ -56,25 +59,52 @@ static int32_t mndCreateDefaultAcct(SMnode *pMnode) {
acctObj
.
updateTime
=
acctObj
.
createdTime
;
acctObj
.
updateTime
=
acctObj
.
createdTime
;
acctObj
.
acctId
=
1
;
acctObj
.
acctId
=
1
;
acctObj
.
status
=
0
;
acctObj
.
status
=
0
;
acctObj
.
cfg
=
(
SAcctCfg
){.
maxUsers
=
INT32_MAX
,
acctObj
.
cfg
=
(
SAcctCfg
){
.
maxDbs
=
INT32_MAX
,
.
maxUsers
=
INT32_MAX
,
.
maxStbs
=
INT32_MAX
,
.
maxDbs
=
INT32_MAX
,
.
maxTbs
=
INT32_MAX
,
.
maxStbs
=
INT32_MAX
,
.
maxTimeSeries
=
INT32_MAX
,
.
maxTbs
=
INT32_MAX
,
.
maxStreams
=
INT32_MAX
,
.
maxTimeSeries
=
INT32_MAX
,
.
maxFuncs
=
INT32_MAX
,
.
maxStreams
=
INT32_MAX
,
.
maxConsumers
=
INT32_MAX
,
.
maxFuncs
=
INT32_MAX
,
.
maxConns
=
INT32_MAX
,
.
maxConsumers
=
INT32_MAX
,
.
maxTopics
=
INT32_MAX
,
.
maxConns
=
INT32_MAX
,
.
maxStorage
=
INT64_MAX
,
.
maxTopics
=
INT32_MAX
,
.
accessState
=
TSDB_VN_ALL_ACCCESS
};
.
maxStorage
=
INT64_MAX
,
.
accessState
=
TSDB_VN_ALL_ACCCESS
,
};
SSdbRaw
*
pRaw
=
mndAcctActionEncode
(
&
acctObj
);
SSdbRaw
*
pRaw
=
mndAcctActionEncode
(
&
acctObj
);
if
(
pRaw
==
NULL
)
return
-
1
;
if
(
pRaw
==
NULL
)
return
-
1
;
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
mDebug
(
"acct:%s, will be created while deploy sdb, raw:%p"
,
acctObj
.
acct
,
pRaw
);
mDebug
(
"acct:%s, will be created while deploy sdb, raw:%p"
,
acctObj
.
acct
,
pRaw
);
#if 0
return sdbWrite(pMnode->pSdb, pRaw);
return sdbWrite(pMnode->pSdb, pRaw);
#else
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_TYPE_CREATE_ACCT
,
NULL
);
if
(
pTrans
==
NULL
)
{
mError
(
"acct:%s, failed to create since %s"
,
acctObj
.
acct
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to create acct:%s"
,
pTrans
->
id
,
acctObj
.
acct
);
if
(
mndTransAppendCommitlog
(
pTrans
,
pRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to commit redo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
mndTransDrop
(
pTrans
);
return
0
;
#endif
}
}
static
SSdbRaw
*
mndAcctActionEncode
(
SAcctObj
*
pAcct
)
{
static
SSdbRaw
*
mndAcctActionEncode
(
SAcctObj
*
pAcct
)
{
...
...
source/dnode/mnode/impl/src/mndCluster.c
浏览文件 @
7ee2e5a3
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "mndCluster.h"
#include "mndCluster.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndTrans.h"
#define CLUSTER_VER_NUMBE 1
#define CLUSTER_VER_NUMBE 1
#define CLUSTER_RESERVE_SIZE 64
#define CLUSTER_RESERVE_SIZE 64
...
@@ -177,7 +178,32 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
...
@@ -177,7 +178,32 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
mDebug
(
"cluster:%"
PRId64
", will be created while deploy sdb, raw:%p"
,
clusterObj
.
id
,
pRaw
);
mDebug
(
"cluster:%"
PRId64
", will be created while deploy sdb, raw:%p"
,
clusterObj
.
id
,
pRaw
);
#if 0
return sdbWrite(pMnode->pSdb, pRaw);
return sdbWrite(pMnode->pSdb, pRaw);
#else
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_TYPE_CREATE_CLUSTER
,
NULL
);
if
(
pTrans
==
NULL
)
{
mError
(
"cluster:%"
PRId64
", failed to create since %s"
,
clusterObj
.
id
,
terrstr
());
return
-
1
;
}
mDebug
(
"trans:%d, used to create cluster:%"
PRId64
,
pTrans
->
id
,
clusterObj
.
id
);
if
(
mndTransAppendCommitlog
(
pTrans
,
pRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to commit redo log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
mndTransDrop
(
pTrans
);
return
0
;
#endif
}
}
static
int32_t
mndRetrieveClusters
(
SRpcMsg
*
pMsg
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
static
int32_t
mndRetrieveClusters
(
SRpcMsg
*
pMsg
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
...
...
tests/script/tsim/mnode/basic2.sim
浏览文件 @
7ee2e5a3
...
@@ -6,15 +6,6 @@ system sh/exec.sh -n dnode2 -s start
...
@@ -6,15 +6,6 @@ system sh/exec.sh -n dnode2 -s start
sql connect
sql connect
print =============== show dnodes
print =============== show dnodes
sql show dnodes;
if $rows != 1 then
return -1
endi
if $data00 != 1 then
return -1
endi
sql show mnodes;
sql show mnodes;
if $rows != 1 then
if $rows != 1 then
return -1
return -1
...
@@ -30,35 +21,11 @@ endi
...
@@ -30,35 +21,11 @@ endi
print =============== create dnodes
print =============== create dnodes
sql create dnode $hostname port 7200
sql create dnode $hostname port 7200
sql create dnode $hostname port 7300
sleep 2000
sleep 2000
sql show dnodes;
sql show dnodes;
if $rows != 2 then
if $rows != 3 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != 2 then
return -1
endi
print $data02
if $data02 != 0 then
return -1
endi
if $data12 != 0 then
return -1
endi
if $data04 != ready then
return -1
endi
if $data14 != ready then
return -1
return -1
endi
endi
...
@@ -82,3 +49,10 @@ if $rows != 2 then
...
@@ -82,3 +49,10 @@ if $rows != 2 then
return -1
return -1
endi
endi
return
sql create mnode on dnode 3
sql show mnodes
if $rows != 3 then
return -1
endi
tests/script/tsim/trans/create_db.sim
浏览文件 @
7ee2e5a3
...
@@ -64,7 +64,7 @@ if $rows != 1 then
...
@@ -64,7 +64,7 @@ if $rows != 1 then
return -1
return -1
endi
endi
if $data[0][0] !=
5
then
if $data[0][0] !=
7
then
return -1
return -1
endi
endi
...
@@ -114,7 +114,7 @@ if $rows != 1 then
...
@@ -114,7 +114,7 @@ if $rows != 1 then
return -1
return -1
endi
endi
if $data[0][0] !=
7
then
if $data[0][0] !=
9
then
return -1
return -1
endi
endi
...
@@ -137,7 +137,7 @@ endi
...
@@ -137,7 +137,7 @@ endi
sql_error create database d2 vgroups 2;
sql_error create database d2 vgroups 2;
print =============== kill transaction
print =============== kill transaction
sql kill transaction
7
;
sql kill transaction
9
;
sleep 2000
sleep 2000
sql show transactions
sql show transactions
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录