Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bed4c349
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
bed4c349
编写于
12月 24, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into feature/vnode
上级
9acdf1e9
7205a9ce
变更
18
展开全部
隐藏空白更改
内联
并排
Showing
18 changed file
with
1131 addition
and
72 deletion
+1131
-72
include/common/tmsg.h
include/common/tmsg.h
+37
-0
include/common/tname.h
include/common/tname.h
+4
-0
include/dnode/mnode/sdb/sdb.h
include/dnode/mnode/sdb/sdb.h
+8
-5
include/util/taoserror.h
include/util/taoserror.h
+10
-0
include/util/tdef.h
include/util/tdef.h
+2
-0
source/dnode/mgmt/impl/src/dndVnodes.c
source/dnode/mgmt/impl/src/dndVnodes.c
+1
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+15
-0
source/dnode/mnode/impl/inc/mndStb.h
source/dnode/mnode/impl/inc/mndStb.h
+3
-0
source/dnode/mnode/impl/inc/mndTopic.h
source/dnode/mnode/impl/inc/mndTopic.h
+35
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+119
-41
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+10
-1
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+857
-0
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+2
-1
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+10
-2
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+4
-2
source/dnode/mnode/sdb/src/sdbHash.c
source/dnode/mnode/sdb/src/sdbHash.c
+1
-0
tests/script/general/db/basic1.sim
tests/script/general/db/basic1.sim
+0
-1
tests/script/general/table/basic1.sim
tests/script/general/table/basic1.sim
+13
-19
未找到文件。
include/common/tmsg.h
浏览文件 @
bed4c349
...
...
@@ -1056,6 +1056,43 @@ typedef struct STaskDropRsp {
int32_t
code
;
}
STaskDropRsp
;
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
int8_t
igExists
;
int32_t
execLen
;
void
*
executor
;
int32_t
sqlLen
;
char
*
sql
;
}
SCreateTopicMsg
;
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
int8_t
igNotExists
;
}
SDropTopicMsg
;
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
int8_t
alterType
;
SSchema
schema
;
}
SAlterTopicMsg
;
typedef
struct
{
SMsgHead
head
;
char
name
[
TSDB_TABLE_FNAME_LEN
];
uint64_t
tuid
;
int32_t
sverson
;
int32_t
execLen
;
char
*
executor
;
int32_t
sqlLen
;
char
*
sql
;
}
SCreateTopicInternalMsg
;
typedef
struct
{
SMsgHead
head
;
char
name
[
TSDB_TABLE_FNAME_LEN
];
uint64_t
tuid
;
}
SDropTopicInternalMsg
;
#pragma pack(pop)
#ifdef __cplusplus
...
...
include/common/tname.h
浏览文件 @
bed4c349
...
...
@@ -16,18 +16,22 @@
#ifndef TDENGINE_TNAME_H
#define TDENGINE_TNAME_H
#include "tdef.h"
#define TSDB_DB_NAME_T 1
#define TSDB_TABLE_NAME_T 2
#define T_NAME_ACCT 0x1u
#define T_NAME_DB 0x2u
#define T_NAME_TABLE 0x4u
#define T_NAME_TOPIC 0x8u
typedef
struct
SName
{
uint8_t
type
;
//db_name_t, table_name_t
int32_t
acctId
;
char
dbname
[
TSDB_DB_NAME_LEN
];
char
tname
[
TSDB_TABLE_NAME_LEN
];
char
topicName
[
TSDB_TOPIC_NAME_LEN
];
}
SName
;
int32_t
tNameExtractFullName
(
const
SName
*
name
,
char
*
dst
);
...
...
include/dnode/mnode/sdb/sdb.h
浏览文件 @
bed4c349
...
...
@@ -16,6 +16,8 @@
#ifndef _TD_SDB_H_
#define _TD_SDB_H_
#include "os.h"
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
@@ -159,11 +161,12 @@ typedef enum {
SDB_USER
=
5
,
SDB_AUTH
=
6
,
SDB_ACCT
=
7
,
SDB_VGROUP
=
8
,
SDB_STB
=
9
,
SDB_DB
=
10
,
SDB_FUNC
=
11
,
SDB_MAX
=
12
SDB_TOPIC
=
8
,
SDB_VGROUP
=
9
,
SDB_STB
=
10
,
SDB_DB
=
11
,
SDB_FUNC
=
12
,
SDB_MAX
=
13
}
ESdbType
;
typedef
struct
SSdb
SSdb
;
...
...
include/util/taoserror.h
浏览文件 @
bed4c349
...
...
@@ -220,6 +220,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_COLUMN_ALREAY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AA)
#define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AB)
#define TSDB_CODE_MND_EXCEED_MAX_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x03AC)
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03AD)
// mnode-func
#define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03C0)
...
...
@@ -234,6 +235,15 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_TRANS_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03D0)
#define TSDB_CODE_MND_TRANS_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03D1)
// mnode-topic
#define TSDB_CODE_MND_TOPIC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03E0)
#define TSDB_CODE_MND_TOPIC_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03E1)
#define TSDB_CODE_MND_TOO_MANY_TOPICS TAOS_DEF_ERROR_CODE(0, 0x03E2)
#define TSDB_CODE_MND_INVALID_TOPIC TAOS_DEF_ERROR_CODE(0, 0x03E3)
#define TSDB_CODE_MND_INVALID_TOPIC_OPTION TAOS_DEF_ERROR_CODE(0, 0x03E4)
#define TSDB_CODE_MND_TOPIC_OPTION_UNCHNAGED TAOS_DEF_ERROR_CODE(0, 0x03E5)
#define TSDB_CODE_MND_NAME_CONFLICT_WITH_STB TAOS_DEF_ERROR_CODE(0, 0x03E6)
// dnode
#define TSDB_CODE_DND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0400)
#define TSDB_CODE_DND_EXITING TAOS_DEF_ERROR_CODE(0, 0x0401)
...
...
include/util/tdef.h
浏览文件 @
bed4c349
...
...
@@ -163,6 +163,7 @@ do { \
#define TSDB_NODE_NAME_LEN 64
#define TSDB_TABLE_NAME_LEN 193 // it is a null-terminated string
#define TSDB_TOPIC_NAME_LEN 193 // it is a null-terminated string
#define TSDB_DB_NAME_LEN 65
#define TSDB_FULL_DB_NAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN)
...
...
@@ -175,6 +176,7 @@ do { \
#define TSDB_TYPE_STR_MAX_LEN 32
#define TSDB_TABLE_FNAME_LEN (TSDB_FULL_DB_NAME_LEN + TSDB_TABLE_NAME_LEN)
#define TSDB_TOPIC_FNAME_LEN TSDB_TABLE_FNAME_LEN
#define TSDB_COL_NAME_LEN 65
#define TSDB_MAX_SAVED_SQL_LEN TSDB_MAX_COLUMNS * 64
#define TSDB_MAX_SQL_LEN TSDB_PAYLOAD_SIZE
...
...
source/dnode/mgmt/impl/src/dndVnodes.c
浏览文件 @
bed4c349
...
...
@@ -829,6 +829,7 @@ static void dndProcessVnodeWriteQueue(SVnodeObj *pVnode, taos_qall qall, int32_t
SRpcMsg
*
pMsg
=
*
(
SRpcMsg
**
)
taosArrayGet
(
pArray
,
i
);
int32_t
code
=
vnodeApplyWMsg
(
pVnode
->
pImpl
,
pMsg
,
&
pRsp
);
if
(
pRsp
!=
NULL
)
{
pRsp
->
ahandle
=
pMsg
->
ahandle
;
rpcSendResponse
(
pRsp
);
free
(
pRsp
);
}
else
{
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
bed4c349
...
...
@@ -285,6 +285,21 @@ typedef struct {
char
payload
[];
}
SShowObj
;
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
db
[
TSDB_FULL_DB_NAME_LEN
];
int64_t
createTime
;
int64_t
updateTime
;
uint64_t
uid
;
uint64_t
dbUid
;
int32_t
version
;
SRWLatch
lock
;
int32_t
execLen
;
void
*
executor
;
int32_t
sqlLen
;
char
*
sql
;
}
STopicObj
;
typedef
struct
SMnodeMsg
{
char
user
[
TSDB_USER_LEN
];
char
db
[
TSDB_FULL_DB_NAME_LEN
];
...
...
source/dnode/mnode/impl/inc/mndStb.h
浏览文件 @
bed4c349
...
...
@@ -25,6 +25,9 @@ extern "C" {
int32_t
mndInitStb
(
SMnode
*
pMnode
);
void
mndCleanupStb
(
SMnode
*
pMnode
);
SStbObj
*
mndAcquireStb
(
SMnode
*
pMnode
,
char
*
stbName
);
void
mndReleaseStb
(
SMnode
*
pMnode
,
SStbObj
*
pStb
);
#ifdef __cplusplus
}
#endif
...
...
source/dnode/mnode/impl/inc/mndTopic.h
0 → 100644
浏览文件 @
bed4c349
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_MND_TOPIC_H_
#define _TD_MND_TOPIC_H_
#include "mndInt.h"
#ifdef __cplusplus
extern
"C"
{
#endif
int32_t
mndInitTopic
(
SMnode
*
pMnode
);
void
mndCleanupTopic
(
SMnode
*
pMnode
);
STopicObj
*
mndAcquireTopic
(
SMnode
*
pMnode
,
char
*
topicName
);
void
mndReleaseTopic
(
SMnode
*
pMnode
,
STopicObj
*
pTopic
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_MND_TOPIC_H_*/
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
bed4c349
...
...
@@ -541,6 +541,15 @@ static int32_t mndSetDbCfgFromAlterDbMsg(SDbObj *pDb, SAlterDbMsg *pAlter) {
}
static
int32_t
mndSetUpdateDbRedoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pOldDb
,
SDbObj
*
pNewDb
)
{
SSdbRaw
*
pRedoRaw
=
mndDbActionEncode
(
pOldDb
);
if
(
pRedoRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_UPDATING
)
!=
0
)
return
-
1
;
return
0
;
}
static
int32_t
mndSetUpdateDbCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pOldDb
,
SDbObj
*
pNewDb
)
{
SSdbRaw
*
pRedoRaw
=
mndDbActionEncode
(
pNewDb
);
if
(
pRedoRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
return
-
1
;
...
...
@@ -549,24 +558,57 @@ static int32_t mndSetUpdateDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pO
return
0
;
}
static
int32_t
mndSetUpdateDbUndoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pOldDb
,
SDbObj
*
pNewDb
)
{
SSdbRaw
*
pUndoRaw
=
mndDbActionEncode
(
pOldDb
);
if
(
pUndoRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_READY
)
!=
0
)
return
-
1
;
static
int32_t
mndBuildUpdateVgroupAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
)
{
for
(
int32_t
vn
=
0
;
vn
<
pVgroup
->
replica
;
++
vn
)
{
STransAction
action
=
{
0
};
SVnodeGid
*
pVgid
=
pVgroup
->
vnodeGid
+
vn
;
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pVgid
->
dnodeId
);
if
(
pDnode
==
NULL
)
return
-
1
;
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
SAlterVnodeMsg
*
pMsg
=
(
SAlterVnodeMsg
*
)
mndBuildCreateVnodeMsg
(
pMnode
,
pDnode
,
pDb
,
pVgroup
);
if
(
pMsg
==
NULL
)
return
-
1
;
action
.
pCont
=
pMsg
;
action
.
contLen
=
sizeof
(
SAlterVnodeMsg
);
action
.
msgType
=
TSDB_MSG_TYPE_ALTER_VNODE_IN
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
pMsg
);
return
-
1
;
}
}
return
0
;
}
static
int32_t
mndSetUpdateDbCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pOldDb
,
SDbObj
*
pNewDb
)
{
return
0
;
}
static
int32_t
mndSetUpdateDbRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pOldDb
,
SDbObj
*
pNewDb
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
static
int32_t
mndSetUpdateDbRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pOldDb
,
SDbObj
*
pNewDb
)
{
return
0
;
}
while
(
1
)
{
SVgObj
*
pVgroup
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
static
int32_t
mndSetUpdateDbUndoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pOldDb
,
SDbObj
*
pNewDb
)
{
return
0
;
}
if
(
pVgroup
->
dbUid
==
pNewDb
->
uid
)
{
if
(
mndBuildUpdateVgroupAction
(
pMnode
,
pTrans
,
pNewDb
,
pVgroup
)
!=
0
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
return
-
1
;
}
}
sdbRelease
(
pSdb
,
pVgroup
);
}
return
0
;
}
static
int32_t
mndUpdateDb
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SDbObj
*
pOldDb
,
SDbObj
*
pNewDb
)
{
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_R
OLLBACK
,
pMsg
->
rpcMsg
.
handle
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_R
ETRY
,
pMsg
->
rpcMsg
.
handle
);
if
(
pTrans
==
NULL
)
{
mError
(
"db:%s, failed to update since %s"
,
pOldDb
->
name
,
terrstr
());
return
terrno
;
...
...
@@ -579,11 +621,6 @@ static int32_t mndUpdateDb(SMnode *pMnode, SMnodeMsg *pMsg, SDbObj *pOldDb, SDbO
goto
UPDATE_DB_OVER
;
}
if
(
mndSetUpdateDbUndoLogs
(
pMnode
,
pTrans
,
pOldDb
,
pNewDb
)
!=
0
)
{
mError
(
"trans:%d, failed to set undo log since %s"
,
pTrans
->
id
,
terrstr
());
goto
UPDATE_DB_OVER
;
}
if
(
mndSetUpdateDbCommitLogs
(
pMnode
,
pTrans
,
pOldDb
,
pNewDb
)
!=
0
)
{
mError
(
"trans:%d, failed to set commit log since %s"
,
pTrans
->
id
,
terrstr
());
goto
UPDATE_DB_OVER
;
...
...
@@ -594,11 +631,6 @@ static int32_t mndUpdateDb(SMnode *pMnode, SMnodeMsg *pMsg, SDbObj *pOldDb, SDbO
goto
UPDATE_DB_OVER
;
}
if
(
mndSetUpdateDbUndoActions
(
pMnode
,
pTrans
,
pOldDb
,
pNewDb
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo actions since %s"
,
pTrans
->
id
,
terrstr
());
goto
UPDATE_DB_OVER
;
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
goto
UPDATE_DB_OVER
;
...
...
@@ -660,31 +692,87 @@ static int32_t mndSetDropDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb)
return
0
;
}
static
int32_t
mndSetDropDbUndoLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
)
{
SSdbRaw
*
pUndoRaw
=
mndDbActionEncode
(
pDb
);
if
(
pUndoRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_READY
)
!=
0
)
return
-
1
;
return
0
;
}
static
int32_t
mndSetDropDbCommitLogs
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
)
{
SSdbRaw
*
pCommitRaw
=
mndDbActionEncode
(
pDb
);
if
(
pCommitRaw
==
NULL
)
return
-
1
;
if
(
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
return
-
1
;
if
(
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_DROPPED
)
!=
0
)
return
-
1
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
while
(
1
)
{
SVgObj
*
pVgroup
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
if
(
pVgroup
->
dbUid
==
pDb
->
uid
)
{
SSdbRaw
*
pVgRaw
=
mndVgroupActionEncode
(
pVgroup
);
if
(
pVgRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pVgRaw
)
!=
0
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
return
-
1
;
}
sdbSetRawStatus
(
pVgRaw
,
SDB_STATUS_DROPPED
);
}
sdbRelease
(
pSdb
,
pVgroup
);
}
return
0
;
}
static
int32_t
mndBuildDropVgroupAction
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SVgObj
*
pVgroup
)
{
for
(
int32_t
vn
=
0
;
vn
<
pVgroup
->
replica
;
++
vn
)
{
STransAction
action
=
{
0
};
SVnodeGid
*
pVgid
=
pVgroup
->
vnodeGid
+
vn
;
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pVgid
->
dnodeId
);
if
(
pDnode
==
NULL
)
return
-
1
;
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
mndReleaseDnode
(
pMnode
,
pDnode
);
SDropVnodeMsg
*
pMsg
=
mndBuildDropVnodeMsg
(
pMnode
,
pDnode
,
pDb
,
pVgroup
);
if
(
pMsg
==
NULL
)
return
-
1
;
action
.
pCont
=
pMsg
;
action
.
contLen
=
sizeof
(
SCreateVnodeMsg
);
action
.
msgType
=
TSDB_MSG_TYPE_DROP_VNODE_IN
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
pMsg
);
return
-
1
;
}
}
return
0
;
}
static
int32_t
mndSetDropDbRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
)
{
return
0
;
}
static
int32_t
mndSetDropDbRedoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
void
*
pIter
=
NULL
;
static
int32_t
mndSetDropDbUndoActions
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
)
{
return
0
;
}
while
(
1
)
{
SVgObj
*
pVgroup
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
if
(
pVgroup
->
dbUid
==
pDb
->
uid
)
{
if
(
mndBuildDropVgroupAction
(
pMnode
,
pTrans
,
pDb
,
pVgroup
)
!=
0
)
{
sdbCancelFetch
(
pSdb
,
pIter
);
sdbRelease
(
pSdb
,
pVgroup
);
return
-
1
;
}
}
sdbRelease
(
pSdb
,
pVgroup
);
}
return
0
;
}
static
int32_t
mndDropDb
(
SMnode
*
pMnode
,
SMnodeMsg
*
pMsg
,
SDbObj
*
pDb
)
{
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_R
OLLBACK
,
pMsg
->
rpcMsg
.
handle
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_R
ETRY
,
pMsg
->
rpcMsg
.
handle
);
if
(
pTrans
==
NULL
)
{
mError
(
"db:%s, failed to drop since %s"
,
pDb
->
name
,
terrstr
());
return
-
1
;
...
...
@@ -697,11 +785,6 @@ static int32_t mndDropDb(SMnode *pMnode, SMnodeMsg *pMsg, SDbObj *pDb) {
goto
DROP_DB_OVER
;
}
if
(
mndSetDropDbUndoLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
{
mError
(
"trans:%d, failed to set undo log since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_DB_OVER
;
}
if
(
mndSetDropDbCommitLogs
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
{
mError
(
"trans:%d, failed to set commit log since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_DB_OVER
;
...
...
@@ -712,11 +795,6 @@ static int32_t mndDropDb(SMnode *pMnode, SMnodeMsg *pMsg, SDbObj *pDb) {
goto
DROP_DB_OVER
;
}
if
(
mndSetDropDbUndoActions
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo actions since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_DB_OVER
;
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_DB_OVER
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
bed4c349
...
...
@@ -484,6 +484,15 @@ static int32_t mndProcessCreateStbMsg(SMnodeMsg *pMsg) {
}
}
//topic should have different name with stb
SStbObj
*
pTopic
=
mndAcquireStb
(
pMnode
,
pCreate
->
name
);
if
(
pTopic
!=
NULL
)
{
sdbRelease
(
pMnode
->
pSdb
,
pTopic
);
terrno
=
TSDB_CODE_MND_NAME_CONFLICT_WITH_TOPIC
;
mError
(
"stb:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
SDbObj
*
pDb
=
mndAcquireDbByStb
(
pMnode
,
pCreate
->
name
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_DB_NOT_SELECTED
;
...
...
@@ -891,4 +900,4 @@ static int32_t mndRetrieveStb(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int3
static
void
mndCancelGetNextStb
(
SMnode
*
pMnode
,
void
*
pIter
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
sdbCancelFetch
(
pSdb
,
pIter
);
}
\ No newline at end of file
}
source/dnode/mnode/impl/src/mndTopic.c
0 → 100644
浏览文件 @
bed4c349
此差异已折叠。
点击以展开。
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
bed4c349
...
...
@@ -696,7 +696,8 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA
for
(
int32_t
action
=
0
;
action
<
numOfActions
;
++
action
)
{
STransAction
*
pAction
=
taosArrayGet
(
pArray
,
action
);
if
(
pAction
==
NULL
)
continue
;
if
(
pAction
->
msgReceived
&&
pAction
->
errCode
==
0
)
continue
;
if
(
pAction
->
msgSent
&&
!
pAction
->
msgReceived
)
continue
;
if
(
pAction
->
msgSent
&&
pAction
->
msgReceived
&&
pAction
->
errCode
==
0
)
continue
;
int64_t
signature
=
pTrans
->
id
;
signature
=
(
signature
<<
32
);
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
bed4c349
...
...
@@ -337,8 +337,16 @@ static int32_t mndProcessCreateVnodeRsp(SMnodeMsg *pMsg) {
return
0
;
}
static
int32_t
mndProcessAlterVnodeRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessDropVnodeRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessAlterVnodeRsp
(
SMnodeMsg
*
pMsg
)
{
mndTransHandleActionRsp
(
pMsg
);
return
0
;
}
static
int32_t
mndProcessDropVnodeRsp
(
SMnodeMsg
*
pMsg
)
{
mndTransHandleActionRsp
(
pMsg
);
return
0
;
}
static
int32_t
mndProcessSyncVnodeRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
static
int32_t
mndProcessCompactVnodeRsp
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
bed4c349
...
...
@@ -27,6 +27,7 @@
#include "mndStb.h"
#include "mndSync.h"
#include "mndTelem.h"
#include "mndTopic.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndVgroup.h"
...
...
@@ -132,6 +133,7 @@ static int32_t mndInitSteps(SMnode *pMnode) {
if
(
mndAllocStep
(
pMnode
,
"mnode-db"
,
mndInitDb
,
mndCleanupDb
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-vgroup"
,
mndInitVgroup
,
mndCleanupVgroup
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-stb"
,
mndInitStb
,
mndCleanupStb
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-topic"
,
mndInitTopic
,
mndCleanupTopic
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-func"
,
mndInitFunc
,
mndCleanupFunc
)
!=
0
)
return
-
1
;
if
(
pMnode
->
clusterId
<=
0
)
{
if
(
mndAllocStep
(
pMnode
,
"mnode-sdb-deploy"
,
mndDeploySdb
,
NULL
)
!=
0
)
return
-
1
;
...
...
@@ -227,7 +229,7 @@ static int32_t mndSetOptions(SMnode *pMnode, const SMnodeOpt *pOption) {
}
return
0
;
}
}
SMnode
*
mndOpen
(
const
char
*
path
,
const
SMnodeOpt
*
pOption
)
{
mDebug
(
"start to open mnode in %s"
,
path
);
...
...
@@ -442,4 +444,4 @@ uint64_t mndGenerateUid(char *name, int32_t len) {
int32_t
hashval
=
MurmurHash3_32
(
name
,
len
);
uint64_t
x
=
(
us
&
0x000000FFFFFFFFFF
)
<<
24
;
return
x
+
((
hashval
&
((
1ul
<<
16
)
-
1ul
))
<<
8
)
+
(
taosRand
()
&
((
1ul
<<
8
)
-
1ul
));
}
\ No newline at end of file
}
source/dnode/mnode/sdb/src/sdbHash.c
浏览文件 @
bed4c349
...
...
@@ -199,6 +199,7 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, void *pKey) {
SSdbRow
*
pRow
=
*
ppRow
;
switch
(
pRow
->
status
)
{
case
SDB_STATUS_READY
:
case
SDB_STATUS_UPDATING
:
atomic_add_fetch_32
(
&
pRow
->
refCount
,
1
);
pRet
=
pRow
->
pObj
;
break
;
...
...
tests/script/general/db/basic1.sim
浏览文件 @
bed4c349
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print =============== create database
...
...
tests/script/general/table/basic1.sim
浏览文件 @
bed4c349
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
print =============== create database
...
...
@@ -13,29 +12,24 @@ endi
print $data00 $data01 $data02
print =============== create normal table
sql create table d1.n1 (ts timestamp, i int)
sql show d1.tables
if $rows != 1 then
return -1
endi
print $data00 $data01 $data02
sql use d1
print =============== create super table
sql create table
d1.
st (ts timestamp, i int) tags (j int)
sql show
d1.
stables
sql create table st (ts timestamp, i int) tags (j int)
sql show stables
if $rows != 1 then
return -1
endi
print $data00 $data01 $data02
return
print =============== create child table
sql create table
d1.c1 using d1.
st tags(1)
sql create table
d1.c2 using d1.
st tags(2)
sql show
d1.
tables
if $rows !=
3
then
sql create table
c1 using
st tags(1)
sql create table
c2 using
st tags(2)
sql show tables
if $rows !=
2
then
return -1
endi
...
...
@@ -44,12 +38,12 @@ print $data10 $data11 $data22
print $data20 $data11 $data22
print =============== insert data
sql insert into
d1.n
1 values(now+1s, 1)
sql insert into
d1.n
1 values(now+2s, 2)
sql insert into
d1.n
1 values(now+3s, 3)
sql insert into
c
1 values(now+1s, 1)
sql insert into
c
1 values(now+2s, 2)
sql insert into
c
1 values(now+3s, 3)
print =============== query data
sql select * from
d1.n
1
sql select * from
c
1
if $rows != 3 then
return -1
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录