Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
f323186f
T
TDengine
项目概览
慢慢CG
/
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看板
提交
f323186f
编写于
11月 20, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-2046
上级
566b749c
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
460 addition
and
463 deletion
+460
-463
src/mnode/inc/mnodeSdb.h
src/mnode/inc/mnodeSdb.h
+22
-24
src/mnode/src/mnodeAcct.c
src/mnode/src/mnodeAcct.c
+20
-21
src/mnode/src/mnodeCluster.c
src/mnode/src/mnodeCluster.c
+15
-15
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+33
-33
src/mnode/src/mnodeDnode.c
src/mnode/src/mnodeDnode.c
+25
-25
src/mnode/src/mnodeMnode.c
src/mnode/src/mnodeMnode.c
+24
-24
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+143
-143
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+108
-108
src/mnode/src/mnodeUser.c
src/mnode/src/mnodeUser.c
+27
-27
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+43
-43
未找到文件。
src/mnode/inc/mnodeSdb.h
浏览文件 @
f323186f
...
@@ -23,8 +23,6 @@ extern "C" {
...
@@ -23,8 +23,6 @@ extern "C" {
#include "mnode.h"
#include "mnode.h"
#include "twal.h"
#include "twal.h"
struct
SSdbTable
;
typedef
enum
{
typedef
enum
{
SDB_TABLE_CLUSTER
=
0
,
SDB_TABLE_CLUSTER
=
0
,
SDB_TABLE_DNODE
=
1
,
SDB_TABLE_DNODE
=
1
,
...
@@ -50,20 +48,20 @@ typedef enum {
...
@@ -50,20 +48,20 @@ typedef enum {
SDB_OPER_LOCAL
=
1
SDB_OPER_LOCAL
=
1
}
ESdbOper
;
}
ESdbOper
;
typedef
struct
SSWriteMsg
{
typedef
struct
SSdbRow
{
ESdbOper
type
;
ESdbOper
type
;
int32_t
processedCount
;
// for sync fwd callback
int32_t
processedCount
;
// for sync fwd callback
int32_t
code
;
// for callback in sdb queue
int32_t
code
;
// for callback in sdb queue
int32_t
rowSize
;
int32_t
rowSize
;
void
*
rowData
;
void
*
rowData
;
void
*
pObj
;
void
*
pTable
;
SMnodeMsg
*
pMsg
;
int32_t
(
*
fpReq
)(
SMnodeMsg
*
pMsg
);
int32_t
(
*
fpReq
)(
SMnodeMsg
*
pMsg
);
int32_t
(
*
fpRsp
)(
SMnodeMsg
*
pMsg
,
int32_t
code
);
int32_t
(
*
fpRsp
)(
SMnodeMsg
*
pMsg
,
int32_t
code
);
void
*
pRow
;
char
reserveForSync
[
16
];
SMnodeMsg
*
pMsg
;
SWalHead
pHead
[];
struct
SSdbTable
*
pTable
;
}
SSdbRow
;
char
reserveForSync
[
16
];
SWalHead
pHead
[];
}
SSWriteMsg
;
typedef
struct
{
typedef
struct
{
char
*
name
;
char
*
name
;
...
@@ -72,12 +70,12 @@ typedef struct {
...
@@ -72,12 +70,12 @@ typedef struct {
int32_t
refCountPos
;
int32_t
refCountPos
;
ESdbTable
id
;
ESdbTable
id
;
ESdbKey
keyType
;
ESdbKey
keyType
;
int32_t
(
*
fpInsert
)(
SS
WriteMsg
*
pWrite
);
int32_t
(
*
fpInsert
)(
SS
dbRow
*
pRow
);
int32_t
(
*
fpDelete
)(
SS
WriteMsg
*
pWrite
);
int32_t
(
*
fpDelete
)(
SS
dbRow
*
pRow
);
int32_t
(
*
fpUpdate
)(
SS
WriteMsg
*
pWrite
);
int32_t
(
*
fpUpdate
)(
SS
dbRow
*
pRow
);
int32_t
(
*
fpEncode
)(
SS
WriteMsg
*
pWrite
);
int32_t
(
*
fpEncode
)(
SS
dbRow
*
pRow
);
int32_t
(
*
fpDecode
)(
SS
WriteMsg
*
pWrite
);
int32_t
(
*
fpDecode
)(
SS
dbRow
*
pRow
);
int32_t
(
*
fpDestroy
)(
SS
WriteMsg
*
pWrite
);
int32_t
(
*
fpDestroy
)(
SS
dbRow
*
pRow
);
int32_t
(
*
fpRestored
)();
int32_t
(
*
fpRestored
)();
}
SSdbTableDesc
;
}
SSdbTableDesc
;
...
@@ -89,10 +87,10 @@ bool sdbIsMaster();
...
@@ -89,10 +87,10 @@ bool sdbIsMaster();
bool
sdbIsServing
();
bool
sdbIsServing
();
void
sdbUpdateMnodeRoles
();
void
sdbUpdateMnodeRoles
();
int32_t
sdbInsertRow
(
SS
WriteMsg
*
pWrite
);
int32_t
sdbInsertRow
(
SS
dbRow
*
pRow
);
int32_t
sdbDeleteRow
(
SS
WriteMsg
*
pWrite
);
int32_t
sdbDeleteRow
(
SS
dbRow
*
pRow
);
int32_t
sdbUpdateRow
(
SS
WriteMsg
*
pWrite
);
int32_t
sdbUpdateRow
(
SS
dbRow
*
pRow
);
int32_t
sdbInsertRowToQueue
(
SS
WriteMsg
*
pWrite
);
int32_t
sdbInsertRowToQueue
(
SS
dbRow
*
pRow
);
void
*
sdbGetRow
(
void
*
pTable
,
void
*
key
);
void
*
sdbGetRow
(
void
*
pTable
,
void
*
key
);
void
*
sdbFetchRow
(
void
*
pTable
,
void
*
pIter
,
void
**
ppRow
);
void
*
sdbFetchRow
(
void
*
pTable
,
void
*
pIter
,
void
**
ppRow
);
...
...
src/mnode/src/mnodeAcct.c
浏览文件 @
f323186f
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "taoserror.h"
#include "taoserror.h"
#include "tglobal.h"
#include "dnode.h"
#include "dnode.h"
#include "mnodeDef.h"
#include "mnodeDef.h"
#include "mnodeInt.h"
#include "mnodeInt.h"
...
@@ -25,36 +26,34 @@
...
@@ -25,36 +26,34 @@
#include "mnodeUser.h"
#include "mnodeUser.h"
#include "mnodeVgroup.h"
#include "mnodeVgroup.h"
#include "tglobal.h"
void
*
tsAcctSdb
=
NULL
;
void
*
tsAcctSdb
=
NULL
;
static
int32_t
tsAcctUpdateSize
;
static
int32_t
tsAcctUpdateSize
;
static
int32_t
mnodeCreateRootAcct
();
static
int32_t
mnodeCreateRootAcct
();
static
int32_t
mnodeAcctActionDestroy
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeAcctActionDestroy
(
SS
dbRow
*
pRow
)
{
SAcctObj
*
pAcct
=
p
WMsg
->
pRow
;
SAcctObj
*
pAcct
=
p
Row
->
pObj
;
pthread_mutex_destroy
(
&
pAcct
->
mutex
);
pthread_mutex_destroy
(
&
pAcct
->
mutex
);
tfree
(
p
WMsg
->
pRow
);
tfree
(
p
Row
->
pObj
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeAcctActionInsert
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeAcctActionInsert
(
SS
dbRow
*
pRow
)
{
SAcctObj
*
pAcct
=
p
WMsg
->
pRow
;
SAcctObj
*
pAcct
=
p
Row
->
pObj
;
memset
(
&
pAcct
->
acctInfo
,
0
,
sizeof
(
SAcctInfo
));
memset
(
&
pAcct
->
acctInfo
,
0
,
sizeof
(
SAcctInfo
));
pAcct
->
acctInfo
.
accessState
=
TSDB_VN_ALL_ACCCESS
;
pAcct
->
acctInfo
.
accessState
=
TSDB_VN_ALL_ACCCESS
;
pthread_mutex_init
(
&
pAcct
->
mutex
,
NULL
);
pthread_mutex_init
(
&
pAcct
->
mutex
,
NULL
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeAcctActionDelete
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeAcctActionDelete
(
SS
dbRow
*
pRow
)
{
SAcctObj
*
pAcct
=
p
WMsg
->
pRow
;
SAcctObj
*
pAcct
=
p
Row
->
pObj
;
mnodeDropAllUsers
(
pAcct
);
mnodeDropAllUsers
(
pAcct
);
mnodeDropAllDbs
(
pAcct
);
mnodeDropAllDbs
(
pAcct
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeAcctActionUpdate
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeAcctActionUpdate
(
SS
dbRow
*
pRow
)
{
SAcctObj
*
pAcct
=
p
WMsg
->
pRow
;
SAcctObj
*
pAcct
=
p
Row
->
pObj
;
SAcctObj
*
pSaved
=
mnodeGetAcct
(
pAcct
->
user
);
SAcctObj
*
pSaved
=
mnodeGetAcct
(
pAcct
->
user
);
if
(
pAcct
!=
pSaved
)
{
if
(
pAcct
!=
pSaved
)
{
memcpy
(
pSaved
,
pAcct
,
tsAcctUpdateSize
);
memcpy
(
pSaved
,
pAcct
,
tsAcctUpdateSize
);
...
@@ -64,19 +63,19 @@ static int32_t mnodeAcctActionUpdate(SSWriteMsg *pWMsg) {
...
@@ -64,19 +63,19 @@ static int32_t mnodeAcctActionUpdate(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeAcctActionEncode
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeAcctActionEncode
(
SS
dbRow
*
pRow
)
{
SAcctObj
*
pAcct
=
p
WMsg
->
pRow
;
SAcctObj
*
pAcct
=
p
Row
->
pObj
;
memcpy
(
p
WMsg
->
rowData
,
pAcct
,
tsAcctUpdateSize
);
memcpy
(
p
Row
->
rowData
,
pAcct
,
tsAcctUpdateSize
);
p
WMsg
->
rowSize
=
tsAcctUpdateSize
;
p
Row
->
rowSize
=
tsAcctUpdateSize
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeAcctActionDecode
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeAcctActionDecode
(
SS
dbRow
*
pRow
)
{
SAcctObj
*
pAcct
=
(
SAcctObj
*
)
calloc
(
1
,
sizeof
(
SAcctObj
));
SAcctObj
*
pAcct
=
(
SAcctObj
*
)
calloc
(
1
,
sizeof
(
SAcctObj
));
if
(
pAcct
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
if
(
pAcct
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pAcct
,
p
WMsg
->
rowData
,
tsAcctUpdateSize
);
memcpy
(
pAcct
,
p
Row
->
rowData
,
tsAcctUpdateSize
);
p
WMsg
->
pRow
=
pAcct
;
p
Row
->
pObj
=
pAcct
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -226,13 +225,13 @@ static int32_t mnodeCreateRootAcct() {
...
@@ -226,13 +225,13 @@ static int32_t mnodeCreateRootAcct() {
pAcct
->
acctId
=
sdbGetId
(
tsAcctSdb
);
pAcct
->
acctId
=
sdbGetId
(
tsAcctSdb
);
pAcct
->
createdTime
=
taosGetTimestampMs
();
pAcct
->
createdTime
=
taosGetTimestampMs
();
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsAcctSdb
,
.
pTable
=
tsAcctSdb
,
.
p
Row
=
pAcct
,
.
p
Obj
=
pAcct
,
};
};
return
sdbInsertRow
(
&
wmsg
);
return
sdbInsertRow
(
&
row
);
}
}
#ifndef _ACCT
#ifndef _ACCT
...
...
src/mnode/src/mnodeCluster.c
浏览文件 @
f323186f
...
@@ -32,36 +32,36 @@ static int32_t mnodeCreateCluster();
...
@@ -32,36 +32,36 @@ static int32_t mnodeCreateCluster();
static
int32_t
mnodeGetClusterMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
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
mnodeRetrieveClusters
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeClusterActionDestroy
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeClusterActionDestroy
(
SS
dbRow
*
pRow
)
{
tfree
(
p
WMsg
->
pRow
);
tfree
(
p
Row
->
pObj
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeClusterActionInsert
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeClusterActionInsert
(
SS
dbRow
*
pRow
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeClusterActionDelete
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeClusterActionDelete
(
SS
dbRow
*
pRow
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeClusterActionUpdate
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeClusterActionUpdate
(
SS
dbRow
*
pRow
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeClusterActionEncode
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeClusterActionEncode
(
SS
dbRow
*
pRow
)
{
SClusterObj
*
pCluster
=
p
WMsg
->
pRow
;
SClusterObj
*
pCluster
=
p
Row
->
pObj
;
memcpy
(
p
WMsg
->
rowData
,
pCluster
,
tsClusterUpdateSize
);
memcpy
(
p
Row
->
rowData
,
pCluster
,
tsClusterUpdateSize
);
p
WMsg
->
rowSize
=
tsClusterUpdateSize
;
p
Row
->
rowSize
=
tsClusterUpdateSize
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeClusterActionDecode
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeClusterActionDecode
(
SS
dbRow
*
pRow
)
{
SClusterObj
*
pCluster
=
(
SClusterObj
*
)
calloc
(
1
,
sizeof
(
SClusterObj
));
SClusterObj
*
pCluster
=
(
SClusterObj
*
)
calloc
(
1
,
sizeof
(
SClusterObj
));
if
(
pCluster
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
if
(
pCluster
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pCluster
,
p
WMsg
->
rowData
,
tsClusterUpdateSize
);
memcpy
(
pCluster
,
p
Row
->
rowData
,
tsClusterUpdateSize
);
p
WMsg
->
pRow
=
pCluster
;
p
Row
->
pObj
=
pCluster
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -145,13 +145,13 @@ static int32_t mnodeCreateCluster() {
...
@@ -145,13 +145,13 @@ static int32_t mnodeCreateCluster() {
mDebug
(
"uid is %s"
,
pCluster
->
uid
);
mDebug
(
"uid is %s"
,
pCluster
->
uid
);
}
}
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsClusterSdb
,
.
pTable
=
tsClusterSdb
,
.
p
Row
=
pCluster
,
.
p
Obj
=
pCluster
,
};
};
return
sdbInsertRow
(
&
wmsg
);
return
sdbInsertRow
(
&
row
);
}
}
const
char
*
mnodeGetClusterId
()
{
const
char
*
mnodeGetClusterId
()
{
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
f323186f
...
@@ -56,8 +56,8 @@ static void mnodeDestroyDb(SDbObj *pDb) {
...
@@ -56,8 +56,8 @@ static void mnodeDestroyDb(SDbObj *pDb) {
tfree
(
pDb
);
tfree
(
pDb
);
}
}
static
int32_t
mnodeDbActionDestroy
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeDbActionDestroy
(
SS
dbRow
*
pRow
)
{
mnodeDestroyDb
(
p
WMsg
->
pRow
);
mnodeDestroyDb
(
p
Row
->
pObj
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -65,8 +65,8 @@ int64_t mnodeGetDbNum() {
...
@@ -65,8 +65,8 @@ int64_t mnodeGetDbNum() {
return
sdbGetNumOfRows
(
tsDbSdb
);
return
sdbGetNumOfRows
(
tsDbSdb
);
}
}
static
int32_t
mnodeDbActionInsert
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeDbActionInsert
(
SS
dbRow
*
pRow
)
{
SDbObj
*
pDb
=
p
WMsg
->
pRow
;
SDbObj
*
pDb
=
p
Row
->
pObj
;
SAcctObj
*
pAcct
=
mnodeGetAcct
(
pDb
->
acct
);
SAcctObj
*
pAcct
=
mnodeGetAcct
(
pDb
->
acct
);
pthread_mutex_init
(
&
pDb
->
mutex
,
NULL
);
pthread_mutex_init
(
&
pDb
->
mutex
,
NULL
);
...
@@ -91,8 +91,8 @@ static int32_t mnodeDbActionInsert(SSWriteMsg *pWMsg) {
...
@@ -91,8 +91,8 @@ static int32_t mnodeDbActionInsert(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeDbActionDelete
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeDbActionDelete
(
SS
dbRow
*
pRow
)
{
SDbObj
*
pDb
=
p
WMsg
->
pRow
;
SDbObj
*
pDb
=
p
Row
->
pObj
;
SAcctObj
*
pAcct
=
mnodeGetAcct
(
pDb
->
acct
);
SAcctObj
*
pAcct
=
mnodeGetAcct
(
pDb
->
acct
);
mnodeDropAllChildTables
(
pDb
);
mnodeDropAllChildTables
(
pDb
);
...
@@ -107,11 +107,11 @@ static int32_t mnodeDbActionDelete(SSWriteMsg *pWMsg) {
...
@@ -107,11 +107,11 @@ static int32_t mnodeDbActionDelete(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeDbActionUpdate
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeDbActionUpdate
(
SS
dbRow
*
pRow
)
{
SDbObj
*
pNew
=
p
WMsg
->
pRow
;
SDbObj
*
pNew
=
p
Row
->
pObj
;
SDbObj
*
pDb
=
mnodeGetDb
(
pNew
->
name
);
SDbObj
*
pDb
=
mnodeGetDb
(
pNew
->
name
);
if
(
pDb
!=
NULL
&&
pNew
!=
pDb
)
{
if
(
pDb
!=
NULL
&&
pNew
!=
pDb
)
{
memcpy
(
pDb
,
pNew
,
p
WMsg
->
rowSize
);
memcpy
(
pDb
,
pNew
,
p
Row
->
rowSize
);
free
(
pNew
->
vgList
);
free
(
pNew
->
vgList
);
free
(
pNew
);
free
(
pNew
);
}
}
...
@@ -120,19 +120,19 @@ static int32_t mnodeDbActionUpdate(SSWriteMsg *pWMsg) {
...
@@ -120,19 +120,19 @@ static int32_t mnodeDbActionUpdate(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeDbActionEncode
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeDbActionEncode
(
SS
dbRow
*
pRow
)
{
SDbObj
*
pDb
=
p
WMsg
->
pRow
;
SDbObj
*
pDb
=
p
Row
->
pObj
;
memcpy
(
p
WMsg
->
rowData
,
pDb
,
tsDbUpdateSize
);
memcpy
(
p
Row
->
rowData
,
pDb
,
tsDbUpdateSize
);
p
WMsg
->
rowSize
=
tsDbUpdateSize
;
p
Row
->
rowSize
=
tsDbUpdateSize
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeDbActionDecode
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeDbActionDecode
(
SS
dbRow
*
pRow
)
{
SDbObj
*
pDb
=
(
SDbObj
*
)
calloc
(
1
,
sizeof
(
SDbObj
));
SDbObj
*
pDb
=
(
SDbObj
*
)
calloc
(
1
,
sizeof
(
SDbObj
));
if
(
pDb
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
if
(
pDb
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pDb
,
p
WMsg
->
rowData
,
tsDbUpdateSize
);
memcpy
(
pDb
,
p
Row
->
rowData
,
tsDbUpdateSize
);
p
WMsg
->
pRow
=
pDb
;
p
Row
->
pObj
=
pDb
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -412,16 +412,16 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
...
@@ -412,16 +412,16 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
pMsg
->
pDb
=
pDb
;
pMsg
->
pDb
=
pDb
;
mnodeIncDbRef
(
pDb
);
mnodeIncDbRef
(
pDb
);
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsDbSdb
,
.
pTable
=
tsDbSdb
,
.
p
Row
=
pDb
,
.
p
Obj
=
pDb
,
.
rowSize
=
sizeof
(
SDbObj
),
.
rowSize
=
sizeof
(
SDbObj
),
.
pMsg
=
pMsg
,
.
pMsg
=
pMsg
,
.
fpRsp
=
mnodeCreateDbCb
.
fpRsp
=
mnodeCreateDbCb
};
};
code
=
sdbInsertRow
(
&
wmsg
);
code
=
sdbInsertRow
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"db:%s, failed to create, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
mError
(
"db:%s, failed to create, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
pMsg
->
pDb
=
NULL
;
pMsg
->
pDb
=
NULL
;
...
@@ -440,8 +440,8 @@ bool mnodeCheckIsMonitorDB(char *db, char *monitordb) {
...
@@ -440,8 +440,8 @@ bool mnodeCheckIsMonitorDB(char *db, char *monitordb) {
}
}
#if 0
#if 0
void mnodePrintVgroups(SDbObj *pDb, char *
wmsg
) {
void mnodePrintVgroups(SDbObj *pDb, char *
row
) {
mInfo("db:%s, vgroup link from head,
wmsg:%s", pDb->name, wmsg
);
mInfo("db:%s, vgroup link from head,
row:%s", pDb->name, row
);
SVgObj *pVgroup = pDb->pHead;
SVgObj *pVgroup = pDb->pHead;
while (pVgroup != NULL) {
while (pVgroup != NULL) {
mInfo("vgId:%d", pVgroup->vgId);
mInfo("vgId:%d", pVgroup->vgId);
...
@@ -807,13 +807,13 @@ static int32_t mnodeSetDbDropping(SDbObj *pDb) {
...
@@ -807,13 +807,13 @@ static int32_t mnodeSetDbDropping(SDbObj *pDb) {
if
(
pDb
->
status
)
return
TSDB_CODE_SUCCESS
;
if
(
pDb
->
status
)
return
TSDB_CODE_SUCCESS
;
pDb
->
status
=
true
;
pDb
->
status
=
true
;
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsDbSdb
,
.
pTable
=
tsDbSdb
,
.
p
Row
=
pDb
.
p
Obj
=
pDb
};
};
int32_t
code
=
sdbUpdateRow
(
&
wmsg
);
int32_t
code
=
sdbUpdateRow
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
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
));
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) {
...
@@ -1019,15 +1019,15 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
if
(
memcmp
(
&
newCfg
,
&
pDb
->
cfg
,
sizeof
(
SDbCfg
))
!=
0
)
{
if
(
memcmp
(
&
newCfg
,
&
pDb
->
cfg
,
sizeof
(
SDbCfg
))
!=
0
)
{
pDb
->
cfg
=
newCfg
;
pDb
->
cfg
=
newCfg
;
pDb
->
cfgVersion
++
;
pDb
->
cfgVersion
++
;
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsDbSdb
,
.
pTable
=
tsDbSdb
,
.
p
Row
=
pDb
,
.
p
Obj
=
pDb
,
.
pMsg
=
pMsg
,
.
pMsg
=
pMsg
,
.
fpRsp
=
mnodeAlterDbCb
.
fpRsp
=
mnodeAlterDbCb
};
};
code
=
sdbUpdateRow
(
&
wmsg
);
code
=
sdbUpdateRow
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"db:%s, failed to alter, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
mError
(
"db:%s, failed to alter, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
}
}
...
@@ -1071,15 +1071,15 @@ static int32_t mnodeDropDb(SMnodeMsg *pMsg) {
...
@@ -1071,15 +1071,15 @@ static int32_t mnodeDropDb(SMnodeMsg *pMsg) {
SDbObj
*
pDb
=
pMsg
->
pDb
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
mInfo
(
"db:%s, drop db from sdb"
,
pDb
->
name
);
mInfo
(
"db:%s, drop db from sdb"
,
pDb
->
name
);
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsDbSdb
,
.
pTable
=
tsDbSdb
,
.
p
Row
=
pDb
,
.
p
Obj
=
pDb
,
.
pMsg
=
pMsg
,
.
pMsg
=
pMsg
,
.
fpRsp
=
mnodeDropDbCb
.
fpRsp
=
mnodeDropDbCb
};
};
int32_t
code
=
sdbDeleteRow
(
&
wmsg
);
int32_t
code
=
sdbDeleteRow
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"db:%s, failed to drop, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
mError
(
"db:%s, failed to drop, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
}
}
...
@@ -1134,13 +1134,13 @@ void mnodeDropAllDbs(SAcctObj *pAcct) {
...
@@ -1134,13 +1134,13 @@ void mnodeDropAllDbs(SAcctObj *pAcct) {
if
(
pDb
->
pAcct
==
pAcct
)
{
if
(
pDb
->
pAcct
==
pAcct
)
{
mInfo
(
"db:%s, drop db from sdb for acct:%s is dropped"
,
pDb
->
name
,
pAcct
->
user
);
mInfo
(
"db:%s, drop db from sdb for acct:%s is dropped"
,
pDb
->
name
,
pAcct
->
user
);
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_LOCAL
,
.
type
=
SDB_OPER_LOCAL
,
.
pTable
=
tsDbSdb
,
.
pTable
=
tsDbSdb
,
.
p
Row
=
pDb
.
p
Obj
=
pDb
};
};
sdbDeleteRow
(
&
wmsg
);
sdbDeleteRow
(
&
row
);
numOfDbs
++
;
numOfDbs
++
;
}
}
mnodeDecDbRef
(
pDb
);
mnodeDecDbRef
(
pDb
);
...
...
src/mnode/src/mnodeDnode.c
浏览文件 @
f323186f
...
@@ -87,13 +87,13 @@ static char* offlineReason[] = {
...
@@ -87,13 +87,13 @@ static char* offlineReason[] = {
"unknown"
,
"unknown"
,
};
};
static
int32_t
mnodeDnodeActionDestroy
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeDnodeActionDestroy
(
SS
dbRow
*
pRow
)
{
tfree
(
p
WMsg
->
pRow
);
tfree
(
p
Row
->
pObj
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeDnodeActionInsert
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeDnodeActionInsert
(
SS
dbRow
*
pRow
)
{
SDnodeObj
*
pDnode
=
p
WMsg
->
pRow
;
SDnodeObj
*
pDnode
=
p
Row
->
pObj
;
if
(
pDnode
->
status
!=
TAOS_DN_STATUS_DROPPING
)
{
if
(
pDnode
->
status
!=
TAOS_DN_STATUS_DROPPING
)
{
pDnode
->
status
=
TAOS_DN_STATUS_OFFLINE
;
pDnode
->
status
=
TAOS_DN_STATUS_OFFLINE
;
pDnode
->
lastAccess
=
tsAccessSquence
;
pDnode
->
lastAccess
=
tsAccessSquence
;
...
@@ -107,8 +107,8 @@ static int32_t mnodeDnodeActionInsert(SSWriteMsg *pWMsg) {
...
@@ -107,8 +107,8 @@ static int32_t mnodeDnodeActionInsert(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeDnodeActionDelete
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeDnodeActionDelete
(
SS
dbRow
*
pRow
)
{
SDnodeObj
*
pDnode
=
p
WMsg
->
pRow
;
SDnodeObj
*
pDnode
=
p
Row
->
pObj
;
#ifndef _SYNC
#ifndef _SYNC
mnodeDropAllDnodeVgroups
(
pDnode
);
mnodeDropAllDnodeVgroups
(
pDnode
);
...
@@ -121,11 +121,11 @@ static int32_t mnodeDnodeActionDelete(SSWriteMsg *pWMsg) {
...
@@ -121,11 +121,11 @@ static int32_t mnodeDnodeActionDelete(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeDnodeActionUpdate
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeDnodeActionUpdate
(
SS
dbRow
*
pRow
)
{
SDnodeObj
*
pNew
=
p
WMsg
->
pRow
;
SDnodeObj
*
pNew
=
p
Row
->
pObj
;
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pNew
->
dnodeId
);
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pNew
->
dnodeId
);
if
(
pDnode
!=
NULL
&&
pNew
!=
pDnode
)
{
if
(
pDnode
!=
NULL
&&
pNew
!=
pDnode
)
{
memcpy
(
pDnode
,
pNew
,
p
WMsg
->
rowSize
);
memcpy
(
pDnode
,
pNew
,
p
Row
->
rowSize
);
free
(
pNew
);
free
(
pNew
);
}
}
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
...
@@ -134,19 +134,19 @@ static int32_t mnodeDnodeActionUpdate(SSWriteMsg *pWMsg) {
...
@@ -134,19 +134,19 @@ static int32_t mnodeDnodeActionUpdate(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeDnodeActionEncode
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeDnodeActionEncode
(
SS
dbRow
*
pRow
)
{
SDnodeObj
*
pDnode
=
p
WMsg
->
pRow
;
SDnodeObj
*
pDnode
=
p
Row
->
pObj
;
memcpy
(
p
WMsg
->
rowData
,
pDnode
,
tsDnodeUpdateSize
);
memcpy
(
p
Row
->
rowData
,
pDnode
,
tsDnodeUpdateSize
);
p
WMsg
->
rowSize
=
tsDnodeUpdateSize
;
p
Row
->
rowSize
=
tsDnodeUpdateSize
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeDnodeActionDecode
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeDnodeActionDecode
(
SS
dbRow
*
pRow
)
{
SDnodeObj
*
pDnode
=
(
SDnodeObj
*
)
calloc
(
1
,
sizeof
(
SDnodeObj
));
SDnodeObj
*
pDnode
=
(
SDnodeObj
*
)
calloc
(
1
,
sizeof
(
SDnodeObj
));
if
(
pDnode
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
if
(
pDnode
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pDnode
,
p
WMsg
->
rowData
,
tsDnodeUpdateSize
);
memcpy
(
pDnode
,
p
Row
->
rowData
,
tsDnodeUpdateSize
);
p
WMsg
->
pRow
=
pDnode
;
p
Row
->
pObj
=
pDnode
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -296,13 +296,13 @@ void mnodeDecDnodeRef(SDnodeObj *pDnode) {
...
@@ -296,13 +296,13 @@ void mnodeDecDnodeRef(SDnodeObj *pDnode) {
}
}
void
mnodeUpdateDnode
(
SDnodeObj
*
pDnode
)
{
void
mnodeUpdateDnode
(
SDnodeObj
*
pDnode
)
{
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsDnodeSdb
,
.
pTable
=
tsDnodeSdb
,
.
p
Row
=
pDnode
.
p
Obj
=
pDnode
};
};
int32_t
code
=
sdbUpdateRow
(
&
wmsg
);
int32_t
code
=
sdbUpdateRow
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"dnodeId:%d, failed update"
,
pDnode
->
dnodeId
);
mError
(
"dnodeId:%d, failed update"
,
pDnode
->
dnodeId
);
}
}
...
@@ -644,15 +644,15 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) {
...
@@ -644,15 +644,15 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) {
tstrncpy
(
pDnode
->
dnodeEp
,
ep
,
TSDB_EP_LEN
);
tstrncpy
(
pDnode
->
dnodeEp
,
ep
,
TSDB_EP_LEN
);
taosGetFqdnPortFromEp
(
ep
,
pDnode
->
dnodeFqdn
,
&
pDnode
->
dnodePort
);
taosGetFqdnPortFromEp
(
ep
,
pDnode
->
dnodeFqdn
,
&
pDnode
->
dnodePort
);
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsDnodeSdb
,
.
pTable
=
tsDnodeSdb
,
.
p
Row
=
pDnode
,
.
p
Obj
=
pDnode
,
.
rowSize
=
sizeof
(
SDnodeObj
),
.
rowSize
=
sizeof
(
SDnodeObj
),
.
pMsg
=
pMsg
.
pMsg
=
pMsg
};
};
int32_t
code
=
sdbInsertRow
(
&
wmsg
);
int32_t
code
=
sdbInsertRow
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
int
dnodeId
=
pDnode
->
dnodeId
;
int
dnodeId
=
pDnode
->
dnodeId
;
tfree
(
pDnode
);
tfree
(
pDnode
);
...
@@ -665,14 +665,14 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) {
...
@@ -665,14 +665,14 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) {
}
}
int32_t
mnodeDropDnode
(
SDnodeObj
*
pDnode
,
void
*
pMsg
)
{
int32_t
mnodeDropDnode
(
SDnodeObj
*
pDnode
,
void
*
pMsg
)
{
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsDnodeSdb
,
.
pTable
=
tsDnodeSdb
,
.
p
Row
=
pDnode
,
.
p
Obj
=
pDnode
,
.
pMsg
=
pMsg
.
pMsg
=
pMsg
};
};
int32_t
code
=
sdbDeleteRow
(
&
wmsg
);
int32_t
code
=
sdbDeleteRow
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
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
));
mError
(
"dnode:%d, failed to drop from cluster, result:%s"
,
pDnode
->
dnodeId
,
tstrerror
(
code
));
}
else
{
}
else
{
...
...
src/mnode/src/mnodeMnode.c
浏览文件 @
f323186f
...
@@ -58,13 +58,13 @@ static int32_t mnodeRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, vo
...
@@ -58,13 +58,13 @@ static int32_t mnodeRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, vo
#define mnodeMnodeDestroyLock() pthread_mutex_destroy(&tsMnodeLock)
#define mnodeMnodeDestroyLock() pthread_mutex_destroy(&tsMnodeLock)
#endif
#endif
static
int32_t
mnodeMnodeActionDestroy
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeMnodeActionDestroy
(
SS
dbRow
*
pRow
)
{
tfree
(
p
WMsg
->
pRow
);
tfree
(
p
Row
->
pObj
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeMnodeActionInsert
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeMnodeActionInsert
(
SS
dbRow
*
pRow
)
{
SMnodeObj
*
pMnode
=
p
WMsg
->
pRow
;
SMnodeObj
*
pMnode
=
p
Row
->
pObj
;
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pMnode
->
mnodeId
);
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pMnode
->
mnodeId
);
if
(
pDnode
==
NULL
)
return
TSDB_CODE_MND_DNODE_NOT_EXIST
;
if
(
pDnode
==
NULL
)
return
TSDB_CODE_MND_DNODE_NOT_EXIST
;
...
@@ -76,8 +76,8 @@ static int32_t mnodeMnodeActionInsert(SSWriteMsg *pWMsg) {
...
@@ -76,8 +76,8 @@ static int32_t mnodeMnodeActionInsert(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeMnodeActionDelete
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeMnodeActionDelete
(
SS
dbRow
*
pRow
)
{
SMnodeObj
*
pMnode
=
p
WMsg
->
pRow
;
SMnodeObj
*
pMnode
=
p
Row
->
pObj
;
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pMnode
->
mnodeId
);
SDnodeObj
*
pDnode
=
mnodeGetDnode
(
pMnode
->
mnodeId
);
if
(
pDnode
==
NULL
)
return
TSDB_CODE_MND_DNODE_NOT_EXIST
;
if
(
pDnode
==
NULL
)
return
TSDB_CODE_MND_DNODE_NOT_EXIST
;
...
@@ -88,30 +88,30 @@ static int32_t mnodeMnodeActionDelete(SSWriteMsg *pWMsg) {
...
@@ -88,30 +88,30 @@ static int32_t mnodeMnodeActionDelete(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeMnodeActionUpdate
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeMnodeActionUpdate
(
SS
dbRow
*
pRow
)
{
SMnodeObj
*
pMnode
=
p
WMsg
->
pRow
;
SMnodeObj
*
pMnode
=
p
Row
->
pObj
;
SMnodeObj
*
pSaved
=
mnodeGetMnode
(
pMnode
->
mnodeId
);
SMnodeObj
*
pSaved
=
mnodeGetMnode
(
pMnode
->
mnodeId
);
if
(
pMnode
!=
pSaved
)
{
if
(
pMnode
!=
pSaved
)
{
memcpy
(
pSaved
,
pMnode
,
p
WMsg
->
rowSize
);
memcpy
(
pSaved
,
pMnode
,
p
Row
->
rowSize
);
free
(
pMnode
);
free
(
pMnode
);
}
}
mnodeDecMnodeRef
(
pSaved
);
mnodeDecMnodeRef
(
pSaved
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeMnodeActionEncode
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeMnodeActionEncode
(
SS
dbRow
*
pRow
)
{
SMnodeObj
*
pMnode
=
p
WMsg
->
pRow
;
SMnodeObj
*
pMnode
=
p
Row
->
pObj
;
memcpy
(
p
WMsg
->
rowData
,
pMnode
,
tsMnodeUpdateSize
);
memcpy
(
p
Row
->
rowData
,
pMnode
,
tsMnodeUpdateSize
);
p
WMsg
->
rowSize
=
tsMnodeUpdateSize
;
p
Row
->
rowSize
=
tsMnodeUpdateSize
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeMnodeActionDecode
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeMnodeActionDecode
(
SS
dbRow
*
pRow
)
{
SMnodeObj
*
pMnode
=
calloc
(
1
,
sizeof
(
SMnodeObj
));
SMnodeObj
*
pMnode
=
calloc
(
1
,
sizeof
(
SMnodeObj
));
if
(
pMnode
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
if
(
pMnode
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pMnode
,
p
WMsg
->
rowData
,
tsMnodeUpdateSize
);
memcpy
(
pMnode
,
p
Row
->
rowData
,
tsMnodeUpdateSize
);
p
WMsg
->
pRow
=
pMnode
;
p
Row
->
pObj
=
pMnode
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -325,10 +325,10 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
...
@@ -325,10 +325,10 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
pMnode
->
mnodeId
=
dnodeId
;
pMnode
->
mnodeId
=
dnodeId
;
pMnode
->
createdTime
=
taosGetTimestampMs
();
pMnode
->
createdTime
=
taosGetTimestampMs
();
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsMnodeSdb
,
.
pTable
=
tsMnodeSdb
,
.
p
Row
=
pMnode
,
.
p
Obj
=
pMnode
,
.
fpRsp
=
mnodeCreateMnodeCb
.
fpRsp
=
mnodeCreateMnodeCb
};
};
...
@@ -342,7 +342,7 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
...
@@ -342,7 +342,7 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
return
;
return
;
}
}
code
=
sdbInsertRow
(
&
wmsg
);
code
=
sdbInsertRow
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
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
));
mError
(
"dnode:%d, failed to create mnode, ep:%s reason:%s"
,
dnodeId
,
dnodeEp
,
tstrerror
(
code
));
tfree
(
pMnode
);
tfree
(
pMnode
);
...
@@ -352,8 +352,8 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
...
@@ -352,8 +352,8 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
void
mnodeDropMnodeLocal
(
int32_t
dnodeId
)
{
void
mnodeDropMnodeLocal
(
int32_t
dnodeId
)
{
SMnodeObj
*
pMnode
=
mnodeGetMnode
(
dnodeId
);
SMnodeObj
*
pMnode
=
mnodeGetMnode
(
dnodeId
);
if
(
pMnode
!=
NULL
)
{
if
(
pMnode
!=
NULL
)
{
SS
WriteMsg
wmsg
=
{.
type
=
SDB_OPER_LOCAL
,
.
pTable
=
tsMnodeSdb
,
.
pRow
=
pMnode
};
SS
dbRow
row
=
{.
type
=
SDB_OPER_LOCAL
,
.
pTable
=
tsMnodeSdb
,
.
pObj
=
pMnode
};
sdbDeleteRow
(
&
wmsg
);
sdbDeleteRow
(
&
row
);
mnodeDecMnodeRef
(
pMnode
);
mnodeDecMnodeRef
(
pMnode
);
}
}
...
@@ -367,13 +367,13 @@ int32_t mnodeDropMnode(int32_t dnodeId) {
...
@@ -367,13 +367,13 @@ int32_t mnodeDropMnode(int32_t dnodeId) {
return
TSDB_CODE_MND_DNODE_NOT_EXIST
;
return
TSDB_CODE_MND_DNODE_NOT_EXIST
;
}
}
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsMnodeSdb
,
.
pTable
=
tsMnodeSdb
,
.
p
Row
=
pMnode
.
p
Obj
=
pMnode
};
};
int32_t
code
=
sdbDeleteRow
(
&
wmsg
);
int32_t
code
=
sdbDeleteRow
(
&
row
);
sdbDecRef
(
tsMnodeSdb
,
pMnode
);
sdbDecRef
(
tsMnodeSdb
,
pMnode
);
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
f323186f
此差异已折叠。
点击以展开。
src/mnode/src/mnodeTable.c
浏览文件 @
f323186f
此差异已折叠。
点击以展开。
src/mnode/src/mnodeUser.c
浏览文件 @
f323186f
...
@@ -42,13 +42,13 @@ static int32_t mnodeProcessAlterUserMsg(SMnodeMsg *pMsg);
...
@@ -42,13 +42,13 @@ static int32_t mnodeProcessAlterUserMsg(SMnodeMsg *pMsg);
static
int32_t
mnodeProcessDropUserMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessDropUserMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessAuthMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessAuthMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeUserActionDestroy
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeUserActionDestroy
(
SS
dbRow
*
pRow
)
{
tfree
(
p
WMsg
->
pRow
);
tfree
(
p
Row
->
pObj
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeUserActionInsert
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeUserActionInsert
(
SS
dbRow
*
pRow
)
{
SUserObj
*
pUser
=
p
WMsg
->
pRow
;
SUserObj
*
pUser
=
p
Row
->
pObj
;
SAcctObj
*
pAcct
=
mnodeGetAcct
(
pUser
->
acct
);
SAcctObj
*
pAcct
=
mnodeGetAcct
(
pUser
->
acct
);
if
(
pAcct
!=
NULL
)
{
if
(
pAcct
!=
NULL
)
{
...
@@ -62,8 +62,8 @@ static int32_t mnodeUserActionInsert(SSWriteMsg *pWMsg) {
...
@@ -62,8 +62,8 @@ static int32_t mnodeUserActionInsert(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeUserActionDelete
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeUserActionDelete
(
SS
dbRow
*
pRow
)
{
SUserObj
*
pUser
=
p
WMsg
->
pRow
;
SUserObj
*
pUser
=
p
Row
->
pObj
;
SAcctObj
*
pAcct
=
mnodeGetAcct
(
pUser
->
acct
);
SAcctObj
*
pAcct
=
mnodeGetAcct
(
pUser
->
acct
);
if
(
pAcct
!=
NULL
)
{
if
(
pAcct
!=
NULL
)
{
...
@@ -74,8 +74,8 @@ static int32_t mnodeUserActionDelete(SSWriteMsg *pWMsg) {
...
@@ -74,8 +74,8 @@ static int32_t mnodeUserActionDelete(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeUserActionUpdate
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeUserActionUpdate
(
SS
dbRow
*
pRow
)
{
SUserObj
*
pUser
=
p
WMsg
->
pRow
;
SUserObj
*
pUser
=
p
Row
->
pObj
;
SUserObj
*
pSaved
=
mnodeGetUser
(
pUser
->
user
);
SUserObj
*
pSaved
=
mnodeGetUser
(
pUser
->
user
);
if
(
pUser
!=
pSaved
)
{
if
(
pUser
!=
pSaved
)
{
memcpy
(
pSaved
,
pUser
,
tsUserUpdateSize
);
memcpy
(
pSaved
,
pUser
,
tsUserUpdateSize
);
...
@@ -85,19 +85,19 @@ static int32_t mnodeUserActionUpdate(SSWriteMsg *pWMsg) {
...
@@ -85,19 +85,19 @@ static int32_t mnodeUserActionUpdate(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeUserActionEncode
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeUserActionEncode
(
SS
dbRow
*
pRow
)
{
SUserObj
*
pUser
=
p
WMsg
->
pRow
;
SUserObj
*
pUser
=
p
Row
->
pObj
;
memcpy
(
p
WMsg
->
rowData
,
pUser
,
tsUserUpdateSize
);
memcpy
(
p
Row
->
rowData
,
pUser
,
tsUserUpdateSize
);
p
WMsg
->
rowSize
=
tsUserUpdateSize
;
p
Row
->
rowSize
=
tsUserUpdateSize
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeUserActionDecode
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeUserActionDecode
(
SS
dbRow
*
pRow
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
calloc
(
1
,
sizeof
(
SUserObj
));
SUserObj
*
pUser
=
(
SUserObj
*
)
calloc
(
1
,
sizeof
(
SUserObj
));
if
(
pUser
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
if
(
pUser
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pUser
,
p
WMsg
->
rowData
,
tsUserUpdateSize
);
memcpy
(
pUser
,
p
Row
->
rowData
,
tsUserUpdateSize
);
p
WMsg
->
pRow
=
pUser
;
p
Row
->
pObj
=
pUser
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -205,14 +205,14 @@ void mnodeDecUserRef(SUserObj *pUser) {
...
@@ -205,14 +205,14 @@ void mnodeDecUserRef(SUserObj *pUser) {
}
}
static
int32_t
mnodeUpdateUser
(
SUserObj
*
pUser
,
void
*
pMsg
)
{
static
int32_t
mnodeUpdateUser
(
SUserObj
*
pUser
,
void
*
pMsg
)
{
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsUserSdb
,
.
pTable
=
tsUserSdb
,
.
p
Row
=
pUser
,
.
p
Obj
=
pUser
,
.
pMsg
=
pMsg
.
pMsg
=
pMsg
};
};
int32_t
code
=
sdbUpdateRow
(
&
wmsg
);
int32_t
code
=
sdbUpdateRow
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
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
));
mError
(
"user:%s, failed to alter by %s, reason:%s"
,
pUser
->
user
,
mnodeGetUserFromMsg
(
pMsg
),
tstrerror
(
code
));
}
else
{
}
else
{
...
@@ -259,15 +259,15 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) {
...
@@ -259,15 +259,15 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) {
pUser
->
superAuth
=
1
;
pUser
->
superAuth
=
1
;
}
}
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsUserSdb
,
.
pTable
=
tsUserSdb
,
.
p
Row
=
pUser
,
.
p
Obj
=
pUser
,
.
rowSize
=
sizeof
(
SUserObj
),
.
rowSize
=
sizeof
(
SUserObj
),
.
pMsg
=
pMsg
.
pMsg
=
pMsg
};
};
code
=
sdbInsertRow
(
&
wmsg
);
code
=
sdbInsertRow
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
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
));
mError
(
"user:%s, failed to create by %s, reason:%s"
,
pUser
->
user
,
mnodeGetUserFromMsg
(
pMsg
),
tstrerror
(
code
));
tfree
(
pUser
);
tfree
(
pUser
);
...
@@ -279,14 +279,14 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) {
...
@@ -279,14 +279,14 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) {
}
}
static
int32_t
mnodeDropUser
(
SUserObj
*
pUser
,
void
*
pMsg
)
{
static
int32_t
mnodeDropUser
(
SUserObj
*
pUser
,
void
*
pMsg
)
{
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsUserSdb
,
.
pTable
=
tsUserSdb
,
.
p
Row
=
pUser
,
.
p
Obj
=
pUser
,
.
pMsg
=
pMsg
.
pMsg
=
pMsg
};
};
int32_t
code
=
sdbDeleteRow
(
&
wmsg
);
int32_t
code
=
sdbDeleteRow
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
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
));
mError
(
"user:%s, failed to drop by %s, reason:%s"
,
pUser
->
user
,
mnodeGetUserFromMsg
(
pMsg
),
tstrerror
(
code
));
}
else
{
}
else
{
...
@@ -562,12 +562,12 @@ void mnodeDropAllUsers(SAcctObj *pAcct) {
...
@@ -562,12 +562,12 @@ void mnodeDropAllUsers(SAcctObj *pAcct) {
if
(
pUser
==
NULL
)
break
;
if
(
pUser
==
NULL
)
break
;
if
(
strncmp
(
pUser
->
acct
,
pAcct
->
user
,
acctNameLen
)
==
0
)
{
if
(
strncmp
(
pUser
->
acct
,
pAcct
->
user
,
acctNameLen
)
==
0
)
{
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_LOCAL
,
.
type
=
SDB_OPER_LOCAL
,
.
pTable
=
tsUserSdb
,
.
pTable
=
tsUserSdb
,
.
p
Row
=
pUser
,
.
p
Obj
=
pUser
,
};
};
sdbDeleteRow
(
&
wmsg
);
sdbDeleteRow
(
&
row
);
numOfUsers
++
;
numOfUsers
++
;
}
}
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
f323186f
...
@@ -72,13 +72,13 @@ static void mnodeDestroyVgroup(SVgObj *pVgroup) {
...
@@ -72,13 +72,13 @@ static void mnodeDestroyVgroup(SVgObj *pVgroup) {
tfree
(
pVgroup
);
tfree
(
pVgroup
);
}
}
static
int32_t
mnodeVgroupActionDestroy
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeVgroupActionDestroy
(
SS
dbRow
*
pRow
)
{
mnodeDestroyVgroup
(
p
WMsg
->
pRow
);
mnodeDestroyVgroup
(
p
Row
->
pObj
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeVgroupActionInsert
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeVgroupActionInsert
(
SS
dbRow
*
pRow
)
{
SVgObj
*
pVgroup
=
p
WMsg
->
pRow
;
SVgObj
*
pVgroup
=
p
Row
->
pObj
;
// refer to db
// refer to db
SDbObj
*
pDb
=
mnodeGetDb
(
pVgroup
->
dbName
);
SDbObj
*
pDb
=
mnodeGetDb
(
pVgroup
->
dbName
);
...
@@ -115,8 +115,8 @@ static int32_t mnodeVgroupActionInsert(SSWriteMsg *pWMsg) {
...
@@ -115,8 +115,8 @@ static int32_t mnodeVgroupActionInsert(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeVgroupActionDelete
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeVgroupActionDelete
(
SS
dbRow
*
pRow
)
{
SVgObj
*
pVgroup
=
p
WMsg
->
pRow
;
SVgObj
*
pVgroup
=
p
Row
->
pObj
;
if
(
pVgroup
->
pDb
==
NULL
)
{
if
(
pVgroup
->
pDb
==
NULL
)
{
mError
(
"vgId:%d, db:%s is not exist while insert into hash"
,
pVgroup
->
vgId
,
pVgroup
->
dbName
);
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 *pWMsg) {
...
@@ -137,8 +137,8 @@ static int32_t mnodeVgroupActionDelete(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeVgroupActionUpdate
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeVgroupActionUpdate
(
SS
dbRow
*
pRow
)
{
SVgObj
*
pNew
=
p
WMsg
->
pRow
;
SVgObj
*
pNew
=
p
Row
->
pObj
;
SVgObj
*
pVgroup
=
mnodeGetVgroup
(
pNew
->
vgId
);
SVgObj
*
pVgroup
=
mnodeGetVgroup
(
pNew
->
vgId
);
if
(
pVgroup
!=
pNew
)
{
if
(
pVgroup
!=
pNew
)
{
...
@@ -176,25 +176,25 @@ static int32_t mnodeVgroupActionUpdate(SSWriteMsg *pWMsg) {
...
@@ -176,25 +176,25 @@ static int32_t mnodeVgroupActionUpdate(SSWriteMsg *pWMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeVgroupActionEncode
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeVgroupActionEncode
(
SS
dbRow
*
pRow
)
{
SVgObj
*
pVgroup
=
p
WMsg
->
pRow
;
SVgObj
*
pVgroup
=
p
Row
->
pObj
;
memcpy
(
p
WMsg
->
rowData
,
pVgroup
,
tsVgUpdateSize
);
memcpy
(
p
Row
->
rowData
,
pVgroup
,
tsVgUpdateSize
);
SVgObj
*
pTmpVgroup
=
p
WMsg
->
rowData
;
SVgObj
*
pTmpVgroup
=
p
Row
->
rowData
;
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
TSDB_MAX_REPLICA
;
++
i
)
{
pTmpVgroup
->
vnodeGid
[
i
].
pDnode
=
NULL
;
pTmpVgroup
->
vnodeGid
[
i
].
pDnode
=
NULL
;
pTmpVgroup
->
vnodeGid
[
i
].
role
=
0
;
pTmpVgroup
->
vnodeGid
[
i
].
role
=
0
;
}
}
p
WMsg
->
rowSize
=
tsVgUpdateSize
;
p
Row
->
rowSize
=
tsVgUpdateSize
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeVgroupActionDecode
(
SS
WriteMsg
*
pWMsg
)
{
static
int32_t
mnodeVgroupActionDecode
(
SS
dbRow
*
pRow
)
{
SVgObj
*
pVgroup
=
(
SVgObj
*
)
calloc
(
1
,
sizeof
(
SVgObj
));
SVgObj
*
pVgroup
=
(
SVgObj
*
)
calloc
(
1
,
sizeof
(
SVgObj
));
if
(
pVgroup
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
if
(
pVgroup
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pVgroup
,
p
WMsg
->
rowData
,
tsVgUpdateSize
);
memcpy
(
pVgroup
,
p
Row
->
rowData
,
tsVgUpdateSize
);
p
WMsg
->
pRow
=
pVgroup
;
p
Row
->
pObj
=
pVgroup
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -253,13 +253,13 @@ SVgObj *mnodeGetVgroup(int32_t vgId) {
...
@@ -253,13 +253,13 @@ SVgObj *mnodeGetVgroup(int32_t vgId) {
}
}
void
mnodeUpdateVgroup
(
SVgObj
*
pVgroup
)
{
void
mnodeUpdateVgroup
(
SVgObj
*
pVgroup
)
{
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsVgroupSdb
,
.
pTable
=
tsVgroupSdb
,
.
p
Row
=
pVgroup
.
p
Obj
=
pVgroup
};
};
int32_t
code
=
sdbUpdateRow
(
&
wmsg
);
int32_t
code
=
sdbUpdateRow
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"vgId:%d, failed to update vgroup"
,
pVgroup
->
vgId
);
mError
(
"vgId:%d, failed to update vgroup"
,
pVgroup
->
vgId
);
}
}
...
@@ -519,14 +519,14 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -519,14 +519,14 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"app:%p:%p, vgId:%d, failed to create in sdb, reason:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pVgroup
->
vgId
,
mError
(
"app:%p:%p, vgId:%d, failed to create in sdb, reason:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pVgroup
->
vgId
,
tstrerror
(
code
));
tstrerror
(
code
));
SS
WriteMsg
desc
=
{.
type
=
SDB_OPER_GLOBAL
,
.
pRow
=
pVgroup
,
.
pTable
=
tsVgroupSdb
};
SS
dbRow
desc
=
{.
type
=
SDB_OPER_GLOBAL
,
.
pObj
=
pVgroup
,
.
pTable
=
tsVgroupSdb
};
sdbDeleteRow
(
&
desc
);
sdbDeleteRow
(
&
desc
);
return
code
;
return
code
;
}
else
{
}
else
{
mInfo
(
"app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pVgroup
->
vgId
,
mInfo
(
"app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pVgroup
->
vgId
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
pDb
->
name
,
pVgroup
->
numOfVnodes
);
pVgroup
->
status
=
TAOS_VG_STATUS_READY
;
pVgroup
->
status
=
TAOS_VG_STATUS_READY
;
SS
WriteMsg
desc
=
{.
type
=
SDB_OPER_GLOBAL
,
.
pRow
=
pVgroup
,
.
pTable
=
tsVgroupSdb
};
SS
dbRow
desc
=
{.
type
=
SDB_OPER_GLOBAL
,
.
pObj
=
pVgroup
,
.
pTable
=
tsVgroupSdb
};
(
void
)
sdbUpdateRow
(
&
desc
);
(
void
)
sdbUpdateRow
(
&
desc
);
dnodeReprocessMWriteMsg
(
pMsg
);
dnodeReprocessMWriteMsg
(
pMsg
);
...
@@ -535,7 +535,7 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -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,
// mInfo("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d", pMsg->rpcMsg.ahandle, pMsg, pVgroup->vgId,
// pDb->name, pVgroup->numOfVnodes);
// pDb->name, pVgroup->numOfVnodes);
// pVgroup->status = TAOS_VG_STATUS_READY;
// pVgroup->status = TAOS_VG_STATUS_READY;
// SS
WriteMsg desc = {.type = SDB_OPER_GLOBAL, .pRow
= pVgroup, .pTable = tsVgroupSdb};
// SS
dbRow desc = {.type = SDB_OPER_GLOBAL, .pObj
= pVgroup, .pTable = tsVgroupSdb};
// (void)sdbUpdateRow(&desc);
// (void)sdbUpdateRow(&desc);
// dnodeReprocessMWriteMsg(pMsg);
// dnodeReprocessMWriteMsg(pMsg);
// return TSDB_CODE_MND_ACTION_IN_PROGRESS;
// return TSDB_CODE_MND_ACTION_IN_PROGRESS;
...
@@ -571,16 +571,16 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) {
...
@@ -571,16 +571,16 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) {
pMsg
->
pVgroup
=
pVgroup
;
pMsg
->
pVgroup
=
pVgroup
;
mnodeIncVgroupRef
(
pVgroup
);
mnodeIncVgroupRef
(
pVgroup
);
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsVgroupSdb
,
.
pTable
=
tsVgroupSdb
,
.
p
Row
=
pVgroup
,
.
p
Obj
=
pVgroup
,
.
rowSize
=
sizeof
(
SVgObj
),
.
rowSize
=
sizeof
(
SVgObj
),
.
pMsg
=
pMsg
,
.
pMsg
=
pMsg
,
.
fpReq
=
mnodeCreateVgroupFp
.
fpReq
=
mnodeCreateVgroupFp
};
};
code
=
sdbInsertRow
(
&
wmsg
);
code
=
sdbInsertRow
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
pMsg
->
pVgroup
=
NULL
;
pMsg
->
pVgroup
=
NULL
;
mnodeDestroyVgroup
(
pVgroup
);
mnodeDestroyVgroup
(
pVgroup
);
...
@@ -595,12 +595,12 @@ void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle) {
...
@@ -595,12 +595,12 @@ void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle) {
}
else
{
}
else
{
mDebug
(
"vgId:%d, replica:%d is deleting from sdb"
,
pVgroup
->
vgId
,
pVgroup
->
numOfVnodes
);
mDebug
(
"vgId:%d, replica:%d is deleting from sdb"
,
pVgroup
->
vgId
,
pVgroup
->
numOfVnodes
);
mnodeSendDropVgroupMsg
(
pVgroup
,
NULL
);
mnodeSendDropVgroupMsg
(
pVgroup
,
NULL
);
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsVgroupSdb
,
.
pTable
=
tsVgroupSdb
,
.
p
Row
=
pVgroup
.
p
Obj
=
pVgroup
};
};
sdbDeleteRow
(
&
wmsg
);
sdbDeleteRow
(
&
row
);
}
}
}
}
...
@@ -957,28 +957,28 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
...
@@ -957,28 +957,28 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
if
(
mnodeMsg
->
received
!=
mnodeMsg
->
expected
)
return
;
if
(
mnodeMsg
->
received
!=
mnodeMsg
->
expected
)
return
;
if
(
mnodeMsg
->
received
==
mnodeMsg
->
successed
)
{
if
(
mnodeMsg
->
received
==
mnodeMsg
->
successed
)
{
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsVgroupSdb
,
.
pTable
=
tsVgroupSdb
,
.
p
Row
=
pVgroup
,
.
p
Obj
=
pVgroup
,
.
rowSize
=
sizeof
(
SVgObj
),
.
rowSize
=
sizeof
(
SVgObj
),
.
pMsg
=
mnodeMsg
,
.
pMsg
=
mnodeMsg
,
.
fpRsp
=
mnodeCreateVgroupCb
.
fpRsp
=
mnodeCreateVgroupCb
};
};
int32_t
code
=
sdbInsertRowToQueue
(
&
wmsg
);
int32_t
code
=
sdbInsertRowToQueue
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mnodeMsg
->
pVgroup
=
NULL
;
mnodeMsg
->
pVgroup
=
NULL
;
mnodeDestroyVgroup
(
pVgroup
);
mnodeDestroyVgroup
(
pVgroup
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
code
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
code
);
}
}
}
else
{
}
else
{
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsVgroupSdb
,
.
pTable
=
tsVgroupSdb
,
.
p
Row
=
pVgroup
.
p
Obj
=
pVgroup
};
};
sdbDeleteRow
(
&
wmsg
);
sdbDeleteRow
(
&
row
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
mnodeMsg
->
code
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
mnodeMsg
->
code
);
}
}
}
}
...
@@ -1031,12 +1031,12 @@ static void mnodeProcessDropVnodeRsp(SRpcMsg *rpcMsg) {
...
@@ -1031,12 +1031,12 @@ static void mnodeProcessDropVnodeRsp(SRpcMsg *rpcMsg) {
if
(
mnodeMsg
->
received
!=
mnodeMsg
->
expected
)
return
;
if
(
mnodeMsg
->
received
!=
mnodeMsg
->
expected
)
return
;
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsVgroupSdb
,
.
pTable
=
tsVgroupSdb
,
.
p
Row
=
pVgroup
.
p
Obj
=
pVgroup
};
};
int32_t
code
=
sdbDeleteRow
(
&
wmsg
);
int32_t
code
=
sdbDeleteRow
(
&
row
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
code
=
TSDB_CODE_MND_SDB_ERROR
;
code
=
TSDB_CODE_MND_SDB_ERROR
;
}
}
...
@@ -1084,12 +1084,12 @@ void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode) {
...
@@ -1084,12 +1084,12 @@ void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode) {
if
(
pVgroup
->
vnodeGid
[
0
].
dnodeId
==
pDropDnode
->
dnodeId
)
{
if
(
pVgroup
->
vnodeGid
[
0
].
dnodeId
==
pDropDnode
->
dnodeId
)
{
mnodeDropAllChildTablesInVgroups
(
pVgroup
);
mnodeDropAllChildTablesInVgroups
(
pVgroup
);
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_LOCAL
,
.
type
=
SDB_OPER_LOCAL
,
.
pTable
=
tsVgroupSdb
,
.
pTable
=
tsVgroupSdb
,
.
p
Row
=
pVgroup
,
.
p
Obj
=
pVgroup
,
};
};
sdbDeleteRow
(
&
wmsg
);
sdbDeleteRow
(
&
row
);
numOfVgroups
++
;
numOfVgroups
++
;
}
}
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
...
@@ -1135,12 +1135,12 @@ void mnodeDropAllDbVgroups(SDbObj *pDropDb) {
...
@@ -1135,12 +1135,12 @@ void mnodeDropAllDbVgroups(SDbObj *pDropDb) {
if
(
pVgroup
==
NULL
)
break
;
if
(
pVgroup
==
NULL
)
break
;
if
(
pVgroup
->
pDb
==
pDropDb
)
{
if
(
pVgroup
->
pDb
==
pDropDb
)
{
SS
WriteMsg
wmsg
=
{
SS
dbRow
row
=
{
.
type
=
SDB_OPER_LOCAL
,
.
type
=
SDB_OPER_LOCAL
,
.
pTable
=
tsVgroupSdb
,
.
pTable
=
tsVgroupSdb
,
.
p
Row
=
pVgroup
,
.
p
Obj
=
pVgroup
,
};
};
sdbDeleteRow
(
&
wmsg
);
sdbDeleteRow
(
&
row
);
numOfVgroups
++
;
numOfVgroups
++
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录