Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小楼昨夜-听风雨
TDengine
提交
97e41cdf
T
TDengine
项目概览
小楼昨夜-听风雨
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
97e41cdf
编写于
11月 18, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-2046
上级
f38b2182
变更
11
展开全部
显示空白变更内容
内联
并排
Showing
11 changed file
with
563 addition
and
560 deletion
+563
-560
src/mnode/inc/mnodeSdb.h
src/mnode/inc/mnodeSdb.h
+27
-25
src/mnode/src/mnodeAcct.c
src/mnode/src/mnodeAcct.c
+21
-21
src/mnode/src/mnodeCluster.c
src/mnode/src/mnodeCluster.c
+17
-17
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+50
-50
src/mnode/src/mnodeDnode.c
src/mnode/src/mnodeDnode.c
+33
-33
src/mnode/src/mnodeMnode.c
src/mnode/src/mnodeMnode.c
+29
-29
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+101
-100
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+167
-167
src/mnode/src/mnodeUser.c
src/mnode/src/mnodeUser.c
+39
-39
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+65
-65
tests/script/sh/deploy.sh
tests/script/sh/deploy.sh
+14
-14
未找到文件。
src/mnode/inc/mnodeSdb.h
浏览文件 @
97e41cdf
...
...
@@ -20,7 +20,9 @@
extern
"C"
{
#endif
struct
SMnodeMsg
;
#include "mnode.h"
struct
SSdbTable
;
typedef
enum
{
SDB_TABLE_CLUSTER
=
0
,
...
...
@@ -36,32 +38,32 @@ typedef enum {
}
ESdbTable
;
typedef
enum
{
SDB_KEY_STRING
,
SDB_KEY_INT
,
SDB_KEY_AUTO
,
SDB_KEY_VAR_STRING
,
SDB_KEY_STRING
=
0
,
SDB_KEY_INT
=
1
,
SDB_KEY_AUTO
=
2
,
SDB_KEY_VAR_STRING
=
3
,
}
ESdbKey
;
typedef
enum
{
SDB_OPER_GLOBAL
,
SDB_OPER_LOCAL
SDB_OPER_GLOBAL
=
0
,
SDB_OPER_LOCAL
=
1
}
ESdbOper
;
typedef
struct
SSWriteMsg
{
ESdbOper
type
;
int32_t
rowSize
;
int32_t
retCode
;
// for callback in sdb queue
int32_t
processedCount
;
// for sync fwd callback
int32_t
(
*
reqFp
)(
struct
SMnodeMsg
*
pMsg
);
int32_t
(
*
writeCb
)(
struct
SMnodeMsg
*
pMsg
,
int32_t
code
);
void
*
table
;
void
*
pObj
;
int32_t
retCode
;
// for callback in sdb queue
int32_t
rowSize
;
void
*
rowData
;
struct
SMnodeMsg
*
pMsg
;
int32_t
(
*
fpReq
)(
SMnodeMsg
*
pMsg
);
int32_t
(
*
fpWrite
)(
SMnodeMsg
*
pMsg
,
int32_t
code
);
void
*
pObj
;
SMnodeMsg
*
pMsg
;
struct
SSdbTable
*
pTable
;
}
SSWriteMsg
;
typedef
struct
{
char
*
tableName
;
char
*
tableName
;
int32_t
hashSessions
;
int32_t
maxRowSize
;
int32_t
refCountPos
;
...
...
@@ -89,15 +91,15 @@ int32_t sdbDeleteRow(SSWriteMsg *pWrite);
int32_t
sdbUpdateRow
(
SSWriteMsg
*
pWrite
);
int32_t
sdbInsertRowImp
(
SSWriteMsg
*
pWrite
);
void
*
sdbGetRow
(
void
*
hand
le
,
void
*
key
);
void
*
sdbFetchRow
(
void
*
hand
le
,
void
*
pIter
,
void
**
ppRow
);
void
*
sdbGetRow
(
void
*
pTab
le
,
void
*
key
);
void
*
sdbFetchRow
(
void
*
pTab
le
,
void
*
pIter
,
void
**
ppRow
);
void
sdbFreeIter
(
void
*
pIter
);
void
sdbIncRef
(
void
*
thand
le
,
void
*
pRow
);
void
sdbDecRef
(
void
*
thand
le
,
void
*
pRow
);
int64_t
sdbGetNumOfRows
(
void
*
hand
le
);
int32_t
sdbGetId
(
void
*
hand
le
);
void
sdbIncRef
(
void
*
pTab
le
,
void
*
pRow
);
void
sdbDecRef
(
void
*
pTab
le
,
void
*
pRow
);
int64_t
sdbGetNumOfRows
(
void
*
pTab
le
);
int32_t
sdbGetId
(
void
*
pTab
le
);
uint64_t
sdbGetVersion
();
bool
sdbCheckRowDeleted
(
void
*
thand
le
,
void
*
pRow
);
bool
sdbCheckRowDeleted
(
void
*
pTab
le
,
void
*
pRow
);
#ifdef __cplusplus
}
...
...
src/mnode/src/mnodeAcct.c
浏览文件 @
97e41cdf
...
...
@@ -31,30 +31,30 @@ void * tsAcctSdb = NULL;
static
int32_t
tsAcctUpdateSize
;
static
int32_t
mnodeCreateRootAcct
();
static
int32_t
mnodeAcctActionDestroy
(
SSWriteMsg
*
p
Oper
)
{
SAcctObj
*
pAcct
=
p
Oper
->
pObj
;
static
int32_t
mnodeAcctActionDestroy
(
SSWriteMsg
*
p
WMsg
)
{
SAcctObj
*
pAcct
=
p
WMsg
->
pObj
;
pthread_mutex_destroy
(
&
pAcct
->
mutex
);
tfree
(
p
Oper
->
pObj
);
tfree
(
p
WMsg
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeAcctActionInsert
(
SSWriteMsg
*
p
Oper
)
{
SAcctObj
*
pAcct
=
p
Oper
->
pObj
;
static
int32_t
mnodeAcctActionInsert
(
SSWriteMsg
*
p
WMsg
)
{
SAcctObj
*
pAcct
=
p
WMsg
->
pObj
;
memset
(
&
pAcct
->
acctInfo
,
0
,
sizeof
(
SAcctInfo
));
pAcct
->
acctInfo
.
accessState
=
TSDB_VN_ALL_ACCCESS
;
pthread_mutex_init
(
&
pAcct
->
mutex
,
NULL
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeAcctActionDelete
(
SSWriteMsg
*
p
Oper
)
{
SAcctObj
*
pAcct
=
p
Oper
->
pObj
;
static
int32_t
mnodeAcctActionDelete
(
SSWriteMsg
*
p
WMsg
)
{
SAcctObj
*
pAcct
=
p
WMsg
->
pObj
;
mnodeDropAllUsers
(
pAcct
);
mnodeDropAllDbs
(
pAcct
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeAcctActionUpdate
(
SSWriteMsg
*
p
Oper
)
{
SAcctObj
*
pAcct
=
p
Oper
->
pObj
;
static
int32_t
mnodeAcctActionUpdate
(
SSWriteMsg
*
p
WMsg
)
{
SAcctObj
*
pAcct
=
p
WMsg
->
pObj
;
SAcctObj
*
pSaved
=
mnodeGetAcct
(
pAcct
->
user
);
if
(
pAcct
!=
pSaved
)
{
memcpy
(
pSaved
,
pAcct
,
tsAcctUpdateSize
);
...
...
@@ -64,19 +64,19 @@ static int32_t mnodeAcctActionUpdate(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeAcctActionEncode
(
SSWriteMsg
*
p
Oper
)
{
SAcctObj
*
pAcct
=
p
Oper
->
pObj
;
memcpy
(
p
Oper
->
rowData
,
pAcct
,
tsAcctUpdateSize
);
p
Oper
->
rowSize
=
tsAcctUpdateSize
;
static
int32_t
mnodeAcctActionEncode
(
SSWriteMsg
*
p
WMsg
)
{
SAcctObj
*
pAcct
=
p
WMsg
->
pObj
;
memcpy
(
p
WMsg
->
rowData
,
pAcct
,
tsAcctUpdateSize
);
p
WMsg
->
rowSize
=
tsAcctUpdateSize
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeAcctActionDecode
(
SSWriteMsg
*
p
Oper
)
{
static
int32_t
mnodeAcctActionDecode
(
SSWriteMsg
*
p
WMsg
)
{
SAcctObj
*
pAcct
=
(
SAcctObj
*
)
calloc
(
1
,
sizeof
(
SAcctObj
));
if
(
pAcct
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pAcct
,
p
Oper
->
rowData
,
tsAcctUpdateSize
);
p
Oper
->
pObj
=
pAcct
;
memcpy
(
pAcct
,
p
WMsg
->
rowData
,
tsAcctUpdateSize
);
p
WMsg
->
pObj
=
pAcct
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -226,13 +226,13 @@ static int32_t mnodeCreateRootAcct() {
pAcct
->
acctId
=
sdbGetId
(
tsAcctSdb
);
pAcct
->
createdTime
=
taosGetTimestampMs
();
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsAcctSdb
,
.
pT
able
=
tsAcctSdb
,
.
pObj
=
pAcct
,
};
return
sdbInsertRow
(
&
oper
);
return
sdbInsertRow
(
&
wmsg
);
}
#ifndef _ACCT
...
...
src/mnode/src/mnodeCluster.c
浏览文件 @
97e41cdf
...
...
@@ -32,36 +32,36 @@ static int32_t mnodeCreateCluster();
static
int32_t
mnodeGetClusterMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeRetrieveClusters
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeClusterActionDestroy
(
SSWriteMsg
*
p
Oper
)
{
tfree
(
p
Oper
->
pObj
);
static
int32_t
mnodeClusterActionDestroy
(
SSWriteMsg
*
p
WMsg
)
{
tfree
(
p
WMsg
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeClusterActionInsert
(
SSWriteMsg
*
p
Oper
)
{
static
int32_t
mnodeClusterActionInsert
(
SSWriteMsg
*
p
WMsg
)
{
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeClusterActionDelete
(
SSWriteMsg
*
p
Oper
)
{
static
int32_t
mnodeClusterActionDelete
(
SSWriteMsg
*
p
WMsg
)
{
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeClusterActionUpdate
(
SSWriteMsg
*
p
Oper
)
{
static
int32_t
mnodeClusterActionUpdate
(
SSWriteMsg
*
p
WMsg
)
{
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeClusterActionEncode
(
SSWriteMsg
*
p
Oper
)
{
SClusterObj
*
pCluster
=
p
Oper
->
pObj
;
memcpy
(
p
Oper
->
rowData
,
pCluster
,
tsClusterUpdateSize
);
p
Oper
->
rowSize
=
tsClusterUpdateSize
;
static
int32_t
mnodeClusterActionEncode
(
SSWriteMsg
*
p
WMsg
)
{
SClusterObj
*
pCluster
=
p
WMsg
->
pObj
;
memcpy
(
p
WMsg
->
rowData
,
pCluster
,
tsClusterUpdateSize
);
p
WMsg
->
rowSize
=
tsClusterUpdateSize
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeClusterActionDecode
(
SSWriteMsg
*
p
Oper
)
{
static
int32_t
mnodeClusterActionDecode
(
SSWriteMsg
*
p
WMsg
)
{
SClusterObj
*
pCluster
=
(
SClusterObj
*
)
calloc
(
1
,
sizeof
(
SClusterObj
));
if
(
pCluster
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pCluster
,
p
Oper
->
rowData
,
tsClusterUpdateSize
);
p
Oper
->
pObj
=
pCluster
;
memcpy
(
pCluster
,
p
WMsg
->
rowData
,
tsClusterUpdateSize
);
p
WMsg
->
pObj
=
pCluster
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -145,13 +145,13 @@ static int32_t mnodeCreateCluster() {
mDebug
(
"uid is %s"
,
pCluster
->
uid
);
}
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsClusterSdb
,
.
pT
able
=
tsClusterSdb
,
.
pObj
=
pCluster
,
};
return
sdbInsertRow
(
&
oper
);
return
sdbInsertRow
(
&
wmsg
);
}
const
char
*
mnodeGetClusterId
()
{
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
97e41cdf
...
...
@@ -56,8 +56,8 @@ static void mnodeDestroyDb(SDbObj *pDb) {
tfree
(
pDb
);
}
static
int32_t
mnodeDbActionDestroy
(
SSWriteMsg
*
p
Oper
)
{
mnodeDestroyDb
(
p
Oper
->
pObj
);
static
int32_t
mnodeDbActionDestroy
(
SSWriteMsg
*
p
WMsg
)
{
mnodeDestroyDb
(
p
WMsg
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -65,8 +65,8 @@ int64_t mnodeGetDbNum() {
return
sdbGetNumOfRows
(
tsDbSdb
);
}
static
int32_t
mnodeDbActionInsert
(
SSWriteMsg
*
p
Oper
)
{
SDbObj
*
pDb
=
p
Oper
->
pObj
;
static
int32_t
mnodeDbActionInsert
(
SSWriteMsg
*
p
WMsg
)
{
SDbObj
*
pDb
=
p
WMsg
->
pObj
;
SAcctObj
*
pAcct
=
mnodeGetAcct
(
pDb
->
acct
);
pthread_mutex_init
(
&
pDb
->
mutex
,
NULL
);
...
...
@@ -91,8 +91,8 @@ static int32_t mnodeDbActionInsert(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeDbActionDelete
(
SSWriteMsg
*
p
Oper
)
{
SDbObj
*
pDb
=
p
Oper
->
pObj
;
static
int32_t
mnodeDbActionDelete
(
SSWriteMsg
*
p
WMsg
)
{
SDbObj
*
pDb
=
p
WMsg
->
pObj
;
SAcctObj
*
pAcct
=
mnodeGetAcct
(
pDb
->
acct
);
mnodeDropAllChildTables
(
pDb
);
...
...
@@ -107,11 +107,11 @@ static int32_t mnodeDbActionDelete(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeDbActionUpdate
(
SSWriteMsg
*
p
Oper
)
{
SDbObj
*
pNew
=
p
Oper
->
pObj
;
static
int32_t
mnodeDbActionUpdate
(
SSWriteMsg
*
p
WMsg
)
{
SDbObj
*
pNew
=
p
WMsg
->
pObj
;
SDbObj
*
pDb
=
mnodeGetDb
(
pNew
->
name
);
if
(
pDb
!=
NULL
&&
pNew
!=
pDb
)
{
memcpy
(
pDb
,
pNew
,
p
Oper
->
rowSize
);
memcpy
(
pDb
,
pNew
,
p
WMsg
->
rowSize
);
free
(
pNew
->
vgList
);
free
(
pNew
);
}
...
...
@@ -120,19 +120,19 @@ static int32_t mnodeDbActionUpdate(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeDbActionEncode
(
SSWriteMsg
*
p
Oper
)
{
SDbObj
*
pDb
=
p
Oper
->
pObj
;
memcpy
(
p
Oper
->
rowData
,
pDb
,
tsDbUpdateSize
);
p
Oper
->
rowSize
=
tsDbUpdateSize
;
static
int32_t
mnodeDbActionEncode
(
SSWriteMsg
*
p
WMsg
)
{
SDbObj
*
pDb
=
p
WMsg
->
pObj
;
memcpy
(
p
WMsg
->
rowData
,
pDb
,
tsDbUpdateSize
);
p
WMsg
->
rowSize
=
tsDbUpdateSize
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeDbActionDecode
(
SSWriteMsg
*
p
Oper
)
{
static
int32_t
mnodeDbActionDecode
(
SSWriteMsg
*
p
WMsg
)
{
SDbObj
*
pDb
=
(
SDbObj
*
)
calloc
(
1
,
sizeof
(
SDbObj
));
if
(
pDb
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pDb
,
p
Oper
->
rowData
,
tsDbUpdateSize
);
p
Oper
->
pObj
=
pDb
;
memcpy
(
pDb
,
p
WMsg
->
rowData
,
tsDbUpdateSize
);
p
WMsg
->
pObj
=
pDb
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -412,16 +412,16 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
pMsg
->
pDb
=
pDb
;
mnodeIncDbRef
(
pDb
);
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsDbSdb
,
.
pT
able
=
tsDbSdb
,
.
pObj
=
pDb
,
.
rowSize
=
sizeof
(
SDbObj
),
.
pMsg
=
pMsg
,
.
writeCb
=
mnodeCreateDbCb
.
fpWrite
=
mnodeCreateDbCb
};
code
=
sdbInsertRow
(
&
oper
);
code
=
sdbInsertRow
(
&
wmsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"db:%s, failed to create, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
pMsg
->
pDb
=
NULL
;
...
...
@@ -440,8 +440,8 @@ bool mnodeCheckIsMonitorDB(char *db, char *monitordb) {
}
#if 0
void mnodePrintVgroups(SDbObj *pDb, char *
oper
) {
mInfo("db:%s, vgroup link from head,
oper:%s", pDb->name, oper
);
void mnodePrintVgroups(SDbObj *pDb, char *
wmsg
) {
mInfo("db:%s, vgroup link from head,
wmsg:%s", pDb->name, wmsg
);
SVgObj *pVgroup = pDb->pHead;
while (pVgroup != NULL) {
mInfo("vgId:%d", pVgroup->vgId);
...
...
@@ -807,13 +807,13 @@ static int32_t mnodeSetDbDropping(SDbObj *pDb) {
if
(
pDb
->
status
)
return
TSDB_CODE_SUCCESS
;
pDb
->
status
=
true
;
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsDbSdb
,
.
pT
able
=
tsDbSdb
,
.
pObj
=
pDb
};
int32_t
code
=
sdbUpdateRow
(
&
oper
);
int32_t
code
=
sdbUpdateRow
(
&
wmsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"db:%s, failed to set dropping state, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
}
...
...
@@ -1019,15 +1019,15 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
if
(
memcmp
(
&
newCfg
,
&
pDb
->
cfg
,
sizeof
(
SDbCfg
))
!=
0
)
{
pDb
->
cfg
=
newCfg
;
pDb
->
cfgVersion
++
;
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsDbSdb
,
.
pTable
=
tsDbSdb
,
.
pObj
=
pDb
,
.
pMsg
=
pMsg
,
.
writeCb
=
mnodeAlterDbCb
.
fpWrite
=
mnodeAlterDbCb
};
code
=
sdbUpdateRow
(
&
oper
);
code
=
sdbUpdateRow
(
&
wmsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"db:%s, failed to alter, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
}
...
...
@@ -1071,15 +1071,15 @@ static int32_t mnodeDropDb(SMnodeMsg *pMsg) {
SDbObj
*
pDb
=
pMsg
->
pDb
;
mInfo
(
"db:%s, drop db from sdb"
,
pDb
->
name
);
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsDbSdb
,
.
pT
able
=
tsDbSdb
,
.
pObj
=
pDb
,
.
pMsg
=
pMsg
,
.
writeCb
=
mnodeDropDbCb
.
fpWrite
=
mnodeDropDbCb
};
int32_t
code
=
sdbDeleteRow
(
&
oper
);
int32_t
code
=
sdbDeleteRow
(
&
wmsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"db:%s, failed to drop, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
}
...
...
@@ -1134,13 +1134,13 @@ void mnodeDropAllDbs(SAcctObj *pAcct) {
if
(
pDb
->
pAcct
==
pAcct
)
{
mInfo
(
"db:%s, drop db from sdb for acct:%s is dropped"
,
pDb
->
name
,
pAcct
->
user
);
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_LOCAL
,
.
t
able
=
tsDbSdb
,
.
pT
able
=
tsDbSdb
,
.
pObj
=
pDb
};
sdbDeleteRow
(
&
oper
);
sdbDeleteRow
(
&
wmsg
);
numOfDbs
++
;
}
mnodeDecDbRef
(
pDb
);
...
...
src/mnode/src/mnodeDnode.c
浏览文件 @
97e41cdf
...
...
@@ -87,13 +87,13 @@ static char* offlineReason[] = {
"unknown"
,
};
static
int32_t
mnodeDnodeActionDestroy
(
SSWriteMsg
*
p
Oper
)
{
tfree
(
p
Oper
->
pObj
);
static
int32_t
mnodeDnodeActionDestroy
(
SSWriteMsg
*
p
WMsg
)
{
tfree
(
p
WMsg
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeDnodeActionInsert
(
SSWriteMsg
*
p
Oper
)
{
SDnodeObj
*
pDnode
=
p
Oper
->
pObj
;
static
int32_t
mnodeDnodeActionInsert
(
SSWriteMsg
*
p
WMsg
)
{
SDnodeObj
*
pDnode
=
p
WMsg
->
pObj
;
if
(
pDnode
->
status
!=
TAOS_DN_STATUS_DROPPING
)
{
pDnode
->
status
=
TAOS_DN_STATUS_OFFLINE
;
pDnode
->
lastAccess
=
tsAccessSquence
;
...
...
@@ -107,8 +107,8 @@ static int32_t mnodeDnodeActionInsert(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeDnodeActionDelete
(
SSWriteMsg
*
p
Oper
)
{
SDnodeObj
*
pDnode
=
p
Oper
->
pObj
;
static
int32_t
mnodeDnodeActionDelete
(
SSWriteMsg
*
p
WMsg
)
{
SDnodeObj
*
pDnode
=
p
WMsg
->
pObj
;
#ifndef _SYNC
mnodeDropAllDnodeVgroups
(
pDnode
);
...
...
@@ -121,11 +121,11 @@ static int32_t mnodeDnodeActionDelete(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeDnodeActionUpdate
(
SSWriteMsg
*
p
Oper
)
{
SDnodeObj
*
pNew
=
p
Oper
->
pObj
;
static
int32_t
mnodeDnodeActionUpdate
(
SSWriteMsg
*
p
WMsg
)
{
SDnodeObj
*
pNew
=
p
WMsg
->
pObj
;
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pNew
->
dnodeId
);
if
(
pDnode
!=
NULL
&&
pNew
!=
pDnode
)
{
memcpy
(
pDnode
,
pNew
,
p
Oper
->
rowSize
);
memcpy
(
pDnode
,
pNew
,
p
WMsg
->
rowSize
);
free
(
pNew
);
}
mnodeDecDnodeRef
(
pDnode
);
...
...
@@ -134,19 +134,19 @@ static int32_t mnodeDnodeActionUpdate(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeDnodeActionEncode
(
SSWriteMsg
*
p
Oper
)
{
SDnodeObj
*
pDnode
=
p
Oper
->
pObj
;
memcpy
(
p
Oper
->
rowData
,
pDnode
,
tsDnodeUpdateSize
);
p
Oper
->
rowSize
=
tsDnodeUpdateSize
;
static
int32_t
mnodeDnodeActionEncode
(
SSWriteMsg
*
p
WMsg
)
{
SDnodeObj
*
pDnode
=
p
WMsg
->
pObj
;
memcpy
(
p
WMsg
->
rowData
,
pDnode
,
tsDnodeUpdateSize
);
p
WMsg
->
rowSize
=
tsDnodeUpdateSize
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeDnodeActionDecode
(
SSWriteMsg
*
p
Oper
)
{
static
int32_t
mnodeDnodeActionDecode
(
SSWriteMsg
*
p
WMsg
)
{
SDnodeObj
*
pDnode
=
(
SDnodeObj
*
)
calloc
(
1
,
sizeof
(
SDnodeObj
));
if
(
pDnode
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pDnode
,
p
Oper
->
rowData
,
tsDnodeUpdateSize
);
p
Oper
->
pObj
=
pDnode
;
memcpy
(
pDnode
,
p
WMsg
->
rowData
,
tsDnodeUpdateSize
);
p
WMsg
->
pObj
=
pDnode
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -296,13 +296,13 @@ void mnodeDecDnodeRef(SDnodeObj *pDnode) {
}
void
mnodeUpdateDnode
(
SDnodeObj
*
pDnode
)
{
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsDnodeSdb
,
.
pT
able
=
tsDnodeSdb
,
.
pObj
=
pDnode
};
int32_t
code
=
sdbUpdateRow
(
&
oper
);
int32_t
code
=
sdbUpdateRow
(
&
wmsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"dnodeId:%d, failed update"
,
pDnode
->
dnodeId
);
}
...
...
@@ -644,15 +644,15 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) {
tstrncpy
(
pDnode
->
dnodeEp
,
ep
,
TSDB_EP_LEN
);
taosGetFqdnPortFromEp
(
ep
,
pDnode
->
dnodeFqdn
,
&
pDnode
->
dnodePort
);
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsDnodeSdb
,
.
pTable
=
tsDnodeSdb
,
.
pObj
=
pDnode
,
.
rowSize
=
sizeof
(
SDnodeObj
),
.
pMsg
=
pMsg
};
int32_t
code
=
sdbInsertRow
(
&
oper
);
int32_t
code
=
sdbInsertRow
(
&
wmsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
int
dnodeId
=
pDnode
->
dnodeId
;
tfree
(
pDnode
);
...
...
@@ -665,14 +665,14 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) {
}
int32_t
mnodeDropDnode
(
SDnodeObj
*
pDnode
,
void
*
pMsg
)
{
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsDnodeSdb
,
.
pT
able
=
tsDnodeSdb
,
.
pObj
=
pDnode
,
.
pMsg
=
pMsg
};
int32_t
code
=
sdbDeleteRow
(
&
oper
);
int32_t
code
=
sdbDeleteRow
(
&
wmsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"dnode:%d, failed to drop from cluster, result:%s"
,
pDnode
->
dnodeId
,
tstrerror
(
code
));
}
else
{
...
...
src/mnode/src/mnodeMnode.c
浏览文件 @
97e41cdf
...
...
@@ -58,13 +58,13 @@ static int32_t mnodeRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, vo
#define mnodeMnodeDestroyLock() pthread_mutex_destroy(&tsMnodeLock)
#endif
static
int32_t
mnodeMnodeActionDestroy
(
SSWriteMsg
*
p
Oper
)
{
tfree
(
p
Oper
->
pObj
);
static
int32_t
mnodeMnodeActionDestroy
(
SSWriteMsg
*
p
WMsg
)
{
tfree
(
p
WMsg
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeMnodeActionInsert
(
SSWriteMsg
*
p
Oper
)
{
SMnodeObj
*
pMnode
=
p
Oper
->
pObj
;
static
int32_t
mnodeMnodeActionInsert
(
SSWriteMsg
*
p
WMsg
)
{
SMnodeObj
*
pMnode
=
p
WMsg
->
pObj
;
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pMnode
->
mnodeId
);
if
(
pDnode
==
NULL
)
return
TSDB_CODE_MND_DNODE_NOT_EXIST
;
...
...
@@ -76,8 +76,8 @@ static int32_t mnodeMnodeActionInsert(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeMnodeActionDelete
(
SSWriteMsg
*
p
Oper
)
{
SMnodeObj
*
pMnode
=
p
Oper
->
pObj
;
static
int32_t
mnodeMnodeActionDelete
(
SSWriteMsg
*
p
WMsg
)
{
SMnodeObj
*
pMnode
=
p
WMsg
->
pObj
;
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pMnode
->
mnodeId
);
if
(
pDnode
==
NULL
)
return
TSDB_CODE_MND_DNODE_NOT_EXIST
;
...
...
@@ -88,30 +88,30 @@ static int32_t mnodeMnodeActionDelete(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeMnodeActionUpdate
(
SSWriteMsg
*
p
Oper
)
{
SMnodeObj
*
pMnode
=
p
Oper
->
pObj
;
static
int32_t
mnodeMnodeActionUpdate
(
SSWriteMsg
*
p
WMsg
)
{
SMnodeObj
*
pMnode
=
p
WMsg
->
pObj
;
SMnodeObj
*
pSaved
=
mnodeGetMnode
(
pMnode
->
mnodeId
);
if
(
pMnode
!=
pSaved
)
{
memcpy
(
pSaved
,
pMnode
,
p
Oper
->
rowSize
);
memcpy
(
pSaved
,
pMnode
,
p
WMsg
->
rowSize
);
free
(
pMnode
);
}
mnodeDecMnodeRef
(
pSaved
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeMnodeActionEncode
(
SSWriteMsg
*
p
Oper
)
{
SMnodeObj
*
pMnode
=
p
Oper
->
pObj
;
memcpy
(
p
Oper
->
rowData
,
pMnode
,
tsMnodeUpdateSize
);
p
Oper
->
rowSize
=
tsMnodeUpdateSize
;
static
int32_t
mnodeMnodeActionEncode
(
SSWriteMsg
*
p
WMsg
)
{
SMnodeObj
*
pMnode
=
p
WMsg
->
pObj
;
memcpy
(
p
WMsg
->
rowData
,
pMnode
,
tsMnodeUpdateSize
);
p
WMsg
->
rowSize
=
tsMnodeUpdateSize
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeMnodeActionDecode
(
SSWriteMsg
*
p
Oper
)
{
static
int32_t
mnodeMnodeActionDecode
(
SSWriteMsg
*
p
WMsg
)
{
SMnodeObj
*
pMnode
=
calloc
(
1
,
sizeof
(
SMnodeObj
));
if
(
pMnode
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pMnode
,
p
Oper
->
rowData
,
tsMnodeUpdateSize
);
p
Oper
->
pObj
=
pMnode
;
memcpy
(
pMnode
,
p
WMsg
->
rowData
,
tsMnodeUpdateSize
);
p
WMsg
->
pObj
=
pMnode
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -329,11 +329,11 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
pMnode
->
mnodeId
=
dnodeId
;
pMnode
->
createdTime
=
taosGetTimestampMs
();
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsMnodeSdb
,
.
pTable
=
tsMnodeSdb
,
.
pObj
=
pMnode
,
.
writeCb
=
mnodeCreateMnodeCb
.
fpWrite
=
mnodeCreateMnodeCb
};
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
@@ -346,7 +346,7 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
return
;
}
code
=
sdbInsertRow
(
&
oper
);
code
=
sdbInsertRow
(
&
wmsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"dnode:%d, failed to create mnode, ep:%s reason:%s"
,
dnodeId
,
dnodeEp
,
tstrerror
(
code
));
tfree
(
pMnode
);
...
...
@@ -356,8 +356,8 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
void
mnodeDropMnodeLocal
(
int32_t
dnodeId
)
{
SMnodeObj
*
pMnode
=
mnodeGetMnode
(
dnodeId
);
if
(
pMnode
!=
NULL
)
{
SSWriteMsg
oper
=
{.
type
=
SDB_OPER_LOCAL
,
.
t
able
=
tsMnodeSdb
,
.
pObj
=
pMnode
};
sdbDeleteRow
(
&
oper
);
SSWriteMsg
wmsg
=
{.
type
=
SDB_OPER_LOCAL
,
.
pT
able
=
tsMnodeSdb
,
.
pObj
=
pMnode
};
sdbDeleteRow
(
&
wmsg
);
mnodeDecMnodeRef
(
pMnode
);
}
...
...
@@ -371,13 +371,13 @@ int32_t mnodeDropMnode(int32_t dnodeId) {
return
TSDB_CODE_MND_DNODE_NOT_EXIST
;
}
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsMnodeSdb
,
.
pT
able
=
tsMnodeSdb
,
.
pObj
=
pMnode
};
int32_t
code
=
sdbDeleteRow
(
&
oper
);
int32_t
code
=
sdbDeleteRow
(
&
wmsg
);
sdbDecRef
(
tsMnodeSdb
,
pMnode
);
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
97e41cdf
...
...
@@ -83,12 +83,12 @@ typedef struct {
typedef
struct
{
pthread_t
thread
;
int32_t
workerId
;
}
SS
Write
Worker
;
}
SS
db
Worker
;
typedef
struct
{
int32_t
num
;
SS
Write
Worker
*
worker
;
}
SS
Write
WorkerPool
;
SS
db
Worker
*
worker
;
}
SS
db
WorkerPool
;
extern
void
*
tsMnodeTmr
;
static
void
*
tsSdbTmr
;
...
...
@@ -96,27 +96,28 @@ static SSdbObject tsSdbObj = {0};
static
taos_qset
tsSdbWQset
;
static
taos_qall
tsSdbWQall
;
static
taos_queue
tsSdbWQueue
;
static
SSWriteWorkerPool
tsSdbPool
;
static
int32_t
sdbWrite
(
void
*
wparam
,
void
*
data
,
int32_t
type
,
void
*
pMsg
);
static
int32_t
sdbWriteToQueue
(
void
*
param
,
void
*
data
,
int32_t
type
,
void
*
pMsg
);
static
void
*
sdbWorkerFp
(
void
*
param
);
static
int32_t
sdbInitWriteWorker
();
static
void
sdbCleanupWriteWorker
();
static
int32_t
sdbAllocWriteQueue
();
static
void
sdbFreeWritequeue
();
static
SSdbWorkerPool
tsSdbPool
;
static
int32_t
sdbWrite
(
void
*
pWrite
,
void
*
pHead
,
int32_t
qtype
,
void
*
unused
);
static
int32_t
sdbWriteToQueue
(
void
*
pWrite
,
void
*
pHead
,
int32_t
qtype
,
void
*
unused
);
static
void
*
sdbWorkerFp
(
void
*
pWorker
);
static
int32_t
sdbInitWorker
();
static
void
sdbCleanupWorker
();
static
int32_t
sdbAllocQueue
();
static
void
sdbFreeQueue
();
extern
int32_t
sdbInsertRowImp
(
SSWriteMsg
*
pWrite
);
static
int32_t
sdbUpdateRowImp
(
SSWriteMsg
*
pWrite
);
static
int32_t
sdbDeleteRowImp
(
SSWriteMsg
*
pWrite
);
static
int32_t
sdbInsertHash
(
SSdbTable
*
pTable
,
SSWriteMsg
*
pWrite
);
static
int32_t
sdbUpdateHash
(
SSdbTable
*
pTable
,
SSWriteMsg
*
pWrite
);
static
int32_t
sdbDeleteHash
(
SSdbTable
*
pTable
,
SSWriteMsg
*
pWrite
);
int32_t
sdbGetId
(
void
*
hand
le
)
{
return
((
SSdbTable
*
)
hand
le
)
->
autoIndex
;
int32_t
sdbGetId
(
void
*
pTab
le
)
{
return
((
SSdbTable
*
)
pTab
le
)
->
autoIndex
;
}
int64_t
sdbGetNumOfRows
(
void
*
hand
le
)
{
return
((
SSdbTable
*
)
hand
le
)
->
numOfRows
;
int64_t
sdbGetNumOfRows
(
void
*
pTab
le
)
{
return
((
SSdbTable
*
)
pTab
le
)
->
numOfRows
;
}
uint64_t
sdbGetVersion
()
{
...
...
@@ -276,27 +277,27 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) {
SWalHead
*
pHead
=
(
void
*
)
pWrite
+
sizeof
(
SSWriteMsg
)
+
SDB_SYNC_HACK
;
int32_t
action
=
pHead
->
msgType
%
10
;
sdbError
(
"vgId:1, key:%p:%s hver:%"
PRIu64
" action:%d, failed to foward since %s"
,
pWrite
->
pObj
,
sdbGetKeyStr
(
pWrite
->
t
able
,
pHead
->
cont
),
pHead
->
version
,
action
,
tstrerror
(
pWrite
->
retCode
));
sdbGetKeyStr
(
pWrite
->
pT
able
,
pHead
->
cont
),
pHead
->
version
,
action
,
tstrerror
(
pWrite
->
retCode
));
if
(
action
==
SDB_ACTION_INSERT
)
{
// It's better to create a table in two stages, create it first and then set it success
//sdbDeleteHash(pWrite->
t
able, pWrite);
SSWriteMsg
oper
=
{
//sdbDeleteHash(pWrite->
pT
able, pWrite);
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
pWrite
->
t
able
,
.
pTable
=
pWrite
->
pT
able
,
.
pObj
=
pWrite
->
pObj
};
sdbDeleteRow
(
&
oper
);
sdbDeleteRow
(
&
wmsg
);
}
}
if
(
pWrite
->
writeCb
!=
NULL
)
{
pWrite
->
retCode
=
(
*
pWrite
->
writeCb
)(
pMsg
,
pWrite
->
retCode
);
if
(
pWrite
->
fpWrite
!=
NULL
)
{
pWrite
->
retCode
=
(
*
pWrite
->
fpWrite
)(
pMsg
,
pWrite
->
retCode
);
}
dnodeSendRpcMWriteRsp
(
pMsg
,
pWrite
->
retCode
);
// if ahandle, means this func is called by sdb write
if
(
ahandle
==
NULL
)
{
sdbDecRef
(
pWrite
->
t
able
,
pWrite
->
pObj
);
sdbDecRef
(
pWrite
->
pT
able
,
pWrite
->
pObj
);
}
taosFreeQitem
(
pWrite
);
...
...
@@ -403,7 +404,7 @@ void sdbUpdateSync(void *pMnodes) {
int32_t
sdbInit
()
{
pthread_mutex_init
(
&
tsSdbObj
.
mutex
,
NULL
);
if
(
sdbInitW
riteW
orker
()
!=
0
)
{
if
(
sdbInitWorker
()
!=
0
)
{
return
-
1
;
}
...
...
@@ -426,7 +427,7 @@ void sdbCleanUp() {
tsSdbObj
.
status
=
SDB_STATUS_CLOSING
;
sdbCleanupW
riteW
orker
();
sdbCleanupWorker
();
sdbDebug
(
"vgId:1, sdb will be closed, mver:%"
PRIu64
,
tsSdbObj
.
version
);
if
(
tsSdbObj
.
sync
)
{
...
...
@@ -442,19 +443,19 @@ void sdbCleanUp() {
pthread_mutex_destroy
(
&
tsSdbObj
.
mutex
);
}
void
sdbIncRef
(
void
*
handle
,
void
*
pObj
)
{
if
(
pObj
==
NULL
||
handle
==
NULL
)
return
;
void
sdbIncRef
(
void
*
tparam
,
void
*
pObj
)
{
if
(
pObj
==
NULL
||
tparam
==
NULL
)
return
;
SSdbTable
*
pTable
=
handle
;
SSdbTable
*
pTable
=
tparam
;
int32_t
*
pRefCount
=
(
int32_t
*
)(
pObj
+
pTable
->
refCountPos
);
int32_t
refCount
=
atomic_add_fetch_32
(
pRefCount
,
1
);
sdbTrace
(
"vgId:1, sdb:%s, inc ref to key:%p:%s:%d"
,
pTable
->
tableName
,
pObj
,
sdbGetObjStr
(
pTable
,
pObj
),
refCount
);
}
void
sdbDecRef
(
void
*
handle
,
void
*
pObj
)
{
if
(
pObj
==
NULL
||
handle
==
NULL
)
return
;
void
sdbDecRef
(
void
*
tparam
,
void
*
pObj
)
{
if
(
pObj
==
NULL
||
tparam
==
NULL
)
return
;
SSdbTable
*
pTable
=
handle
;
SSdbTable
*
pTable
=
tparam
;
int32_t
*
pRefCount
=
(
int32_t
*
)(
pObj
+
pTable
->
refCountPos
);
int32_t
refCount
=
atomic_sub_fetch_32
(
pRefCount
,
1
);
sdbTrace
(
"vgId:1, sdb:%s, dec ref to key:%p:%s:%d"
,
pTable
->
tableName
,
pObj
,
sdbGetObjStr
(
pTable
,
pObj
),
refCount
);
...
...
@@ -462,8 +463,8 @@ void sdbDecRef(void *handle, void *pObj) {
int32_t
*
updateEnd
=
pObj
+
pTable
->
refCountPos
-
4
;
if
(
refCount
<=
0
&&
*
updateEnd
)
{
sdbTrace
(
"vgId:1, sdb:%s, key:%p:%s:%d destroyed"
,
pTable
->
tableName
,
pObj
,
sdbGetObjStr
(
pTable
,
pObj
),
refCount
);
SSWriteMsg
oper
=
{.
pObj
=
pObj
};
(
*
pTable
->
fpDestroy
)(
&
oper
);
SSWriteMsg
wmsg
=
{.
pObj
=
pObj
};
(
*
pTable
->
fpDestroy
)(
&
wmsg
);
}
}
...
...
@@ -485,12 +486,12 @@ static void *sdbGetRowMetaFromObj(SSdbTable *pTable, void *key) {
return
sdbGetRowMeta
(
pTable
,
sdbGetObjKey
(
pTable
,
key
));
}
void
*
sdbGetRow
(
void
*
handle
,
void
*
key
)
{
SSdbTable
*
pTable
=
handle
;
void
*
sdbGetRow
(
void
*
tparam
,
void
*
key
)
{
SSdbTable
*
pTable
=
tparam
;
pthread_mutex_lock
(
&
pTable
->
mutex
);
void
*
pRow
=
sdbGetRowMeta
(
hand
le
,
key
);
if
(
pRow
)
sdbIncRef
(
hand
le
,
pRow
);
void
*
pRow
=
sdbGetRowMeta
(
pTab
le
,
key
);
if
(
pRow
)
sdbIncRef
(
pTab
le
,
pRow
);
pthread_mutex_unlock
(
&
pTable
->
mutex
);
return
pRow
;
...
...
@@ -573,9 +574,9 @@ static int32_t sdbUpdateHash(SSdbTable *pTable, SSWriteMsg *pWrite) {
return
TSDB_CODE_SUCCESS
;
}
static
int
sdbWrite
(
void
*
param
,
void
*
data
,
int32_t
type
,
void
*
pMsg
)
{
SSWriteMsg
*
pWrite
=
param
;
SWalHead
*
pHead
=
data
;
static
int
sdbWrite
(
void
*
wparam
,
void
*
hparam
,
int32_t
qtype
,
void
*
unused
)
{
SSWriteMsg
*
pWrite
=
w
param
;
SWalHead
*
pHead
=
hparam
;
int32_t
tableId
=
pHead
->
msgType
/
10
;
int32_t
action
=
pHead
->
msgType
%
10
;
...
...
@@ -593,12 +594,12 @@ static int sdbWrite(void *param, void *data, int32_t type, void *pMsg) {
if
(
pHead
->
version
<=
tsSdbObj
.
version
)
{
pthread_mutex_unlock
(
&
tsSdbObj
.
mutex
);
sdbDebug
(
"vgId:1, sdb:%s, failed to restore %s key:%s from source(%d), hver:%"
PRIu64
" too large, mver:%"
PRIu64
,
pTable
->
tableName
,
sdbGetActionStr
(
action
),
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
type
,
pHead
->
version
,
tsSdbObj
.
version
);
pTable
->
tableName
,
sdbGetActionStr
(
action
),
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
q
type
,
pHead
->
version
,
tsSdbObj
.
version
);
return
TSDB_CODE_SUCCESS
;
}
else
if
(
pHead
->
version
!=
tsSdbObj
.
version
+
1
)
{
pthread_mutex_unlock
(
&
tsSdbObj
.
mutex
);
sdbError
(
"vgId:1, sdb:%s, failed to restore %s key:%s from source(%d), hver:%"
PRIu64
" too large, mver:%"
PRIu64
,
pTable
->
tableName
,
sdbGetActionStr
(
action
),
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
type
,
pHead
->
version
,
tsSdbObj
.
version
);
pTable
->
tableName
,
sdbGetActionStr
(
action
),
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
q
type
,
pHead
->
version
,
tsSdbObj
.
version
);
return
TSDB_CODE_SYN_INVALID_VERSION
;
}
else
{
tsSdbObj
.
version
=
pHead
->
version
;
...
...
@@ -613,7 +614,7 @@ static int sdbWrite(void *param, void *data, int32_t type, void *pMsg) {
pthread_mutex_unlock
(
&
tsSdbObj
.
mutex
);
// from app,
oper
is created
// from app,
wmsg
is created
if
(
pWrite
!=
NULL
)
{
// forward to peers
pWrite
->
processedCount
=
0
;
...
...
@@ -639,11 +640,11 @@ static int sdbWrite(void *param, void *data, int32_t type, void *pMsg) {
// even it is WAL/FWD, it shall be called to update version in sync
syncForwardToPeer
(
tsSdbObj
.
sync
,
pHead
,
pWrite
,
TAOS_QTYPE_RPC
);
// from wal or forward msg,
oper
not created, should add into hash
// from wal or forward msg,
wmsg
not created, should add into hash
if
(
action
==
SDB_ACTION_INSERT
)
{
SSWriteMsg
oper
=
{.
rowSize
=
pHead
->
len
,
.
rowData
=
pHead
->
cont
,
.
t
able
=
pTable
};
code
=
(
*
pTable
->
fpDecode
)(
&
oper
);
return
sdbInsertHash
(
pTable
,
&
oper
);
SSWriteMsg
wmsg
=
{.
rowSize
=
pHead
->
len
,
.
rowData
=
pHead
->
cont
,
.
pT
able
=
pTable
};
code
=
(
*
pTable
->
fpDecode
)(
&
wmsg
);
return
sdbInsertHash
(
pTable
,
&
wmsg
);
}
else
if
(
action
==
SDB_ACTION_DELETE
)
{
void
*
pRow
=
sdbGetRowMeta
(
pTable
,
pHead
->
cont
);
if
(
pRow
==
NULL
)
{
...
...
@@ -651,8 +652,8 @@ static int sdbWrite(void *param, void *data, int32_t type, void *pMsg) {
sdbGetKeyStr
(
pTable
,
pHead
->
cont
));
return
TSDB_CODE_SUCCESS
;
}
SSWriteMsg
oper
=
{.
t
able
=
pTable
,
.
pObj
=
pRow
};
return
sdbDeleteHash
(
pTable
,
&
oper
);
SSWriteMsg
wmsg
=
{.
pT
able
=
pTable
,
.
pObj
=
pRow
};
return
sdbDeleteHash
(
pTable
,
&
wmsg
);
}
else
if
(
action
==
SDB_ACTION_UPDATE
)
{
void
*
pRow
=
sdbGetRowMeta
(
pTable
,
pHead
->
cont
);
if
(
pRow
==
NULL
)
{
...
...
@@ -660,16 +661,16 @@ static int sdbWrite(void *param, void *data, int32_t type, void *pMsg) {
sdbGetKeyStr
(
pTable
,
pHead
->
cont
));
return
TSDB_CODE_SUCCESS
;
}
SSWriteMsg
oper
=
{.
rowSize
=
pHead
->
len
,
.
rowData
=
pHead
->
cont
,
.
t
able
=
pTable
};
code
=
(
*
pTable
->
fpDecode
)(
&
oper
);
return
sdbUpdateHash
(
pTable
,
&
oper
);
SSWriteMsg
wmsg
=
{.
rowSize
=
pHead
->
len
,
.
rowData
=
pHead
->
cont
,
.
pT
able
=
pTable
};
code
=
(
*
pTable
->
fpDecode
)(
&
wmsg
);
return
sdbUpdateHash
(
pTable
,
&
wmsg
);
}
else
{
return
TSDB_CODE_MND_INVALID_MSG_TYPE
;
}
}
int32_t
sdbInsertRow
(
SSWriteMsg
*
pWrite
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pWrite
->
t
able
;
SSdbTable
*
pTable
=
pWrite
->
pT
able
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
if
(
sdbGetRowFromObj
(
pTable
,
pWrite
->
pObj
))
{
...
...
@@ -699,15 +700,15 @@ int32_t sdbInsertRow(SSWriteMsg *pWrite) {
return
TSDB_CODE_SUCCESS
;
}
if
(
pWrite
->
reqFp
)
{
return
(
*
pWrite
->
reqFp
)(
pWrite
->
pMsg
);
if
(
pWrite
->
fpReq
)
{
return
(
*
pWrite
->
fpReq
)(
pWrite
->
pMsg
);
}
else
{
return
sdbInsertRowImp
(
pWrite
);
}
}
int32_t
sdbInsertRowImp
(
SSWriteMsg
*
pWrite
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pWrite
->
t
able
;
SSdbTable
*
pTable
=
pWrite
->
pT
able
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
int32_t
size
=
sizeof
(
SSWriteMsg
)
+
sizeof
(
SWalHead
)
+
pTable
->
maxRowSize
+
SDB_SYNC_HACK
;
...
...
@@ -729,14 +730,14 @@ int32_t sdbInsertRowImp(SSWriteMsg *pWrite) {
pNewOper
->
pMsg
,
pTable
->
tableName
,
pWrite
->
pObj
,
sdbGetObjStr
(
pTable
,
pWrite
->
pObj
));
}
sdbIncRef
(
pNewOper
->
t
able
,
pNewOper
->
pObj
);
sdbIncRef
(
pNewOper
->
pT
able
,
pNewOper
->
pObj
);
taosWriteQitem
(
tsSdbWQueue
,
TAOS_QTYPE_RPC
,
pNewOper
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
bool
sdbCheckRowDeleted
(
void
*
pTableInput
,
void
*
pRow
)
{
SSdbTable
*
pTable
=
pTableInput
;
bool
sdbCheckRowDeleted
(
void
*
tparam
,
void
*
pRow
)
{
SSdbTable
*
pTable
=
tparam
;
if
(
pTable
==
NULL
)
return
false
;
int32_t
*
updateEnd
=
pRow
+
pTable
->
refCountPos
-
4
;
...
...
@@ -744,7 +745,7 @@ bool sdbCheckRowDeleted(void *pTableInput, void *pRow) {
}
int32_t
sdbDeleteRow
(
SSWriteMsg
*
pWrite
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pWrite
->
t
able
;
SSdbTable
*
pTable
=
pWrite
->
pT
able
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
void
*
pRow
=
sdbGetRowMetaFromObj
(
pTable
,
pWrite
->
pObj
);
...
...
@@ -768,15 +769,15 @@ int32_t sdbDeleteRow(SSWriteMsg *pWrite) {
return
TSDB_CODE_SUCCESS
;
}
if
(
pWrite
->
reqFp
)
{
return
(
*
pWrite
->
reqFp
)(
pWrite
->
pMsg
);
if
(
pWrite
->
fpReq
)
{
return
(
*
pWrite
->
fpReq
)(
pWrite
->
pMsg
);
}
else
{
return
sdbDeleteRowImp
(
pWrite
);
}
}
int32_t
sdbDeleteRowImp
(
SSWriteMsg
*
pWrite
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pWrite
->
t
able
;
SSdbTable
*
pTable
=
pWrite
->
pT
able
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
int32_t
size
=
sizeof
(
SSWriteMsg
)
+
sizeof
(
SWalHead
)
+
pTable
->
maxRowSize
+
SDB_SYNC_HACK
;
...
...
@@ -803,7 +804,7 @@ int32_t sdbDeleteRowImp(SSWriteMsg *pWrite) {
}
int32_t
sdbUpdateRow
(
SSWriteMsg
*
pWrite
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pWrite
->
t
able
;
SSdbTable
*
pTable
=
pWrite
->
pT
able
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
void
*
pRow
=
sdbGetRowMetaFromObj
(
pTable
,
pWrite
->
pObj
);
...
...
@@ -823,15 +824,15 @@ int32_t sdbUpdateRow(SSWriteMsg *pWrite) {
return
TSDB_CODE_SUCCESS
;
}
if
(
pWrite
->
reqFp
)
{
return
(
*
pWrite
->
reqFp
)(
pWrite
->
pMsg
);
if
(
pWrite
->
fpReq
)
{
return
(
*
pWrite
->
fpReq
)(
pWrite
->
pMsg
);
}
else
{
return
sdbUpdateRowImp
(
pWrite
);
}
}
int32_t
sdbUpdateRowImp
(
SSWriteMsg
*
pWrite
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pWrite
->
t
able
;
SSdbTable
*
pTable
=
pWrite
->
pT
able
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
int32_t
size
=
sizeof
(
SSWriteMsg
)
+
sizeof
(
SWalHead
)
+
pTable
->
maxRowSize
+
SDB_SYNC_HACK
;
...
...
@@ -852,14 +853,14 @@ int32_t sdbUpdateRowImp(SSWriteMsg *pWrite) {
pNewOper
->
pMsg
,
pTable
->
tableName
,
pWrite
->
pObj
,
sdbGetObjStr
(
pTable
,
pWrite
->
pObj
));
}
sdbIncRef
(
pNewOper
->
t
able
,
pNewOper
->
pObj
);
sdbIncRef
(
pNewOper
->
pT
able
,
pNewOper
->
pObj
);
taosWriteQitem
(
tsSdbWQueue
,
TAOS_QTYPE_RPC
,
pNewOper
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
void
*
sdbFetchRow
(
void
*
handle
,
void
*
pNode
,
void
**
ppRow
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
handle
;
void
*
sdbFetchRow
(
void
*
tparam
,
void
*
pNode
,
void
**
ppRow
)
{
SSdbTable
*
pTable
=
tparam
;
*
ppRow
=
NULL
;
if
(
pTable
==
NULL
)
return
NULL
;
...
...
@@ -880,7 +881,7 @@ void *sdbFetchRow(void *handle, void *pNode, void **ppRow) {
}
*
ppRow
=
*
ppMetaRow
;
sdbIncRef
(
hand
le
,
*
ppMetaRow
);
sdbIncRef
(
pTab
le
,
*
ppMetaRow
);
return
pIter
;
}
...
...
@@ -934,12 +935,12 @@ void sdbCloseTable(void *handle) {
void
**
ppRow
=
taosHashIterGet
(
pIter
);
if
(
ppRow
==
NULL
)
continue
;
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
pObj
=
*
ppRow
,
.
t
able
=
pTable
,
.
pT
able
=
pTable
,
};
(
*
pTable
->
fpDestroy
)(
&
oper
);
(
*
pTable
->
fpDestroy
)(
&
wmsg
);
}
taosHashDestroyIter
(
pIter
);
...
...
@@ -950,44 +951,44 @@ void sdbCloseTable(void *handle) {
free
(
pTable
);
}
int32_t
sdbInitW
riteW
orker
()
{
int32_t
sdbInitWorker
()
{
tsSdbPool
.
num
=
1
;
tsSdbPool
.
worker
=
(
SSWriteWorker
*
)
calloc
(
sizeof
(
SSWrite
Worker
),
tsSdbPool
.
num
);
tsSdbPool
.
worker
=
calloc
(
sizeof
(
SSdb
Worker
),
tsSdbPool
.
num
);
if
(
tsSdbPool
.
worker
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
tsSdbPool
.
num
;
++
i
)
{
SS
Write
Worker
*
pWorker
=
tsSdbPool
.
worker
+
i
;
SS
db
Worker
*
pWorker
=
tsSdbPool
.
worker
+
i
;
pWorker
->
workerId
=
i
;
}
sdbAlloc
Write
Queue
();
sdbAllocQueue
();
mInfo
(
"vgId:1, sdb write is opened"
);
return
0
;
}
void
sdbCleanupW
riteW
orker
()
{
void
sdbCleanupWorker
()
{
for
(
int32_t
i
=
0
;
i
<
tsSdbPool
.
num
;
++
i
)
{
SS
Write
Worker
*
pWorker
=
tsSdbPool
.
worker
+
i
;
SS
db
Worker
*
pWorker
=
tsSdbPool
.
worker
+
i
;
if
(
pWorker
->
thread
)
{
taosQsetThreadResume
(
tsSdbWQset
);
}
}
for
(
int32_t
i
=
0
;
i
<
tsSdbPool
.
num
;
++
i
)
{
SS
Write
Worker
*
pWorker
=
tsSdbPool
.
worker
+
i
;
SS
db
Worker
*
pWorker
=
tsSdbPool
.
worker
+
i
;
if
(
pWorker
->
thread
)
{
pthread_join
(
pWorker
->
thread
,
NULL
);
}
}
sdbFree
Writeq
ueue
();
sdbFree
Q
ueue
();
tfree
(
tsSdbPool
.
worker
);
mInfo
(
"vgId:1, sdb write is closed"
);
}
int32_t
sdbAlloc
Write
Queue
()
{
int32_t
sdbAllocQueue
()
{
tsSdbWQueue
=
taosOpenQueue
();
if
(
tsSdbWQueue
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
...
...
@@ -1006,7 +1007,7 @@ int32_t sdbAllocWriteQueue() {
}
for
(
int32_t
i
=
0
;
i
<
tsSdbPool
.
num
;
++
i
)
{
SS
Write
Worker
*
pWorker
=
tsSdbPool
.
worker
+
i
;
SS
db
Worker
*
pWorker
=
tsSdbPool
.
worker
+
i
;
pWorker
->
workerId
=
i
;
pthread_attr_t
thAttr
;
...
...
@@ -1029,7 +1030,7 @@ int32_t sdbAllocWriteQueue() {
return
TSDB_CODE_SUCCESS
;
}
void
sdbFree
Writeq
ueue
()
{
void
sdbFree
Q
ueue
()
{
taosCloseQueue
(
tsSdbWQueue
);
taosFreeQall
(
tsSdbWQall
);
taosCloseQset
(
tsSdbWQset
);
...
...
@@ -1038,8 +1039,8 @@ void sdbFreeWritequeue() {
tsSdbWQueue
=
NULL
;
}
int32_t
sdbWriteToQueue
(
void
*
param
,
void
*
data
,
int32_t
qtype
,
void
*
pMsg
)
{
SWalHead
*
pHead
=
data
;
int32_t
sdbWriteToQueue
(
void
*
wparam
,
void
*
hparam
,
int32_t
qtype
,
void
*
unsed
)
{
SWalHead
*
pHead
=
hparam
;
int32_t
size
=
sizeof
(
SWalHead
)
+
pHead
->
len
;
SWalHead
*
pWal
=
taosAllocateQitem
(
size
);
memcpy
(
pWal
,
pHead
,
size
);
...
...
@@ -1048,10 +1049,10 @@ int32_t sdbWriteToQueue(void *param, void *data, int32_t qtype, void *pMsg) {
return
0
;
}
static
void
*
sdbWorkerFp
(
void
*
p
aram
)
{
static
void
*
sdbWorkerFp
(
void
*
p
Worker
)
{
SWalHead
*
pHead
;
SSWriteMsg
*
pWrite
;
int32_t
type
;
int32_t
q
type
;
int32_t
numOfMsgs
;
void
*
item
;
void
*
unUsed
;
...
...
@@ -1064,22 +1065,22 @@ static void *sdbWorkerFp(void *param) {
}
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
taosGetQitem
(
tsSdbWQall
,
&
type
,
&
item
);
if
(
type
==
TAOS_QTYPE_RPC
)
{
taosGetQitem
(
tsSdbWQall
,
&
q
type
,
&
item
);
if
(
q
type
==
TAOS_QTYPE_RPC
)
{
pWrite
=
(
SSWriteMsg
*
)
item
;
pWrite
->
processedCount
=
1
;
pHead
=
(
void
*
)
pWrite
+
sizeof
(
SSWriteMsg
)
+
SDB_SYNC_HACK
;
if
(
pWrite
->
pMsg
!=
NULL
)
{
sdbDebug
(
"vgId:1, ahandle:%p msg:%p, sdb:%s key:%p:%s hver:%"
PRIu64
", will be processed in sdb queue"
,
pWrite
->
pMsg
->
rpcMsg
.
ahandle
,
pWrite
->
pMsg
,
((
SSdbTable
*
)
pWrite
->
table
)
->
tableName
,
pWrite
->
pObj
,
sdbGetKeyStr
(
pWrite
->
t
able
,
pHead
->
cont
),
pHead
->
version
);
pWrite
->
pMsg
->
rpcMsg
.
ahandle
,
pWrite
->
pMsg
,
pWrite
->
pTable
->
tableName
,
pWrite
->
pObj
,
sdbGetKeyStr
(
pWrite
->
pT
able
,
pHead
->
cont
),
pHead
->
version
);
}
}
else
{
pHead
=
(
SWalHead
*
)
item
;
pWrite
=
NULL
;
}
int32_t
code
=
sdbWrite
(
pWrite
,
pHead
,
type
,
NULL
);
int32_t
code
=
sdbWrite
(
pWrite
,
pHead
,
q
type
,
NULL
);
if
(
code
>
0
)
code
=
0
;
if
(
pWrite
)
{
pWrite
->
retCode
=
code
;
...
...
@@ -1093,12 +1094,12 @@ static void *sdbWorkerFp(void *param) {
// browse all items, and process them one by one
taosResetQitems
(
tsSdbWQall
);
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
taosGetQitem
(
tsSdbWQall
,
&
type
,
&
item
);
taosGetQitem
(
tsSdbWQall
,
&
q
type
,
&
item
);
if
(
type
==
TAOS_QTYPE_RPC
)
{
if
(
q
type
==
TAOS_QTYPE_RPC
)
{
pWrite
=
(
SSWriteMsg
*
)
item
;
sdbConfirmForward
(
NULL
,
pWrite
,
pWrite
->
retCode
);
}
else
if
(
type
==
TAOS_QTYPE_FWD
)
{
}
else
if
(
q
type
==
TAOS_QTYPE_FWD
)
{
pHead
=
(
SWalHead
*
)
item
;
syncConfirmForward
(
tsSdbObj
.
sync
,
pHead
->
version
,
pHead
->
len
);
taosFreeQitem
(
item
);
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
97e41cdf
此差异已折叠。
点击以展开。
src/mnode/src/mnodeUser.c
浏览文件 @
97e41cdf
...
...
@@ -42,13 +42,13 @@ static int32_t mnodeProcessAlterUserMsg(SMnodeMsg *pMsg);
static
int32_t
mnodeProcessDropUserMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessAuthMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeUserActionDestroy
(
SSWriteMsg
*
p
Oper
)
{
tfree
(
p
Oper
->
pObj
);
static
int32_t
mnodeUserActionDestroy
(
SSWriteMsg
*
p
WMsg
)
{
tfree
(
p
WMsg
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeUserActionInsert
(
SSWriteMsg
*
p
Oper
)
{
SUserObj
*
pUser
=
p
Oper
->
pObj
;
static
int32_t
mnodeUserActionInsert
(
SSWriteMsg
*
p
WMsg
)
{
SUserObj
*
pUser
=
p
WMsg
->
pObj
;
SAcctObj
*
pAcct
=
mnodeGetAcct
(
pUser
->
acct
);
if
(
pAcct
!=
NULL
)
{
...
...
@@ -62,8 +62,8 @@ static int32_t mnodeUserActionInsert(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeUserActionDelete
(
SSWriteMsg
*
p
Oper
)
{
SUserObj
*
pUser
=
p
Oper
->
pObj
;
static
int32_t
mnodeUserActionDelete
(
SSWriteMsg
*
p
WMsg
)
{
SUserObj
*
pUser
=
p
WMsg
->
pObj
;
SAcctObj
*
pAcct
=
mnodeGetAcct
(
pUser
->
acct
);
if
(
pAcct
!=
NULL
)
{
...
...
@@ -74,8 +74,8 @@ static int32_t mnodeUserActionDelete(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeUserActionUpdate
(
SSWriteMsg
*
p
Oper
)
{
SUserObj
*
pUser
=
p
Oper
->
pObj
;
static
int32_t
mnodeUserActionUpdate
(
SSWriteMsg
*
p
WMsg
)
{
SUserObj
*
pUser
=
p
WMsg
->
pObj
;
SUserObj
*
pSaved
=
mnodeGetUser
(
pUser
->
user
);
if
(
pUser
!=
pSaved
)
{
memcpy
(
pSaved
,
pUser
,
tsUserUpdateSize
);
...
...
@@ -85,19 +85,19 @@ static int32_t mnodeUserActionUpdate(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeUserActionEncode
(
SSWriteMsg
*
p
Oper
)
{
SUserObj
*
pUser
=
p
Oper
->
pObj
;
memcpy
(
p
Oper
->
rowData
,
pUser
,
tsUserUpdateSize
);
p
Oper
->
rowSize
=
tsUserUpdateSize
;
static
int32_t
mnodeUserActionEncode
(
SSWriteMsg
*
p
WMsg
)
{
SUserObj
*
pUser
=
p
WMsg
->
pObj
;
memcpy
(
p
WMsg
->
rowData
,
pUser
,
tsUserUpdateSize
);
p
WMsg
->
rowSize
=
tsUserUpdateSize
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeUserActionDecode
(
SSWriteMsg
*
p
Oper
)
{
static
int32_t
mnodeUserActionDecode
(
SSWriteMsg
*
p
WMsg
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
calloc
(
1
,
sizeof
(
SUserObj
));
if
(
pUser
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pUser
,
p
Oper
->
rowData
,
tsUserUpdateSize
);
p
Oper
->
pObj
=
pUser
;
memcpy
(
pUser
,
p
WMsg
->
rowData
,
tsUserUpdateSize
);
p
WMsg
->
pObj
=
pUser
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -205,14 +205,14 @@ void mnodeDecUserRef(SUserObj *pUser) {
}
static
int32_t
mnodeUpdateUser
(
SUserObj
*
pUser
,
void
*
pMsg
)
{
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsUserSdb
,
.
pT
able
=
tsUserSdb
,
.
pObj
=
pUser
,
.
pMsg
=
pMsg
};
int32_t
code
=
sdbUpdateRow
(
&
oper
);
int32_t
code
=
sdbUpdateRow
(
&
wmsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"user:%s, failed to alter by %s, reason:%s"
,
pUser
->
user
,
mnodeGetUserFromMsg
(
pMsg
),
tstrerror
(
code
));
}
else
{
...
...
@@ -259,15 +259,15 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) {
pUser
->
superAuth
=
1
;
}
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsUserSdb
,
.
pT
able
=
tsUserSdb
,
.
pObj
=
pUser
,
.
rowSize
=
sizeof
(
SUserObj
),
.
pMsg
=
pMsg
};
code
=
sdbInsertRow
(
&
oper
);
code
=
sdbInsertRow
(
&
wmsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"user:%s, failed to create by %s, reason:%s"
,
pUser
->
user
,
mnodeGetUserFromMsg
(
pMsg
),
tstrerror
(
code
));
tfree
(
pUser
);
...
...
@@ -279,14 +279,14 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) {
}
static
int32_t
mnodeDropUser
(
SUserObj
*
pUser
,
void
*
pMsg
)
{
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsUserSdb
,
.
pT
able
=
tsUserSdb
,
.
pObj
=
pUser
,
.
pMsg
=
pMsg
};
int32_t
code
=
sdbDeleteRow
(
&
oper
);
int32_t
code
=
sdbDeleteRow
(
&
wmsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"user:%s, failed to drop by %s, reason:%s"
,
pUser
->
user
,
mnodeGetUserFromMsg
(
pMsg
),
tstrerror
(
code
));
}
else
{
...
...
@@ -562,12 +562,12 @@ void mnodeDropAllUsers(SAcctObj *pAcct) {
if
(
pUser
==
NULL
)
break
;
if
(
strncmp
(
pUser
->
acct
,
pAcct
->
user
,
acctNameLen
)
==
0
)
{
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_LOCAL
,
.
t
able
=
tsUserSdb
,
.
pT
able
=
tsUserSdb
,
.
pObj
=
pUser
,
};
sdbDeleteRow
(
&
oper
);
sdbDeleteRow
(
&
wmsg
);
numOfUsers
++
;
}
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
97e41cdf
...
...
@@ -72,13 +72,13 @@ static void mnodeDestroyVgroup(SVgObj *pVgroup) {
tfree
(
pVgroup
);
}
static
int32_t
mnodeVgroupActionDestroy
(
SSWriteMsg
*
p
Oper
)
{
mnodeDestroyVgroup
(
p
Oper
->
pObj
);
static
int32_t
mnodeVgroupActionDestroy
(
SSWriteMsg
*
p
WMsg
)
{
mnodeDestroyVgroup
(
p
WMsg
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeVgroupActionInsert
(
SSWriteMsg
*
p
Oper
)
{
SVgObj
*
pVgroup
=
p
Oper
->
pObj
;
static
int32_t
mnodeVgroupActionInsert
(
SSWriteMsg
*
p
WMsg
)
{
SVgObj
*
pVgroup
=
p
WMsg
->
pObj
;
// refer to db
SDbObj
*
pDb
=
mnodeGetDb
(
pVgroup
->
dbName
);
...
...
@@ -115,8 +115,8 @@ static int32_t mnodeVgroupActionInsert(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeVgroupActionDelete
(
SSWriteMsg
*
p
Oper
)
{
SVgObj
*
pVgroup
=
p
Oper
->
pObj
;
static
int32_t
mnodeVgroupActionDelete
(
SSWriteMsg
*
p
WMsg
)
{
SVgObj
*
pVgroup
=
p
WMsg
->
pObj
;
if
(
pVgroup
->
pDb
==
NULL
)
{
mError
(
"vgId:%d, db:%s is not exist while insert into hash"
,
pVgroup
->
vgId
,
pVgroup
->
dbName
);
...
...
@@ -137,8 +137,8 @@ static int32_t mnodeVgroupActionDelete(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeVgroupActionUpdate
(
SSWriteMsg
*
p
Oper
)
{
SVgObj
*
pNew
=
p
Oper
->
pObj
;
static
int32_t
mnodeVgroupActionUpdate
(
SSWriteMsg
*
p
WMsg
)
{
SVgObj
*
pNew
=
p
WMsg
->
pObj
;
SVgObj
*
pVgroup
=
mnodeGetVgroup
(
pNew
->
vgId
);
if
(
pVgroup
!=
pNew
)
{
...
...
@@ -176,25 +176,25 @@ static int32_t mnodeVgroupActionUpdate(SSWriteMsg *pOper) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeVgroupActionEncode
(
SSWriteMsg
*
p
Oper
)
{
SVgObj
*
pVgroup
=
p
Oper
->
pObj
;
memcpy
(
p
Oper
->
rowData
,
pVgroup
,
tsVgUpdateSize
);
SVgObj
*
pTmpVgroup
=
p
Oper
->
rowData
;
static
int32_t
mnodeVgroupActionEncode
(
SSWriteMsg
*
p
WMsg
)
{
SVgObj
*
pVgroup
=
p
WMsg
->
pObj
;
memcpy
(
p
WMsg
->
rowData
,
pVgroup
,
tsVgUpdateSize
);
SVgObj
*
pTmpVgroup
=
p
WMsg
->
rowData
;
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
pTmpVgroup
->
vnodeGid
[
i
].
pDnode
=
NULL
;
pTmpVgroup
->
vnodeGid
[
i
].
role
=
0
;
}
p
Oper
->
rowSize
=
tsVgUpdateSize
;
p
WMsg
->
rowSize
=
tsVgUpdateSize
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeVgroupActionDecode
(
SSWriteMsg
*
p
Oper
)
{
static
int32_t
mnodeVgroupActionDecode
(
SSWriteMsg
*
p
WMsg
)
{
SVgObj
*
pVgroup
=
(
SVgObj
*
)
calloc
(
1
,
sizeof
(
SVgObj
));
if
(
pVgroup
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pVgroup
,
p
Oper
->
rowData
,
tsVgUpdateSize
);
p
Oper
->
pObj
=
pVgroup
;
memcpy
(
pVgroup
,
p
WMsg
->
rowData
,
tsVgUpdateSize
);
p
WMsg
->
pObj
=
pVgroup
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -253,13 +253,13 @@ SVgObj *mnodeGetVgroup(int32_t vgId) {
}
void
mnodeUpdateVgroup
(
SVgObj
*
pVgroup
)
{
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsVgroupSdb
,
.
pT
able
=
tsVgroupSdb
,
.
pObj
=
pVgroup
};
int32_t
code
=
sdbUpdateRow
(
&
oper
);
int32_t
code
=
sdbUpdateRow
(
&
wmsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"vgId:%d, failed to update vgroup"
,
pVgroup
->
vgId
);
}
...
...
@@ -519,14 +519,14 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"app:%p:%p, vgId:%d, failed to create in sdb, reason:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pVgroup
->
vgId
,
tstrerror
(
code
));
SSWriteMsg
desc
=
{.
type
=
SDB_OPER_GLOBAL
,
.
pObj
=
pVgroup
,
.
t
able
=
tsVgroupSdb
};
SSWriteMsg
desc
=
{.
type
=
SDB_OPER_GLOBAL
,
.
pObj
=
pVgroup
,
.
pT
able
=
tsVgroupSdb
};
sdbDeleteRow
(
&
desc
);
return
code
;
}
else
{
mInfo
(
"app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pVgroup
->
vgId
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
pVgroup
->
status
=
TAOS_VG_STATUS_READY
;
SSWriteMsg
desc
=
{.
type
=
SDB_OPER_GLOBAL
,
.
pObj
=
pVgroup
,
.
t
able
=
tsVgroupSdb
};
SSWriteMsg
desc
=
{.
type
=
SDB_OPER_GLOBAL
,
.
pObj
=
pVgroup
,
.
pT
able
=
tsVgroupSdb
};
(
void
)
sdbUpdateRow
(
&
desc
);
dnodeReprocessMWriteMsg
(
pMsg
);
...
...
@@ -535,7 +535,7 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
// mInfo("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d", pMsg->rpcMsg.ahandle, pMsg, pVgroup->vgId,
// pDb->name, pVgroup->numOfVnodes);
// pVgroup->status = TAOS_VG_STATUS_READY;
// SSWriteMsg desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .
t
able = tsVgroupSdb};
// SSWriteMsg desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .
pT
able = tsVgroupSdb};
// (void)sdbUpdateRow(&desc);
// dnodeReprocessMWriteMsg(pMsg);
// return TSDB_CODE_MND_ACTION_IN_PROGRESS;
...
...
@@ -571,16 +571,16 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) {
pMsg
->
pVgroup
=
pVgroup
;
mnodeIncVgroupRef
(
pVgroup
);
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsVgroupSdb
,
.
pT
able
=
tsVgroupSdb
,
.
pObj
=
pVgroup
,
.
rowSize
=
sizeof
(
SVgObj
),
.
pMsg
=
pMsg
,
.
reqFp
=
mnodeCreateVgroupFp
.
fpReq
=
mnodeCreateVgroupFp
};
code
=
sdbInsertRow
(
&
oper
);
code
=
sdbInsertRow
(
&
wmsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
pMsg
->
pVgroup
=
NULL
;
mnodeDestroyVgroup
(
pVgroup
);
...
...
@@ -595,12 +595,12 @@ void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle) {
}
else
{
mDebug
(
"vgId:%d, replica:%d is deleting from sdb"
,
pVgroup
->
vgId
,
pVgroup
->
numOfVnodes
);
mnodeSendDropVgroupMsg
(
pVgroup
,
NULL
);
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsVgroupSdb
,
.
pT
able
=
tsVgroupSdb
,
.
pObj
=
pVgroup
};
sdbDeleteRow
(
&
oper
);
sdbDeleteRow
(
&
wmsg
);
}
}
...
...
@@ -957,28 +957,28 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
if
(
mnodeMsg
->
received
!=
mnodeMsg
->
expected
)
return
;
if
(
mnodeMsg
->
received
==
mnodeMsg
->
successed
)
{
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsVgroupSdb
,
.
pT
able
=
tsVgroupSdb
,
.
pObj
=
pVgroup
,
.
rowSize
=
sizeof
(
SVgObj
),
.
pMsg
=
mnodeMsg
,
.
writeCb
=
mnodeCreateVgroupCb
.
fpWrite
=
mnodeCreateVgroupCb
};
int32_t
code
=
sdbInsertRowImp
(
&
oper
);
int32_t
code
=
sdbInsertRowImp
(
&
wmsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mnodeMsg
->
pVgroup
=
NULL
;
mnodeDestroyVgroup
(
pVgroup
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
code
);
}
}
else
{
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsVgroupSdb
,
.
pT
able
=
tsVgroupSdb
,
.
pObj
=
pVgroup
};
sdbDeleteRow
(
&
oper
);
sdbDeleteRow
(
&
wmsg
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
mnodeMsg
->
code
);
}
}
...
...
@@ -1031,12 +1031,12 @@ static void mnodeProcessDropVnodeRsp(SRpcMsg *rpcMsg) {
if
(
mnodeMsg
->
received
!=
mnodeMsg
->
expected
)
return
;
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
t
able
=
tsVgroupSdb
,
.
pT
able
=
tsVgroupSdb
,
.
pObj
=
pVgroup
};
int32_t
code
=
sdbDeleteRow
(
&
oper
);
int32_t
code
=
sdbDeleteRow
(
&
wmsg
);
if
(
code
!=
0
)
{
code
=
TSDB_CODE_MND_SDB_ERROR
;
}
...
...
@@ -1084,12 +1084,12 @@ void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode) {
if
(
pVgroup
->
vnodeGid
[
0
].
dnodeId
==
pDropDnode
->
dnodeId
)
{
mnodeDropAllChildTablesInVgroups
(
pVgroup
);
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_LOCAL
,
.
t
able
=
tsVgroupSdb
,
.
pT
able
=
tsVgroupSdb
,
.
pObj
=
pVgroup
,
};
sdbDeleteRow
(
&
oper
);
sdbDeleteRow
(
&
wmsg
);
numOfVgroups
++
;
}
mnodeDecVgroupRef
(
pVgroup
);
...
...
@@ -1135,12 +1135,12 @@ void mnodeDropAllDbVgroups(SDbObj *pDropDb) {
if
(
pVgroup
==
NULL
)
break
;
if
(
pVgroup
->
pDb
==
pDropDb
)
{
SSWriteMsg
oper
=
{
SSWriteMsg
wmsg
=
{
.
type
=
SDB_OPER_LOCAL
,
.
t
able
=
tsVgroupSdb
,
.
pT
able
=
tsVgroupSdb
,
.
pObj
=
pVgroup
,
};
sdbDeleteRow
(
&
oper
);
sdbDeleteRow
(
&
wmsg
);
numOfVgroups
++
;
}
...
...
tests/script/sh/deploy.sh
浏览文件 @
97e41cdf
...
...
@@ -113,22 +113,22 @@ echo "logDir $LOG_DIR" >> $TAOS_CFG
echo
"debugFlag 0"
>>
$TAOS_CFG
echo
"mDebugFlag 143"
>>
$TAOS_CFG
echo
"sdbDebugFlag 143"
>>
$TAOS_CFG
echo
"dDebugFlag 1
43
"
>>
$TAOS_CFG
echo
"vDebugFlag 1
43
"
>>
$TAOS_CFG
echo
"tsdbDebugFlag 1
43
"
>>
$TAOS_CFG
echo
"cDebugFlag 1
43
"
>>
$TAOS_CFG
echo
"jnidebugFlag 1
43
"
>>
$TAOS_CFG
echo
"odbcdebugFlag 1
43
"
>>
$TAOS_CFG
echo
"httpDebugFlag 1
43
"
>>
$TAOS_CFG
echo
"monitorDebugFlag 1
43
"
>>
$TAOS_CFG
echo
"mqttDebugFlag 1
43
"
>>
$TAOS_CFG
echo
"qdebugFlag 1
43
"
>>
$TAOS_CFG
echo
"rpcDebugFlag 1
43
"
>>
$TAOS_CFG
echo
"dDebugFlag 1
31
"
>>
$TAOS_CFG
echo
"vDebugFlag 1
31
"
>>
$TAOS_CFG
echo
"tsdbDebugFlag 1
31
"
>>
$TAOS_CFG
echo
"cDebugFlag 1
31
"
>>
$TAOS_CFG
echo
"jnidebugFlag 1
31
"
>>
$TAOS_CFG
echo
"odbcdebugFlag 1
31
"
>>
$TAOS_CFG
echo
"httpDebugFlag 1
31
"
>>
$TAOS_CFG
echo
"monitorDebugFlag 1
31
"
>>
$TAOS_CFG
echo
"mqttDebugFlag 1
31
"
>>
$TAOS_CFG
echo
"qdebugFlag 1
31
"
>>
$TAOS_CFG
echo
"rpcDebugFlag 1
31
"
>>
$TAOS_CFG
echo
"tmrDebugFlag 131"
>>
$TAOS_CFG
echo
"udebugFlag 1
43
"
>>
$TAOS_CFG
echo
"udebugFlag 1
31
"
>>
$TAOS_CFG
echo
"sdebugFlag 143"
>>
$TAOS_CFG
echo
"wdebugFlag 143"
>>
$TAOS_CFG
echo
"cqdebugFlag 1
43
"
>>
$TAOS_CFG
echo
"cqdebugFlag 1
31
"
>>
$TAOS_CFG
echo
"monitor 0"
>>
$TAOS_CFG
echo
"monitorInterval 1"
>>
$TAOS_CFG
echo
"http 0"
>>
$TAOS_CFG
...
...
@@ -140,7 +140,7 @@ echo "clog 2" >> $TAOS_CFG
#echo "cache 1" >> $TAOS_CFG
echo
"days 10"
>>
$TAOS_CFG
echo
"statusInterval 1"
>>
$TAOS_CFG
echo
"maxVgroupsPerDb
4
"
>>
$TAOS_CFG
echo
"maxVgroupsPerDb
10
"
>>
$TAOS_CFG
echo
"minTablesPerVnode 4"
>>
$TAOS_CFG
echo
"maxTablesPerVnode 1000"
>>
$TAOS_CFG
echo
"tableIncStepPerVnode 10000"
>>
$TAOS_CFG
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录