Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f7e40d0e
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f7e40d0e
编写于
11月 19, 2019
作者:
P
plum-lihui
提交者:
GitHub
11月 19, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #746 from taosdata/feature/slguan
Fix crashes and other exceptions that may occur when deleting a database
上级
a7b8c71a
eb6be387
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
305 addition
and
133 deletion
+305
-133
src/inc/taoserror.h
src/inc/taoserror.h
+2
-0
src/inc/tsdb.h
src/inc/tsdb.h
+26
-8
src/inc/tstatus.h
src/inc/tstatus.h
+5
-4
src/rpc/src/trpc.c
src/rpc/src/trpc.c
+4
-0
src/rpc/src/tstring.c
src/rpc/src/tstring.c
+2
-0
src/system/detail/inc/mgmtBalance.h
src/system/detail/inc/mgmtBalance.h
+0
-9
src/system/detail/inc/vnode.h
src/system/detail/inc/vnode.h
+1
-1
src/system/detail/src/dnodeMgmt.c
src/system/detail/src/dnodeMgmt.c
+23
-5
src/system/detail/src/mgmtDb.c
src/system/detail/src/mgmtDb.c
+5
-6
src/system/detail/src/mgmtDnode.c
src/system/detail/src/mgmtDnode.c
+9
-8
src/system/detail/src/mgmtDnodeInt.c
src/system/detail/src/mgmtDnodeInt.c
+3
-4
src/system/detail/src/mgmtMeter.c
src/system/detail/src/mgmtMeter.c
+42
-18
src/system/detail/src/mgmtShell.c
src/system/detail/src/mgmtShell.c
+36
-19
src/system/detail/src/mgmtVgroup.c
src/system/detail/src/mgmtVgroup.c
+16
-9
src/system/detail/src/vnodeCache.c
src/system/detail/src/vnodeCache.c
+1
-1
src/system/detail/src/vnodeFile.c
src/system/detail/src/vnodeFile.c
+1
-1
src/system/detail/src/vnodeShell.c
src/system/detail/src/vnodeShell.c
+17
-5
src/system/detail/src/vnodeStore.c
src/system/detail/src/vnodeStore.c
+56
-24
src/system/detail/src/vnodeStream.c
src/system/detail/src/vnodeStream.c
+1
-1
src/system/lite/src/dnodeMgmt.spec.c
src/system/lite/src/dnodeMgmt.spec.c
+1
-1
src/system/lite/src/mgmtDnode.spec.c
src/system/lite/src/mgmtDnode.spec.c
+1
-1
src/system/lite/src/mgmtDnodeInt.spec.c
src/system/lite/src/mgmtDnodeInt.spec.c
+2
-2
src/system/lite/src/vnodePeer.spec.c
src/system/lite/src/vnodePeer.spec.c
+3
-2
src/util/src/tstatus.c
src/util/src/tstatus.c
+48
-4
未找到文件。
src/inc/taoserror.h
浏览文件 @
f7e40d0e
...
@@ -134,6 +134,8 @@ extern "C" {
...
@@ -134,6 +134,8 @@ extern "C" {
#define TSDB_CODE_INVALID_SUBMIT_MSG 113
#define TSDB_CODE_INVALID_SUBMIT_MSG 113
#define TSDB_CODE_NOT_ACTIVE_TABLE 114
#define TSDB_CODE_NOT_ACTIVE_TABLE 114
#define TSDB_CODE_INVALID_TABLE_ID 115
#define TSDB_CODE_INVALID_TABLE_ID 115
#define TSDB_CODE_INVALID_VNODE_STATUS 116
#define TSDB_CODE_FAILED_TO_LOCK_RESOURCES 117
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/inc/tsdb.h
浏览文件 @
f7e40d0e
...
@@ -44,22 +44,40 @@ extern "C" {
...
@@ -44,22 +44,40 @@ extern "C" {
#define TSDB_TIME_PRECISION_MILLI_STR "ms"
#define TSDB_TIME_PRECISION_MILLI_STR "ms"
#define TSDB_TIME_PRECISION_MICRO_STR "us"
#define TSDB_TIME_PRECISION_MICRO_STR "us"
enum
_status
{
enum
_vnode_status
{
TSDB_STATUS_OFFLINE
,
TSDB_VNODE_STATUS_OFFLINE
,
TSDB_STATUS_CREATING
,
TSDB_VNODE_STATUS_CREATING
,
TSDB_STATUS_UNSYNCED
,
TSDB_VNODE_STATUS_UNSYNCED
,
TSDB_STATUS_SLAVE
,
TSDB_VNODE_STATUS_SLAVE
,
TSDB_STATUS_MASTER
,
TSDB_VNODE_STATUS_MASTER
,
TSDB_STATUS_READY
,
TSDB_VNODE_STATUS_CLOSING
,
TSDB_VNODE_STATUS_DELETING
,
};
};
enum
_
sync
status
{
enum
_
vnode_sync_
status
{
STDB_SSTATUS_INIT
,
STDB_SSTATUS_INIT
,
TSDB_SSTATUS_SYNCING
,
TSDB_SSTATUS_SYNCING
,
TSDB_SSTATUS_SYNC_CACHE
,
TSDB_SSTATUS_SYNC_CACHE
,
TSDB_SSTATUS_SYNC_FILE
,
TSDB_SSTATUS_SYNC_FILE
,
};
};
enum
_dnode_status
{
TSDB_DNODE_STATUS_OFFLINE
,
TSDB_DNODE_STATUS_READY
};
enum
_dnode_balance_status
{
LB_DNODE_STATE_BALANCED
,
LB_DNODE_STATE_BALANCING
,
LB_DNODE_STATE_OFFLINE_REMOVING
,
LB_DNODE_STATE_SHELL_REMOVING
};
enum
_vgroup_status
{
LB_VGROUP_STATE_READY
,
LB_VGROUP_STATE_UPDATE
};
#define TSDB_DATA_TYPE_BOOL 1 // 1 bytes
#define TSDB_DATA_TYPE_BOOL 1 // 1 bytes
#define TSDB_DATA_TYPE_TINYINT 2 // 1 byte
#define TSDB_DATA_TYPE_TINYINT 2 // 1 byte
#define TSDB_DATA_TYPE_SMALLINT 3 // 2 bytes
#define TSDB_DATA_TYPE_SMALLINT 3 // 2 bytes
...
...
src/inc/tstatus.h
浏览文件 @
f7e40d0e
...
@@ -20,10 +20,11 @@
...
@@ -20,10 +20,11 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
extern
char
*
sdbDnodeStatusStr
[];
const
char
*
taosGetVnodeStatusStr
(
int
vnodeStatus
);
extern
char
*
sdbDnodeBalanceStateStr
[];
const
char
*
taosGetDnodeStatusStr
(
int
dnodeStatus
);
extern
char
*
sdbVnodeDropStateStr
[];
const
char
*
taosGetDnodeBalanceStateStr
(
int
dnodeBalanceStatus
);
extern
char
*
sdbVnodeSyncStatusStr
[];
const
char
*
taosGetVnodeSyncStatusStr
(
int
vnodeSyncStatus
);
const
char
*
taosGetVnodeDropStatusStr
(
int
dropping
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/rpc/src/trpc.c
浏览文件 @
f7e40d0e
...
@@ -354,6 +354,8 @@ int taosOpenRpcChannWithQ(void *handle, int cid, int sessions, void *qhandle) {
...
@@ -354,6 +354,8 @@ int taosOpenRpcChannWithQ(void *handle, int cid, int sessions, void *qhandle) {
STaosRpc
*
pServer
=
(
STaosRpc
*
)
handle
;
STaosRpc
*
pServer
=
(
STaosRpc
*
)
handle
;
SRpcChann
*
pChann
;
SRpcChann
*
pChann
;
tTrace
(
"cid:%d, handle:%p open rpc chann"
,
cid
,
handle
);
if
(
pServer
==
NULL
)
return
-
1
;
if
(
pServer
==
NULL
)
return
-
1
;
if
(
cid
>=
pServer
->
numOfChanns
||
cid
<
0
)
{
if
(
cid
>=
pServer
->
numOfChanns
||
cid
<
0
)
{
tError
(
"%s: cid:%d, chann is out of range, max:%d"
,
pServer
->
label
,
cid
,
pServer
->
numOfChanns
);
tError
(
"%s: cid:%d, chann is out of range, max:%d"
,
pServer
->
label
,
cid
,
pServer
->
numOfChanns
);
...
@@ -402,6 +404,8 @@ void taosCloseRpcChann(void *handle, int cid) {
...
@@ -402,6 +404,8 @@ void taosCloseRpcChann(void *handle, int cid) {
STaosRpc
*
pServer
=
(
STaosRpc
*
)
handle
;
STaosRpc
*
pServer
=
(
STaosRpc
*
)
handle
;
SRpcChann
*
pChann
;
SRpcChann
*
pChann
;
tTrace
(
"cid:%d, handle:%p close rpc chann"
,
cid
,
handle
);
if
(
pServer
==
NULL
)
return
;
if
(
pServer
==
NULL
)
return
;
if
(
cid
>=
pServer
->
numOfChanns
||
cid
<
0
)
{
if
(
cid
>=
pServer
->
numOfChanns
||
cid
<
0
)
{
tError
(
"%s cid:%d, chann is out of range, max:%d"
,
pServer
->
label
,
cid
,
pServer
->
numOfChanns
);
tError
(
"%s cid:%d, chann is out of range, max:%d"
,
pServer
->
label
,
cid
,
pServer
->
numOfChanns
);
...
...
src/rpc/src/tstring.c
浏览文件 @
f7e40d0e
...
@@ -240,4 +240,6 @@ char *tsError[] = {"success",
...
@@ -240,4 +240,6 @@ char *tsError[] = {"success",
"invalid submit message"
,
"invalid submit message"
,
"not active table(not created yet or deleted already)"
,
//114
"not active table(not created yet or deleted already)"
,
//114
"invalid table id"
,
"invalid table id"
,
"invalid vnode status"
,
//116
"failed to lock resources"
,
};
};
src/system/detail/inc/mgmtBalance.h
浏览文件 @
f7e40d0e
...
@@ -28,15 +28,6 @@ extern "C" {
...
@@ -28,15 +28,6 @@ extern "C" {
#include "tstatus.h"
#include "tstatus.h"
#include "ttime.h"
#include "ttime.h"
enum
{
LB_DNODE_STATE_BALANCED
,
LB_DNODE_STATE_BALANCING
,
LB_DNODE_STATE_OFFLINE_REMOVING
,
LB_DNODE_STATE_SHELL_REMOVING
};
enum
{
LB_VGROUP_STATE_READY
,
LB_VGROUP_STATE_UPDATE
};
void
mgmtCreateDnodeOrderList
();
void
mgmtCreateDnodeOrderList
();
void
mgmtReleaseDnodeOrderList
();
void
mgmtReleaseDnodeOrderList
();
...
...
src/system/detail/inc/vnode.h
浏览文件 @
f7e40d0e
...
@@ -92,7 +92,7 @@ typedef struct {
...
@@ -92,7 +92,7 @@ typedef struct {
SVPeerDesc
vpeers
[
TSDB_VNODES_SUPPORT
];
SVPeerDesc
vpeers
[
TSDB_VNODES_SUPPORT
];
SVnodePeer
*
peerInfo
[
TSDB_VNODES_SUPPORT
];
SVnodePeer
*
peerInfo
[
TSDB_VNODES_SUPPORT
];
char
selfIndex
;
char
selfIndex
;
char
s
tatus
;
char
vnodeS
tatus
;
char
accessState
;
// Vnode access state, Readable/Writable
char
accessState
;
// Vnode access state, Readable/Writable
char
syncStatus
;
char
syncStatus
;
char
commitInProcess
;
char
commitInProcess
;
...
...
src/system/detail/src/dnodeMgmt.c
浏览文件 @
f7e40d0e
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include "vnodeMgmt.h"
#include "vnodeMgmt.h"
#include "vnodeSystem.h"
#include "vnodeSystem.h"
#include "vnodeUtil.h"
#include "vnodeUtil.h"
#include "tstatus.h"
SMgmtObj
mgmtObj
;
SMgmtObj
mgmtObj
;
extern
uint64_t
tsCreatedTime
;
extern
uint64_t
tsCreatedTime
;
...
@@ -330,7 +331,7 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
...
@@ -330,7 +331,7 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
return
-
1
;
return
-
1
;
}
}
if
(
vnodeList
[
vnode
].
status
==
TSDB
_STATUS_CREATING
)
{
if
(
vnodeList
[
vnode
].
vnodeStatus
==
TSDB_VNODE
_STATUS_CREATING
)
{
dTrace
(
"vid:%d, vnode is still under creating"
,
vnode
);
dTrace
(
"vid:%d, vnode is still under creating"
,
vnode
);
return
0
;
return
0
;
}
}
...
@@ -359,13 +360,27 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
...
@@ -359,13 +360,27 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
}
}
if
(
vnodeList
[
vnode
].
cfg
.
maxSessions
==
0
)
{
if
(
vnodeList
[
vnode
].
cfg
.
maxSessions
==
0
)
{
dTrace
(
"vid:%d, vnode is empty"
,
vnode
);
if
(
pCfg
->
maxSessions
>
0
)
{
if
(
pCfg
->
maxSessions
>
0
)
{
return
vnodeCreateVnode
(
vnode
,
pCfg
,
pMsg
->
vpeerDesc
);
if
(
vnodeList
[
vnode
].
vnodeStatus
==
TSDB_VNODE_STATUS_OFFLINE
)
{
dTrace
(
"vid:%d, status:%s, start to create vnode"
,
vnode
,
taosGetVnodeStatusStr
(
vnodeList
[
vnode
].
vnodeStatus
));
return
vnodeCreateVnode
(
vnode
,
pCfg
,
pMsg
->
vpeerDesc
);
}
else
{
dTrace
(
"vid:%d, status:%s, cannot preform create vnode operation"
,
vnode
,
taosGetVnodeStatusStr
(
vnodeList
[
vnode
].
vnodeStatus
));
return
TSDB_CODE_INVALID_VNODE_STATUS
;
}
}
}
}
else
{
}
else
{
dTrace
(
"vid:%d, vnode is not empty"
,
vnode
);
if
(
pCfg
->
maxSessions
>
0
)
{
if
(
pCfg
->
maxSessions
>
0
)
{
if
(
vnodeList
[
vnode
].
vnodeStatus
==
TSDB_VNODE_STATUS_DELETING
)
{
dTrace
(
"vid:%d, status:%s, wait vnode delete finished"
,
vnode
,
taosGetVnodeStatusStr
(
vnodeList
[
vnode
].
vnodeStatus
));
}
else
{
dTrace
(
"vid:%d, status:%s, start to update vnode"
,
vnode
,
taosGetVnodeStatusStr
(
vnodeList
[
vnode
].
vnodeStatus
));
}
/*
if (pCfg->maxSessions != vnodeList[vnode].cfg.maxSessions) {
if (pCfg->maxSessions != vnodeList[vnode].cfg.maxSessions) {
vnodeCleanUpOneVnode
(
vnode
);
vnodeCleanUpOneVnode(vnode);
}
}
vnodeConfigVPeers(vnode, pCfg->replications, pMsg->vpeerDesc);
vnodeConfigVPeers(vnode, pCfg->replications, pMsg->vpeerDesc);
...
@@ -376,7 +391,10 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
...
@@ -376,7 +391,10 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
vnodeList[vnode].cfg.maxSessions = pCfg->maxSessions;
vnodeList[vnode].cfg.maxSessions = pCfg->maxSessions;
vnodeOpenVnode(vnode);
vnodeOpenVnode(vnode);
}
}
*/
return
0
;
}
else
{
}
else
{
dTrace
(
"vid:%d, status:%s, start to delete vnode"
,
vnode
,
taosGetVnodeStatusStr
(
vnodeList
[
vnode
].
vnodeStatus
));
vnodeRemoveVnode
(
vnode
);
vnodeRemoveVnode
(
vnode
);
}
}
}
}
...
@@ -434,11 +452,11 @@ int vnodeProcessFreeVnodeRequest(char *pMsg, int msgLen, SMgmtObj *pMgmtObj) {
...
@@ -434,11 +452,11 @@ int vnodeProcessFreeVnodeRequest(char *pMsg, int msgLen, SMgmtObj *pMgmtObj) {
pFree
->
vnode
=
htons
(
pFree
->
vnode
);
pFree
->
vnode
=
htons
(
pFree
->
vnode
);
if
(
pFree
->
vnode
<
0
||
pFree
->
vnode
>=
TSDB_MAX_VNODES
)
{
if
(
pFree
->
vnode
<
0
||
pFree
->
vnode
>=
TSDB_MAX_VNODES
)
{
dWarn
(
"vid:%d out of range"
,
pFree
->
vnode
);
dWarn
(
"vid:%d
,
out of range"
,
pFree
->
vnode
);
return
-
1
;
return
-
1
;
}
}
dTrace
(
"vid:%d receive free vnode message"
,
pFree
->
vnode
);
dTrace
(
"vid:%d
,
receive free vnode message"
,
pFree
->
vnode
);
int32_t
code
=
vnodeRemoveVnode
(
pFree
->
vnode
);
int32_t
code
=
vnodeRemoveVnode
(
pFree
->
vnode
);
assert
(
code
==
TSDB_CODE_SUCCESS
||
code
==
TSDB_CODE_ACTION_IN_PROGRESS
);
assert
(
code
==
TSDB_CODE_SUCCESS
||
code
==
TSDB_CODE_ACTION_IN_PROGRESS
);
...
...
src/system/detail/src/mgmtDb.c
浏览文件 @
f7e40d0e
...
@@ -141,11 +141,10 @@ int mgmtCheckDbParams(SCreateDbMsg *pCreate) {
...
@@ -141,11 +141,10 @@ int mgmtCheckDbParams(SCreateDbMsg *pCreate) {
if
(
pCreate
->
cacheNumOfBlocks
.
fraction
<
0
)
pCreate
->
cacheNumOfBlocks
.
fraction
=
tsAverageCacheBlocks
;
//
if
(
pCreate
->
cacheNumOfBlocks
.
fraction
<
0
)
pCreate
->
cacheNumOfBlocks
.
fraction
=
tsAverageCacheBlocks
;
//
//-1 for balance
//-1 for balance
#ifdef CLUSTER
if
(
pCreate
->
replications
<=
0
||
pCreate
->
replications
>
TSDB_REPLICA_MAX_NUM
)
{
if
(
pCreate
->
replications
>
TSDB_VNODES_SUPPORT
-
1
)
pCreate
->
replications
=
TSDB_VNODES_SUPPORT
-
1
;
mTrace
(
"invalid db option replications: %d"
,
pCreate
->
replications
);
#else
return
TSDB_CODE_INVALID_OPTION
;
pCreate
->
replications
=
1
;
}
#endif
if
(
pCreate
->
commitLog
<
0
||
pCreate
->
commitLog
>
1
)
{
if
(
pCreate
->
commitLog
<
0
||
pCreate
->
commitLog
>
1
)
{
mTrace
(
"invalid db option commitLog: %d"
,
pCreate
->
commitLog
);
mTrace
(
"invalid db option commitLog: %d"
,
pCreate
->
commitLog
);
...
@@ -316,7 +315,7 @@ bool mgmtCheckDropDbFinished(SDbObj *pDb) {
...
@@ -316,7 +315,7 @@ bool mgmtCheckDropDbFinished(SDbObj *pDb) {
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
pVnodeGid
->
ip
);
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
pVnodeGid
->
ip
);
if
(
pDnode
==
NULL
)
continue
;
if
(
pDnode
==
NULL
)
continue
;
if
(
pDnode
->
status
==
TSDB_STATUS_OFFLINE
)
continue
;
if
(
pDnode
->
status
==
TSDB_
DNODE_
STATUS_OFFLINE
)
continue
;
SVnodeLoad
*
pVload
=
&
pDnode
->
vload
[
pVnodeGid
->
vnode
];
SVnodeLoad
*
pVload
=
&
pDnode
->
vload
[
pVnodeGid
->
vnode
];
if
(
pVload
->
dropStatus
==
TSDB_VN_STATUS_DROPPING
)
{
if
(
pVload
->
dropStatus
==
TSDB_VN_STATUS_DROPPING
)
{
...
...
src/system/detail/src/mgmtDnode.c
浏览文件 @
f7e40d0e
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "mgmt.h"
#include "mgmt.h"
#include "tschemautil.h"
#include "tschemautil.h"
#include "tstatus.h"
#include "tstatus.h"
#include "tstatus.h"
bool
mgmtCheckModuleInDnode
(
SDnodeObj
*
pDnode
,
int
moduleType
);
bool
mgmtCheckModuleInDnode
(
SDnodeObj
*
pDnode
,
int
moduleType
);
int
mgmtGetDnodesNum
();
int
mgmtGetDnodesNum
();
...
@@ -43,9 +44,9 @@ void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode) {
...
@@ -43,9 +44,9 @@ void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode) {
pDnode
->
openVnodes
=
0
;
pDnode
->
openVnodes
=
0
;
#ifdef CLUSTER
#ifdef CLUSTER
pDnode
->
status
=
TSDB_STATUS_OFFLINE
;
pDnode
->
status
=
TSDB_
DNODE_
STATUS_OFFLINE
;
#else
#else
pDnode
->
status
=
TSDB_STATUS_READY
;
pDnode
->
status
=
TSDB_
DNODE_
STATUS_READY
;
#endif
#endif
}
}
...
@@ -57,9 +58,9 @@ void mgmtCalcNumOfFreeVnodes(SDnodeObj *pDnode) {
...
@@ -57,9 +58,9 @@ void mgmtCalcNumOfFreeVnodes(SDnodeObj *pDnode) {
if
(
pVload
->
vgId
!=
0
)
{
if
(
pVload
->
vgId
!=
0
)
{
mTrace
(
"dnode:%s, calc free vnodes, exist vnode:%d, vgroup:%d, state:%d %s, dropstate:%d %s, syncstatus:%d %s"
,
mTrace
(
"dnode:%s, calc free vnodes, exist vnode:%d, vgroup:%d, state:%d %s, dropstate:%d %s, syncstatus:%d %s"
,
taosIpStr
(
pDnode
->
privateIp
),
i
,
pVload
->
vgId
,
taosIpStr
(
pDnode
->
privateIp
),
i
,
pVload
->
vgId
,
pVload
->
status
,
sdbDnodeStatusStr
[
pVload
->
status
]
,
pVload
->
status
,
taosGetDnodeStatusStr
(
pVload
->
status
)
,
pVload
->
dropStatus
,
sdbVnodeDropStateStr
[
pVload
->
dropStatus
]
,
pVload
->
dropStatus
,
taosGetVnodeDropStatusStr
(
pVload
->
dropStatus
)
,
pVload
->
syncStatus
,
sdbVnodeSyncStatusStr
[
pVload
->
syncStatus
]
);
pVload
->
syncStatus
,
taosGetVnodeSyncStatusStr
(
pVload
->
syncStatus
)
);
totalVnodes
++
;
totalVnodes
++
;
}
}
}
}
...
@@ -196,11 +197,11 @@ int mgmtRetrieveDnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
...
@@ -196,11 +197,11 @@ int mgmtRetrieveDnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
sdbDnodeStatusStr
[
pDnode
->
status
]
);
strcpy
(
pWrite
,
taosGetDnodeStatusStr
(
pDnode
->
status
)
);
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
sdbDnodeBalanceStateStr
[
pDnode
->
lbState
]
);
strcpy
(
pWrite
,
taosGetDnodeBalanceStateStr
(
pDnode
->
lbState
)
);
cols
++
;
cols
++
;
tinet_ntoa
(
ipstr
,
pDnode
->
publicIp
);
tinet_ntoa
(
ipstr
,
pDnode
->
publicIp
);
...
@@ -292,7 +293,7 @@ int mgmtRetrieveModules(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
...
@@ -292,7 +293,7 @@ int mgmtRetrieveModules(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
sdbDnodeStatusStr
[
pDnode
->
status
]
);
strcpy
(
pWrite
,
taosGetDnodeStatusStr
(
pDnode
->
status
)
);
cols
++
;
cols
++
;
numOfRows
++
;
numOfRows
++
;
...
...
src/system/detail/src/mgmtDnodeInt.c
浏览文件 @
f7e40d0e
...
@@ -128,7 +128,7 @@ int mgmtProcessVPeersRsp(char *msg, int msgLen, SDnodeObj *pObj) {
...
@@ -128,7 +128,7 @@ int mgmtProcessVPeersRsp(char *msg, int msgLen, SDnodeObj *pObj) {
}
}
if
(
pDb
->
vgStatus
!=
TSDB_VG_STATUS_IN_PROGRESS
)
{
if
(
pDb
->
vgStatus
!=
TSDB_VG_STATUS_IN_PROGRESS
)
{
mTrace
(
"dnode:%s, db:%s vpeer rsp already disposed,
code:%d"
,
taosIpStr
(
pObj
->
privateIp
),
pRsp
->
more
,
pRsp
->
code
);
mTrace
(
"dnode:%s, db:%s vpeer rsp already disposed,
vgroup status:%d code:%d"
,
taosIpStr
(
pObj
->
privateIp
),
pRsp
->
more
,
pDb
->
vgStatus
,
pRsp
->
code
);
return
0
;
return
0
;
}
}
...
@@ -140,10 +140,11 @@ int mgmtProcessVPeersRsp(char *msg, int msgLen, SDnodeObj *pObj) {
...
@@ -140,10 +140,11 @@ int mgmtProcessVPeersRsp(char *msg, int msgLen, SDnodeObj *pObj) {
if
(
pRsp
->
code
==
TSDB_CODE_VG_COMMITLOG_INIT_FAILED
)
{
if
(
pRsp
->
code
==
TSDB_CODE_VG_COMMITLOG_INIT_FAILED
)
{
pDb
->
vgStatus
=
TSDB_VG_STATUS_COMMITLOG_INIT_FAILED
;
pDb
->
vgStatus
=
TSDB_VG_STATUS_COMMITLOG_INIT_FAILED
;
mError
(
"dnode:%s, db:%s vgroup commit log init failed, code:%d"
,
taosIpStr
(
pObj
->
privateIp
),
pRsp
->
more
,
pRsp
->
code
);
}
else
{
}
else
{
pDb
->
vgStatus
=
TSDB_VG_STATUS_INIT_FAILED
;
pDb
->
vgStatus
=
TSDB_VG_STATUS_INIT_FAILED
;
mError
(
"dnode:%s, db:%s vgroup init failed, code:%d"
,
taosIpStr
(
pObj
->
privateIp
),
pRsp
->
more
,
pRsp
->
code
);
}
}
mError
(
"dnode:%s, db:%s vgroup create failed, code:%d"
,
taosIpStr
(
pObj
->
privateIp
),
pRsp
->
more
,
pRsp
->
code
);
return
0
;
return
0
;
}
}
...
@@ -331,7 +332,6 @@ char *mgmtBuildVpeersIe(char *pMsg, SVgObj *pVgroup, int vnode) {
...
@@ -331,7 +332,6 @@ char *mgmtBuildVpeersIe(char *pMsg, SVgObj *pVgroup, int vnode) {
pCfg
->
replications
=
(
char
)
pVgroup
->
numOfVnodes
;
pCfg
->
replications
=
(
char
)
pVgroup
->
numOfVnodes
;
pCfg
->
rowsInFileBlock
=
htonl
(
pCfg
->
rowsInFileBlock
);
pCfg
->
rowsInFileBlock
=
htonl
(
pCfg
->
rowsInFileBlock
);
#ifdef CLUSTER
SVPeerDesc
*
vpeerDesc
=
pVPeers
->
vpeerDesc
;
SVPeerDesc
*
vpeerDesc
=
pVPeers
->
vpeerDesc
;
pMsg
=
(
char
*
)(
pVPeers
->
vpeerDesc
);
pMsg
=
(
char
*
)(
pVPeers
->
vpeerDesc
);
...
@@ -341,7 +341,6 @@ char *mgmtBuildVpeersIe(char *pMsg, SVgObj *pVgroup, int vnode) {
...
@@ -341,7 +341,6 @@ char *mgmtBuildVpeersIe(char *pMsg, SVgObj *pVgroup, int vnode) {
vpeerDesc
[
j
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
j
].
vnode
);
vpeerDesc
[
j
].
vnode
=
htonl
(
pVgroup
->
vnodeGid
[
j
].
vnode
);
pMsg
+=
sizeof
(
SVPeerDesc
);
pMsg
+=
sizeof
(
SVPeerDesc
);
}
}
#endif
return
pMsg
;
return
pMsg
;
}
}
...
...
src/system/detail/src/mgmtMeter.c
浏览文件 @
f7e40d0e
...
@@ -502,7 +502,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
...
@@ -502,7 +502,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
int
numOfTables
=
sdbGetNumOfRows
(
meterSdb
);
int
numOfTables
=
sdbGetNumOfRows
(
meterSdb
);
if
(
numOfTables
>=
tsMaxTables
)
{
if
(
numOfTables
>=
tsMaxTables
)
{
m
Warn
(
"numOfTables:%d, exceed tsMaxTables:%d"
,
numOfTables
,
tsMaxTables
);
m
Error
(
"table:%s, numOfTables:%d exceed maxTables:%d"
,
pCreate
->
meterId
,
numOfTables
,
tsMaxTables
);
return
TSDB_CODE_TOO_MANY_TABLES
;
return
TSDB_CODE_TOO_MANY_TABLES
;
}
}
...
@@ -510,6 +510,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
...
@@ -510,6 +510,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
assert
(
pAcct
!=
NULL
);
assert
(
pAcct
!=
NULL
);
int
code
=
mgmtCheckMeterLimit
(
pAcct
,
pCreate
);
int
code
=
mgmtCheckMeterLimit
(
pAcct
,
pCreate
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mError
(
"table:%s, exceed the limit"
,
pCreate
->
meterId
);
return
code
;
return
code
;
}
}
...
@@ -517,8 +518,10 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
...
@@ -517,8 +518,10 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pMeter
=
mgmtGetMeter
(
pCreate
->
meterId
);
pMeter
=
mgmtGetMeter
(
pCreate
->
meterId
);
if
(
pMeter
)
{
if
(
pMeter
)
{
if
(
pCreate
->
igExists
)
{
if
(
pCreate
->
igExists
)
{
mError
(
"table:%s, igExists is true"
,
pCreate
->
meterId
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
else
{
}
else
{
mError
(
"table:%s, table is already exist"
,
pCreate
->
meterId
);
return
TSDB_CODE_TABLE_ALREADY_EXIST
;
return
TSDB_CODE_TABLE_ALREADY_EXIST
;
}
}
}
}
...
@@ -533,6 +536,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
...
@@ -533,6 +536,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
char
*
pTagData
=
(
char
*
)
pCreate
->
schema
;
// it is a tag key
char
*
pTagData
=
(
char
*
)
pCreate
->
schema
;
// it is a tag key
pMetric
=
mgmtGetMeter
(
pTagData
);
pMetric
=
mgmtGetMeter
(
pTagData
);
if
(
pMetric
==
NULL
)
{
if
(
pMetric
==
NULL
)
{
mError
(
"table:%s, corresponding super table does not exist"
,
pCreate
->
meterId
);
return
TSDB_CODE_INVALID_TABLE
;
return
TSDB_CODE_INVALID_TABLE
;
}
}
...
@@ -545,6 +549,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
...
@@ -545,6 +549,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pMeter
->
schema
=
(
char
*
)
malloc
(
size
);
pMeter
->
schema
=
(
char
*
)
malloc
(
size
);
if
(
pMeter
->
schema
==
NULL
)
{
if
(
pMeter
->
schema
==
NULL
)
{
mgmtDestroyMeter
(
pMeter
);
mgmtDestroyMeter
(
pMeter
);
mError
(
"table:%s, corresponding super table schema is null"
,
pCreate
->
meterId
);
return
TSDB_CODE_INVALID_TABLE
;
return
TSDB_CODE_INVALID_TABLE
;
}
}
memset
(
pMeter
->
schema
,
0
,
size
);
memset
(
pMeter
->
schema
,
0
,
size
);
...
@@ -556,13 +561,13 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
...
@@ -556,13 +561,13 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pMeter
->
pTagData
=
pMeter
->
schema
;
pMeter
->
pTagData
=
pMeter
->
schema
;
pMeter
->
nextColId
=
pMetric
->
nextColId
;
pMeter
->
nextColId
=
pMetric
->
nextColId
;
memcpy
(
pMeter
->
pTagData
,
pTagData
,
size
);
memcpy
(
pMeter
->
pTagData
,
pTagData
,
size
);
}
else
{
}
else
{
int
numOfCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
int
numOfCols
=
pCreate
->
numOfColumns
+
pCreate
->
numOfTags
;
size
=
numOfCols
*
sizeof
(
SSchema
)
+
pCreate
->
sqlLen
;
size
=
numOfCols
*
sizeof
(
SSchema
)
+
pCreate
->
sqlLen
;
pMeter
->
schema
=
(
char
*
)
malloc
(
size
);
pMeter
->
schema
=
(
char
*
)
malloc
(
size
);
if
(
pMeter
->
schema
==
NULL
)
{
if
(
pMeter
->
schema
==
NULL
)
{
mgmtDestroyMeter
(
pMeter
);
mgmtDestroyMeter
(
pMeter
);
mError
(
"table:%s, no schema input"
,
pCreate
->
meterId
);
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
}
memset
(
pMeter
->
schema
,
0
,
size
);
memset
(
pMeter
->
schema
,
0
,
size
);
...
@@ -583,7 +588,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
...
@@ -583,7 +588,7 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pMeter
->
pSql
=
pMeter
->
schema
+
numOfCols
*
sizeof
(
SSchema
);
pMeter
->
pSql
=
pMeter
->
schema
+
numOfCols
*
sizeof
(
SSchema
);
memcpy
(
pMeter
->
pSql
,
(
char
*
)(
pCreate
->
schema
)
+
numOfCols
*
sizeof
(
SSchema
),
pCreate
->
sqlLen
);
memcpy
(
pMeter
->
pSql
,
(
char
*
)(
pCreate
->
schema
)
+
numOfCols
*
sizeof
(
SSchema
),
pCreate
->
sqlLen
);
pMeter
->
pSql
[
pCreate
->
sqlLen
-
1
]
=
0
;
pMeter
->
pSql
[
pCreate
->
sqlLen
-
1
]
=
0
;
mTrace
(
"
stream sql len:%d, sql:%s"
,
pCreate
->
sqlLen
,
pMeter
->
pSql
);
mTrace
(
"
table:%s, stream sql len:%d sql:%s"
,
pCreate
->
meterId
,
pCreate
->
sqlLen
,
pMeter
->
pSql
);
}
else
{
}
else
{
if
(
pCreate
->
numOfTags
>
0
)
{
if
(
pCreate
->
numOfTags
>
0
)
{
pMeter
->
meterType
=
TSDB_METER_METRIC
;
pMeter
->
meterType
=
TSDB_METER_METRIC
;
...
@@ -596,13 +601,14 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
...
@@ -596,13 +601,14 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pMeter
->
createdTime
=
taosGetTimestampMs
();
pMeter
->
createdTime
=
taosGetTimestampMs
();
strcpy
(
pMeter
->
meterId
,
pCreate
->
meterId
);
strcpy
(
pMeter
->
meterId
,
pCreate
->
meterId
);
if
(
pthread_rwlock_init
(
&
pMeter
->
rwLock
,
NULL
))
{
if
(
pthread_rwlock_init
(
&
pMeter
->
rwLock
,
NULL
))
{
mError
(
"
Failed to init meter lock"
);
mError
(
"
table:%s, failed to init meter lock"
,
pCreate
->
meterId
);
mgmtDestroyMeter
(
pMeter
);
mgmtDestroyMeter
(
pMeter
);
return
TSDB_CODE_
OTHER
S
;
return
TSDB_CODE_
FAILED_TO_LOCK_RESOURCE
S
;
}
}
code
=
mgmtCheckMeterGrant
(
pCreate
,
pMeter
);
code
=
mgmtCheckMeterGrant
(
pCreate
,
pMeter
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mError
(
"table:%s, grant expired"
,
pCreate
->
meterId
);
return
code
;
return
code
;
}
}
...
@@ -611,21 +617,25 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
...
@@ -611,21 +617,25 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
if
(
pDb
->
vgStatus
==
TSDB_VG_STATUS_IN_PROGRESS
)
{
if
(
pDb
->
vgStatus
==
TSDB_VG_STATUS_IN_PROGRESS
)
{
mgmtDestroyMeter
(
pMeter
);
mgmtDestroyMeter
(
pMeter
);
mTrace
(
"table:%s, vgroup in creating progress"
,
pCreate
->
meterId
);
return
TSDB_CODE_ACTION_IN_PROGRESS
;
return
TSDB_CODE_ACTION_IN_PROGRESS
;
}
}
if
(
pDb
->
vgStatus
==
TSDB_VG_STATUS_FULL
)
{
if
(
pDb
->
vgStatus
==
TSDB_VG_STATUS_FULL
)
{
mgmtDestroyMeter
(
pMeter
);
mgmtDestroyMeter
(
pMeter
);
mError
(
"table:%s, vgroup is full"
,
pCreate
->
meterId
);
return
TSDB_CODE_NO_ENOUGH_DNODES
;
return
TSDB_CODE_NO_ENOUGH_DNODES
;
}
}
if
(
pDb
->
vgStatus
==
TSDB_VG_STATUS_COMMITLOG_INIT_FAILED
)
{
if
(
pDb
->
vgStatus
==
TSDB_VG_STATUS_COMMITLOG_INIT_FAILED
)
{
mgmtDestroyMeter
(
pMeter
);
mgmtDestroyMeter
(
pMeter
);
mError
(
"table:%s, commit log init failed"
,
pCreate
->
meterId
);
return
TSDB_CODE_VG_COMMITLOG_INIT_FAILED
;
return
TSDB_CODE_VG_COMMITLOG_INIT_FAILED
;
}
}
if
(
pDb
->
vgStatus
==
TSDB_VG_STATUS_INIT_FAILED
)
{
if
(
pDb
->
vgStatus
==
TSDB_VG_STATUS_INIT_FAILED
)
{
mgmtDestroyMeter
(
pMeter
);
mgmtDestroyMeter
(
pMeter
);
mError
(
"table:%s, vgroup init failed"
,
pCreate
->
meterId
);
return
TSDB_CODE_VG_INIT_FAILED
;
return
TSDB_CODE_VG_INIT_FAILED
;
}
}
...
@@ -633,12 +643,13 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
...
@@ -633,12 +643,13 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pDb
->
vgStatus
=
TSDB_VG_STATUS_IN_PROGRESS
;
pDb
->
vgStatus
=
TSDB_VG_STATUS_IN_PROGRESS
;
mgmtCreateVgroup
(
pDb
);
mgmtCreateVgroup
(
pDb
);
mgmtDestroyMeter
(
pMeter
);
mgmtDestroyMeter
(
pMeter
);
mTrace
(
"table:%s, vgroup malloced, wait for create progress finished"
,
pCreate
->
meterId
);
return
TSDB_CODE_ACTION_IN_PROGRESS
;
return
TSDB_CODE_ACTION_IN_PROGRESS
;
}
}
int
sid
=
taosAllocateId
(
pVgroup
->
idPool
);
int
sid
=
taosAllocateId
(
pVgroup
->
idPool
);
if
(
sid
<
0
)
{
if
(
sid
<
0
)
{
mWarn
(
"
db:%s, vgroup:%d, run out of ID, num:%d"
,
pDb
->
name
,
pVgroup
->
vgId
,
taosIdPoolNumOfUsed
(
pVgroup
->
idPool
));
mWarn
(
"
table:%s, vgroup:%d run out of ID, num:%d"
,
pCreate
->
meterId
,
pVgroup
->
vgId
,
taosIdPoolNumOfUsed
(
pVgroup
->
idPool
));
pDb
->
vgStatus
=
TSDB_VG_STATUS_IN_PROGRESS
;
pDb
->
vgStatus
=
TSDB_VG_STATUS_IN_PROGRESS
;
mgmtCreateVgroup
(
pDb
);
mgmtCreateVgroup
(
pDb
);
mgmtDestroyMeter
(
pMeter
);
mgmtDestroyMeter
(
pMeter
);
...
@@ -650,18 +661,21 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
...
@@ -650,18 +661,21 @@ int mgmtCreateMeter(SDbObj *pDb, SCreateTableMsg *pCreate) {
pMeter
->
uid
=
(((
uint64_t
)
pMeter
->
gid
.
vgId
)
<<
40
)
+
((((
uint64_t
)
pMeter
->
gid
.
sid
)
&
((
1ul
<<
24
)
-
1ul
))
<<
16
)
+
pMeter
->
uid
=
(((
uint64_t
)
pMeter
->
gid
.
vgId
)
<<
40
)
+
((((
uint64_t
)
pMeter
->
gid
.
sid
)
&
((
1ul
<<
24
)
-
1ul
))
<<
16
)
+
((
uint64_t
)
sdbVersion
&
((
1ul
<<
16
)
-
1ul
));
((
uint64_t
)
sdbVersion
&
((
1ul
<<
16
)
-
1ul
));
mTrace
(
"
meter:%s, create meter in vgroup, vgId:%d, sid:%d, vnode:%d, uid:%d
"
,
mTrace
(
"
table:%s, create table in vgroup, vgId:%d sid:%d vnode:%d uid:%d db:%s
"
,
pMeter
->
meterId
,
pVgroup
->
vgId
,
sid
,
pVgroup
->
vnodeGid
[
0
].
vnode
,
pMeter
->
uid
);
pMeter
->
meterId
,
pVgroup
->
vgId
,
sid
,
pVgroup
->
vnodeGid
[
0
].
vnode
,
pMeter
->
uid
,
pDb
->
name
);
}
else
{
}
else
{
pMeter
->
uid
=
(((
uint64_t
)
pMeter
->
createdTime
)
<<
16
)
+
((
uint64_t
)
sdbVersion
&
((
1ul
<<
16
)
-
1ul
));
pMeter
->
uid
=
(((
uint64_t
)
pMeter
->
createdTime
)
<<
16
)
+
((
uint64_t
)
sdbVersion
&
((
1ul
<<
16
)
-
1ul
));
}
}
if
(
sdbInsertRow
(
meterSdb
,
pMeter
,
0
)
<
0
)
return
TSDB_CODE_SDB_ERROR
;
if
(
sdbInsertRow
(
meterSdb
,
pMeter
,
0
)
<
0
)
{
mError
(
"table:%s, update sdb error"
,
pCreate
->
meterId
);
return
TSDB_CODE_SDB_ERROR
;
}
// send create message to the selected vnode servers
// send create message to the selected vnode servers
if
(
pCreate
->
numOfTags
==
0
)
{
if
(
pCreate
->
numOfTags
==
0
)
{
mTrace
(
"
meter:%s, send msg to dnode, vgId:%d, sid:%d, vnode:%d, dbname:%s
"
,
mTrace
(
"
table:%s, send create msg to dnode, vgId:%d, sid:%d, vnode:%d
"
,
pMeter
->
meterId
,
pMeter
->
gid
.
vgId
,
pMeter
->
gid
.
sid
,
pVgroup
->
vnodeGid
[
0
].
vnode
,
pDb
->
name
);
pMeter
->
meterId
,
pMeter
->
gid
.
vgId
,
pMeter
->
gid
.
sid
,
pVgroup
->
vnodeGid
[
0
].
vnode
);
grantAddTimeSeries
(
pMeter
->
numOfColumns
-
1
);
grantAddTimeSeries
(
pMeter
->
numOfColumns
-
1
);
mgmtSendCreateMsgToVgroup
(
pMeter
,
pVgroup
);
mgmtSendCreateMsgToVgroup
(
pMeter
,
pVgroup
);
...
@@ -881,7 +895,10 @@ void mgmtCleanUpMeters() { sdbCloseTable(meterSdb); }
...
@@ -881,7 +895,10 @@ void mgmtCleanUpMeters() { sdbCloseTable(meterSdb); }
int
mgmtGetMeterMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
mgmtGetMeterMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
cols
=
0
;
int
cols
=
0
;
if
(
pConn
->
pDb
==
NULL
)
return
TSDB_CODE_DB_NOT_SELECTED
;
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
if
(
pDb
==
NULL
)
return
TSDB_CODE_DB_NOT_SELECTED
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
...
@@ -916,7 +933,7 @@ int mgmtGetMeterMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
...
@@ -916,7 +933,7 @@ int mgmtGetMeterMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
// pShow->numOfRows = sdbGetNumOfRows (meterSdb);
// pShow->numOfRows = sdbGetNumOfRows (meterSdb);
pShow
->
numOfRows
=
p
Conn
->
p
Db
->
numOfTables
;
pShow
->
numOfRows
=
pDb
->
numOfTables
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
return
0
;
return
0
;
...
@@ -1208,8 +1225,12 @@ int mgmtRetrieveMeters(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
...
@@ -1208,8 +1225,12 @@ int mgmtRetrieveMeters(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
int
numOfRead
=
0
;
int
numOfRead
=
0
;
char
prefix
[
20
]
=
{
0
};
char
prefix
[
20
]
=
{
0
};
if
(
pConn
->
pDb
==
NULL
)
return
0
;
SDbObj
*
pDb
=
NULL
;
strcpy
(
prefix
,
pConn
->
pDb
->
name
);
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
if
(
pDb
==
NULL
)
return
0
;
strcpy
(
prefix
,
pDb
->
name
);
strcat
(
prefix
,
TS_PATH_DELIMITER
);
strcat
(
prefix
,
TS_PATH_DELIMITER
);
prefixLen
=
strlen
(
prefix
);
prefixLen
=
strlen
(
prefix
);
...
@@ -1269,7 +1290,10 @@ int mgmtRetrieveMeters(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
...
@@ -1269,7 +1290,10 @@ int mgmtRetrieveMeters(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
int
mgmtGetMetricMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
mgmtGetMetricMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
cols
=
0
;
int
cols
=
0
;
if
(
pConn
->
pDb
==
NULL
)
return
TSDB_CODE_DB_NOT_SELECTED
;
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
if
(
pDb
==
NULL
)
return
TSDB_CODE_DB_NOT_SELECTED
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
...
@@ -1309,8 +1333,8 @@ int mgmtGetMetricMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
...
@@ -1309,8 +1333,8 @@ int mgmtGetMetricMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
pShow
->
offset
[
0
]
=
0
;
pShow
->
offset
[
0
]
=
0
;
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
pShow
->
numOfRows
=
p
Conn
->
p
Db
->
numOfMetrics
;
pShow
->
numOfRows
=
pDb
->
numOfMetrics
;
pShow
->
pNode
=
p
Conn
->
p
Db
->
pMetric
;
pShow
->
pNode
=
pDb
->
pMetric
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
return
0
;
return
0
;
...
...
src/system/detail/src/mgmtShell.c
浏览文件 @
f7e40d0e
...
@@ -189,8 +189,11 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
...
@@ -189,8 +189,11 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
int
size
=
sizeof
(
STaosHeader
)
+
sizeof
(
STaosRsp
)
+
sizeof
(
SMeterMeta
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
+
int
size
=
sizeof
(
STaosHeader
)
+
sizeof
(
STaosRsp
)
+
sizeof
(
SMeterMeta
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
+
sizeof
(
SSchema
)
*
TSDB_MAX_TAGS
+
TSDB_MAX_TAGS_LEN
+
TSDB_EXTRA_PAYLOAD_SIZE
;
sizeof
(
SSchema
)
*
TSDB_MAX_TAGS
+
TSDB_MAX_TAGS_LEN
+
TSDB_EXTRA_PAYLOAD_SIZE
;
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
// todo db check should be extracted
// todo db check should be extracted
if
(
p
Conn
->
pDb
==
NULL
||
(
pConn
->
pDb
!=
NULL
&&
pConn
->
pDb
->
dropStatus
!=
TSDB_DB_STATUS_READY
))
{
if
(
p
Db
==
NULL
||
(
pDb
!=
NULL
&&
pDb
->
dropStatus
!=
TSDB_DB_STATUS_READY
))
{
if
((
pStart
=
mgmtAllocMsg
(
pConn
,
size
,
&
pMsg
,
&
pRsp
))
==
NULL
)
{
if
((
pStart
=
mgmtAllocMsg
(
pConn
,
size
,
&
pMsg
,
&
pRsp
))
==
NULL
)
{
taosSendSimpleRsp
(
pConn
->
thandle
,
TSDB_MSG_TYPE_METERINFO_RSP
,
TSDB_CODE_SERV_OUT_OF_MEMORY
);
taosSendSimpleRsp
(
pConn
->
thandle
,
TSDB_MSG_TYPE_METERINFO_RSP
,
TSDB_CODE_SERV_OUT_OF_MEMORY
);
...
@@ -223,10 +226,10 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
...
@@ -223,10 +226,10 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
SDbObj
*
pMeterDb
=
mgmtGetDbByMeterId
(
pCreateMsg
->
meterId
);
SDbObj
*
pMeterDb
=
mgmtGetDbByMeterId
(
pCreateMsg
->
meterId
);
mTrace
(
"meter:%s, pConnDb:%p, pConnDbName:%s, pMeterDb:%p, pMeterDbName:%s"
,
mTrace
(
"meter:%s, pConnDb:%p, pConnDbName:%s, pMeterDb:%p, pMeterDbName:%s"
,
pCreateMsg
->
meterId
,
p
Conn
->
pDb
,
pConn
->
pDb
->
name
,
pMeterDb
,
pMeterDb
->
name
);
pCreateMsg
->
meterId
,
p
Db
,
pDb
->
name
,
pMeterDb
,
pMeterDb
->
name
);
assert
(
p
Conn
->
p
Db
==
pMeterDb
);
assert
(
pDb
==
pMeterDb
);
int32_t
code
=
mgmtCreateMeter
(
p
Conn
->
p
Db
,
pCreateMsg
);
int32_t
code
=
mgmtCreateMeter
(
pDb
,
pCreateMsg
);
char
stableName
[
TSDB_METER_ID_LEN
]
=
{
0
};
char
stableName
[
TSDB_METER_ID_LEN
]
=
{
0
};
strncpy
(
stableName
,
pInfo
->
tags
,
TSDB_METER_ID_LEN
);
strncpy
(
stableName
,
pInfo
->
tags
,
TSDB_METER_ID_LEN
);
...
@@ -256,7 +259,7 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
...
@@ -256,7 +259,7 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
}
}
if
(
pMeterObj
==
NULL
)
{
if
(
pMeterObj
==
NULL
)
{
if
(
p
Conn
->
p
Db
)
if
(
pDb
)
pRsp
->
code
=
TSDB_CODE_INVALID_TABLE
;
pRsp
->
code
=
TSDB_CODE_INVALID_TABLE
;
else
else
pRsp
->
code
=
TSDB_CODE_DB_NOT_SELECTED
;
pRsp
->
code
=
TSDB_CODE_DB_NOT_SELECTED
;
...
@@ -274,7 +277,7 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
...
@@ -274,7 +277,7 @@ int mgmtProcessMeterMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
pMeta
->
vgid
=
htonl
(
pMeterObj
->
gid
.
vgId
);
pMeta
->
vgid
=
htonl
(
pMeterObj
->
gid
.
vgId
);
pMeta
->
sversion
=
htons
(
pMeterObj
->
sversion
);
pMeta
->
sversion
=
htons
(
pMeterObj
->
sversion
);
pMeta
->
precision
=
p
Conn
->
p
Db
->
cfg
.
precision
;
pMeta
->
precision
=
pDb
->
cfg
.
precision
;
pMeta
->
numOfTags
=
pMeterObj
->
numOfTags
;
pMeta
->
numOfTags
=
pMeterObj
->
numOfTags
;
pMeta
->
numOfColumns
=
htons
(
pMeterObj
->
numOfColumns
);
pMeta
->
numOfColumns
=
htons
(
pMeterObj
->
numOfColumns
);
...
@@ -505,7 +508,10 @@ int mgmtProcessMetricMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
...
@@ -505,7 +508,10 @@ int mgmtProcessMetricMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
SMetricMetaElemMsg
*
pElem
=
(
SMetricMetaElemMsg
*
)(((
char
*
)
pMetricMetaMsg
)
+
pMetricMetaMsg
->
metaElem
[
0
]);
SMetricMetaElemMsg
*
pElem
=
(
SMetricMetaElemMsg
*
)(((
char
*
)
pMetricMetaMsg
)
+
pMetricMetaMsg
->
metaElem
[
0
]);
pMetric
=
mgmtGetMeter
(
pElem
->
meterId
);
pMetric
=
mgmtGetMeter
(
pElem
->
meterId
);
if
(
pMetric
==
NULL
||
(
pConn
->
pDb
!=
NULL
&&
pConn
->
pDb
->
dropStatus
!=
TSDB_DB_STATUS_READY
))
{
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
if
(
pMetric
==
NULL
||
(
pDb
!=
NULL
&&
pDb
->
dropStatus
!=
TSDB_DB_STATUS_READY
))
{
pStart
=
taosBuildRspMsg
(
pConn
->
thandle
,
TSDB_MSG_TYPE_METRIC_META_RSP
);
pStart
=
taosBuildRspMsg
(
pConn
->
thandle
,
TSDB_MSG_TYPE_METRIC_META_RSP
);
if
(
pStart
==
NULL
)
{
if
(
pStart
==
NULL
)
{
taosSendSimpleRsp
(
pConn
->
thandle
,
TSDB_MSG_TYPE_METRIC_META_RSP
,
TSDB_CODE_SERV_OUT_OF_MEMORY
);
taosSendSimpleRsp
(
pConn
->
thandle
,
TSDB_MSG_TYPE_METRIC_META_RSP
,
TSDB_CODE_SERV_OUT_OF_MEMORY
);
...
@@ -514,7 +520,7 @@ int mgmtProcessMetricMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
...
@@ -514,7 +520,7 @@ int mgmtProcessMetricMetaMsg(char *pMsg, int msgLen, SConnObj *pConn) {
pMsg
=
pStart
;
pMsg
=
pStart
;
pRsp
=
(
STaosRsp
*
)
pMsg
;
pRsp
=
(
STaosRsp
*
)
pMsg
;
if
(
p
Conn
->
p
Db
)
if
(
pDb
)
pRsp
->
code
=
TSDB_CODE_INVALID_TABLE
;
pRsp
->
code
=
TSDB_CODE_INVALID_TABLE
;
else
else
pRsp
->
code
=
TSDB_CODE_DB_NOT_SELECTED
;
pRsp
->
code
=
TSDB_CODE_DB_NOT_SELECTED
;
...
@@ -957,17 +963,23 @@ int mgmtProcessCreateTableMsg(char *pMsg, int msgLen, SConnObj *pConn) {
...
@@ -957,17 +963,23 @@ int mgmtProcessCreateTableMsg(char *pMsg, int msgLen, SConnObj *pConn) {
pSchema
++
;
pSchema
++
;
}
}
if
(
pConn
->
pDb
)
{
SDbObj
*
pDb
=
NULL
;
code
=
mgmtCreateMeter
(
pConn
->
pDb
,
pCreate
);
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
if
(
code
==
0
)
{
mTrace
(
"meter:%s is created by %s"
,
pCreate
->
meterId
,
pConn
->
pUser
->
user
);
if
(
pDb
)
{
// mLPrint("meter:%s is created by %s", pCreate->meterId, pConn->pUser->user);
code
=
mgmtCreateMeter
(
pDb
,
pCreate
);
}
}
else
{
}
else
{
code
=
TSDB_CODE_DB_NOT_SELECTED
;
code
=
TSDB_CODE_DB_NOT_SELECTED
;
}
}
}
}
if
(
code
!=
0
)
{
mError
(
"table:%s, failed to create table, code:%d"
,
pCreate
->
meterId
,
code
);
}
else
{
mTrace
(
"table:%s, table is created by %s"
,
pCreate
->
meterId
,
pConn
->
pUser
->
user
);
//mLPrint("meter:%s is created by %s", pCreate->meterId, pConn->pUser->user);
}
taosSendSimpleRsp
(
pConn
->
thandle
,
TSDB_MSG_TYPE_CREATE_TABLE_RSP
,
code
);
taosSendSimpleRsp
(
pConn
->
thandle
,
TSDB_MSG_TYPE_CREATE_TABLE_RSP
,
code
);
return
0
;
return
0
;
...
@@ -984,7 +996,10 @@ int mgmtProcessDropTableMsg(char *pMsg, int msgLen, SConnObj *pConn) {
...
@@ -984,7 +996,10 @@ int mgmtProcessDropTableMsg(char *pMsg, int msgLen, SConnObj *pConn) {
if
(
!
pConn
->
writeAuth
)
{
if
(
!
pConn
->
writeAuth
)
{
code
=
TSDB_CODE_NO_RIGHTS
;
code
=
TSDB_CODE_NO_RIGHTS
;
}
else
{
}
else
{
code
=
mgmtDropMeter
(
pConn
->
pDb
,
pDrop
->
meterId
,
pDrop
->
igNotExists
);
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
code
=
mgmtDropMeter
(
pDb
,
pDrop
->
meterId
,
pDrop
->
igNotExists
);
if
(
code
==
0
)
{
if
(
code
==
0
)
{
mTrace
(
"meter:%s is dropped by user:%s"
,
pDrop
->
meterId
,
pConn
->
pUser
->
user
);
mTrace
(
"meter:%s is dropped by user:%s"
,
pDrop
->
meterId
,
pConn
->
pUser
->
user
);
// mLPrint("meter:%s is dropped by user:%s", pDrop->meterId, pConn->pUser->user);
// mLPrint("meter:%s is dropped by user:%s", pDrop->meterId, pConn->pUser->user);
...
@@ -1014,12 +1029,15 @@ int mgmtProcessAlterTableMsg(char *pMsg, int msgLen, SConnObj *pConn) {
...
@@ -1014,12 +1029,15 @@ int mgmtProcessAlterTableMsg(char *pMsg, int msgLen, SConnObj *pConn) {
mError
(
"meter:%s error numOfCols:%d in alter table"
,
pAlter
->
meterId
,
pAlter
->
numOfCols
);
mError
(
"meter:%s error numOfCols:%d in alter table"
,
pAlter
->
meterId
,
pAlter
->
numOfCols
);
code
=
TSDB_CODE_APP_ERROR
;
code
=
TSDB_CODE_APP_ERROR
;
}
else
{
}
else
{
if
(
pConn
->
pDb
)
{
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
if
(
pDb
)
{
for
(
int32_t
i
=
0
;
i
<
pAlter
->
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pAlter
->
numOfCols
;
++
i
)
{
pAlter
->
schema
[
i
].
bytes
=
htons
(
pAlter
->
schema
[
i
].
bytes
);
pAlter
->
schema
[
i
].
bytes
=
htons
(
pAlter
->
schema
[
i
].
bytes
);
}
}
code
=
mgmtAlterMeter
(
p
Conn
->
p
Db
,
pAlter
);
code
=
mgmtAlterMeter
(
pDb
,
pAlter
);
if
(
code
==
0
)
{
if
(
code
==
0
)
{
mLPrint
(
"meter:%s is altered by %s"
,
pAlter
->
meterId
,
pConn
->
pUser
->
user
);
mLPrint
(
"meter:%s is altered by %s"
,
pAlter
->
meterId
,
pConn
->
pUser
->
user
);
}
}
...
@@ -1263,8 +1281,7 @@ void *mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle) {
...
@@ -1263,8 +1281,7 @@ void *mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle) {
}
}
if
(
pConn
->
pAcct
)
{
if
(
pConn
->
pAcct
)
{
if
(
pConn
->
pDb
==
NULL
||
if
(
pConn
->
pDb
==
NULL
||
strncmp
(
pConn
->
pDb
->
name
,
pHead
->
db
,
tListLen
(
pConn
->
pDb
->
name
))
!=
0
)
{
strncmp
(
pConn
->
pDb
->
name
,
pHead
->
db
,
tListLen
(
pConn
->
pDb
->
name
))
!=
0
)
{
pConn
->
pDb
=
mgmtGetDb
(
pHead
->
db
);
pConn
->
pDb
=
mgmtGetDb
(
pHead
->
db
);
}
}
...
...
src/system/detail/src/mgmtVgroup.c
浏览文件 @
f7e40d0e
...
@@ -123,7 +123,7 @@ void mgmtProcessVgTimer(void *handle, void *tmrId) {
...
@@ -123,7 +123,7 @@ void mgmtProcessVgTimer(void *handle, void *tmrId) {
if
(
pDb
==
NULL
)
return
;
if
(
pDb
==
NULL
)
return
;
if
(
pDb
->
vgStatus
>
TSDB_VG_STATUS_IN_PROGRESS
)
{
if
(
pDb
->
vgStatus
>
TSDB_VG_STATUS_IN_PROGRESS
)
{
mTrace
(
"db:%s, set vg
status from %d to %d"
,
pDb
->
name
,
pDb
->
vgStatus
,
TSDB_VG_STATUS_READY
);
mTrace
(
"db:%s, set vg
roup status from %d to ready"
,
pDb
->
name
,
pDb
->
vgStatus
);
pDb
->
vgStatus
=
TSDB_VG_STATUS_READY
;
pDb
->
vgStatus
=
TSDB_VG_STATUS_READY
;
}
}
...
@@ -143,7 +143,7 @@ SVgObj *mgmtCreateVgroup(SDbObj *pDb) {
...
@@ -143,7 +143,7 @@ SVgObj *mgmtCreateVgroup(SDbObj *pDb) {
// based on load balance, create a new one
// based on load balance, create a new one
if
(
mgmtAllocVnodes
(
pVgroup
)
!=
0
)
{
if
(
mgmtAllocVnodes
(
pVgroup
)
!=
0
)
{
mError
(
"
no enough free dnode"
);
mError
(
"
db:%s, no enough free dnode to alloc %d vnodes"
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
free
(
pVgroup
);
free
(
pVgroup
);
pDb
->
vgStatus
=
TSDB_VG_STATUS_FULL
;
pDb
->
vgStatus
=
TSDB_VG_STATUS_FULL
;
taosTmrReset
(
mgmtProcessVgTimer
,
5000
,
pDb
,
mgmtTmr
,
&
pDb
->
vgTimer
);
taosTmrReset
(
mgmtProcessVgTimer
,
5000
,
pDb
,
mgmtTmr
,
&
pDb
->
vgTimer
);
...
@@ -152,9 +152,9 @@ SVgObj *mgmtCreateVgroup(SDbObj *pDb) {
...
@@ -152,9 +152,9 @@ SVgObj *mgmtCreateVgroup(SDbObj *pDb) {
sdbInsertRow
(
vgSdb
,
pVgroup
,
0
);
sdbInsertRow
(
vgSdb
,
pVgroup
,
0
);
mTrace
(
"vgroup:%d,
db:%s replica:%d is create
d"
,
pVgroup
->
vgId
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
mTrace
(
"vgroup:%d,
vgroup is created, db:%s replica:%
d"
,
pVgroup
->
vgId
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
for
(
int
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
for
(
int
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
mTrace
(
"
dnode:%s, vgroup:%d, vnode:%d is created"
,
taosIpStr
(
pVgroup
->
vnodeGid
[
i
].
ip
),
pVgroup
->
vgId
,
pVgroup
->
vnodeGid
[
i
].
vnode
);
mTrace
(
"
vgroup:%d, dnode:%s vnode:%d is created"
,
pVgroup
->
vgId
,
taosIpStr
(
pVgroup
->
vnodeGid
[
i
].
ip
)
,
pVgroup
->
vnodeGid
[
i
].
vnode
);
mgmtSendVPeersMsg
(
pVgroup
);
mgmtSendVPeersMsg
(
pVgroup
);
...
@@ -206,7 +206,10 @@ void mgmtCleanUpVgroups() { sdbCloseTable(vgSdb); }
...
@@ -206,7 +206,10 @@ void mgmtCleanUpVgroups() { sdbCloseTable(vgSdb); }
int
mgmtGetVgroupMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
mgmtGetVgroupMeta
(
SMeterMeta
*
pMeta
,
SShowObj
*
pShow
,
SConnObj
*
pConn
)
{
int
cols
=
0
;
int
cols
=
0
;
if
(
pConn
->
pDb
==
NULL
)
return
TSDB_CODE_DB_NOT_SELECTED
;
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
if
(
pDb
==
NULL
)
return
TSDB_CODE_DB_NOT_SELECTED
;
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
SSchema
*
pSchema
=
tsGetSchema
(
pMeta
);
...
@@ -229,7 +232,7 @@ int mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
...
@@ -229,7 +232,7 @@ int mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
cols
++
;
cols
++
;
int
maxReplica
=
0
;
int
maxReplica
=
0
;
SVgObj
*
pVgroup
=
p
Conn
->
p
Db
->
pHead
;
SVgObj
*
pVgroup
=
pDb
->
pHead
;
while
(
pVgroup
!=
NULL
)
{
while
(
pVgroup
!=
NULL
)
{
maxReplica
=
pVgroup
->
numOfVnodes
>
maxReplica
?
pVgroup
->
numOfVnodes
:
maxReplica
;
maxReplica
=
pVgroup
->
numOfVnodes
>
maxReplica
?
pVgroup
->
numOfVnodes
:
maxReplica
;
pVgroup
=
pVgroup
->
next
;
pVgroup
=
pVgroup
->
next
;
...
@@ -267,8 +270,8 @@ int mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
...
@@ -267,8 +270,8 @@ int mgmtGetVgroupMeta(SMeterMeta *pMeta, SShowObj *pShow, SConnObj *pConn) {
pShow
->
offset
[
0
]
=
0
;
pShow
->
offset
[
0
]
=
0
;
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
for
(
int
i
=
1
;
i
<
cols
;
++
i
)
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
pShow
->
numOfRows
=
p
Conn
->
p
Db
->
numOfVgroups
;
pShow
->
numOfRows
=
pDb
->
numOfVgroups
;
pShow
->
pNode
=
p
Conn
->
p
Db
->
pHead
;
pShow
->
pNode
=
pDb
->
pHead
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
return
0
;
return
0
;
...
@@ -282,7 +285,11 @@ int mgmtRetrieveVgroups(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
...
@@ -282,7 +285,11 @@ int mgmtRetrieveVgroups(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
char
ipstr
[
20
];
char
ipstr
[
20
];
int
maxReplica
=
0
;
int
maxReplica
=
0
;
pVgroup
=
pConn
->
pDb
->
pHead
;
SDbObj
*
pDb
=
NULL
;
if
(
pConn
->
pDb
!=
NULL
)
pDb
=
mgmtGetDb
(
pConn
->
pDb
->
name
);
pVgroup
=
pDb
->
pHead
;
while
(
pVgroup
!=
NULL
)
{
while
(
pVgroup
!=
NULL
)
{
maxReplica
=
pVgroup
->
numOfVnodes
>
maxReplica
?
pVgroup
->
numOfVnodes
:
maxReplica
;
maxReplica
=
pVgroup
->
numOfVnodes
>
maxReplica
?
pVgroup
->
numOfVnodes
:
maxReplica
;
pVgroup
=
pVgroup
->
next
;
pVgroup
=
pVgroup
->
next
;
...
...
src/system/detail/src/vnodeCache.c
浏览文件 @
f7e40d0e
...
@@ -297,7 +297,7 @@ pthread_t vnodeCreateCommitThread(SVnodeObj *pVnode) {
...
@@ -297,7 +297,7 @@ pthread_t vnodeCreateCommitThread(SVnodeObj *pVnode) {
taosTmrStopA
(
&
pVnode
->
commitTimer
);
taosTmrStopA
(
&
pVnode
->
commitTimer
);
if
(
pVnode
->
status
==
TSDB
_STATUS_UNSYNCED
)
{
if
(
pVnode
->
vnodeStatus
==
TSDB_VNODE
_STATUS_UNSYNCED
)
{
taosTmrReset
(
vnodeProcessCommitTimer
,
pVnode
->
cfg
.
commitTime
*
1000
,
pVnode
,
vnodeTmrCtrl
,
&
pVnode
->
commitTimer
);
taosTmrReset
(
vnodeProcessCommitTimer
,
pVnode
->
cfg
.
commitTime
*
1000
,
pVnode
,
vnodeTmrCtrl
,
&
pVnode
->
commitTimer
);
dTrace
(
"vid:%d, it is in unsyc state, commit later"
,
pVnode
->
vnode
);
dTrace
(
"vid:%d, it is in unsyc state, commit later"
,
pVnode
->
vnode
);
return
pVnode
->
commitThread
;
return
pVnode
->
commitThread
;
...
...
src/system/detail/src/vnodeFile.c
浏览文件 @
f7e40d0e
...
@@ -1290,7 +1290,7 @@ int vnodeWriteBlockToFile(SMeterObj *pObj, SCompBlock *pCompBlock, SData *data[]
...
@@ -1290,7 +1290,7 @@ int vnodeWriteBlockToFile(SMeterObj *pObj, SCompBlock *pCompBlock, SData *data[]
pCompBlock
->
len
+=
wlen
;
pCompBlock
->
len
+=
wlen
;
}
}
dTrace
(
"vid:
%d
vnode compStorage size is: %ld"
,
pObj
->
vnode
,
pVnode
->
vnodeStatistic
.
compStorage
);
dTrace
(
"vid:
%d,
vnode compStorage size is: %ld"
,
pObj
->
vnode
,
pVnode
->
vnodeStatistic
.
compStorage
);
pCompBlock
->
algorithm
=
pCfg
->
compression
;
pCompBlock
->
algorithm
=
pCfg
->
compression
;
pCompBlock
->
numOfPoints
=
points
;
pCompBlock
->
numOfPoints
=
points
;
...
...
src/system/detail/src/vnodeShell.c
浏览文件 @
f7e40d0e
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "vnode.h"
#include "vnode.h"
#include "vnodeRead.h"
#include "vnodeRead.h"
#include "vnodeUtil.h"
#include "vnodeUtil.h"
#include "vnodeStore.h"
#pragma GCC diagnostic ignored "-Wint-conversion"
#pragma GCC diagnostic ignored "-Wint-conversion"
extern
int
tsMaxQueues
;
extern
int
tsMaxQueues
;
...
@@ -89,9 +90,9 @@ void *vnodeProcessMsgFromShell(char *msg, void *ahandle, void *thandle) {
...
@@ -89,9 +90,9 @@ void *vnodeProcessMsgFromShell(char *msg, void *ahandle, void *thandle) {
// if ( vnodeList[vnode].status != TSDB_STATUS_MASTER && pMsg->msgType != TSDB_MSG_TYPE_RETRIEVE ) {
// if ( vnodeList[vnode].status != TSDB_STATUS_MASTER && pMsg->msgType != TSDB_MSG_TYPE_RETRIEVE ) {
#ifdef CLUSTER
#ifdef CLUSTER
if
(
vnodeList
[
vnode
].
status
!=
TSDB
_STATUS_MASTER
)
{
if
(
vnodeList
[
vnode
].
vnodeStatus
!=
TSDB_VNODE
_STATUS_MASTER
)
{
taosSendSimpleRsp
(
thandle
,
pMsg
->
msgType
+
1
,
TSDB_CODE_NOT_READY
);
taosSendSimpleRsp
(
thandle
,
pMsg
->
msgType
+
1
,
TSDB_CODE_NOT_READY
);
dTrace
(
"vid:%d sid:%d, shell msg is ignored since in state:%d"
,
vnode
,
sid
,
vnodeList
[
vnode
].
s
tatus
);
dTrace
(
"vid:%d sid:%d, shell msg is ignored since in state:%d"
,
vnode
,
sid
,
vnodeList
[
vnode
].
vnodeS
tatus
);
}
else
{
}
else
{
#endif
#endif
dTrace
(
"vid:%d sid:%d, msg:%s is received pConn:%p"
,
vnode
,
sid
,
taosMsg
[
pMsg
->
msgType
],
thandle
);
dTrace
(
"vid:%d sid:%d, msg:%s is received pConn:%p"
,
vnode
,
sid
,
taosMsg
[
pMsg
->
msgType
],
thandle
);
...
@@ -154,6 +155,11 @@ int vnodeInitShell() {
...
@@ -154,6 +155,11 @@ int vnodeInitShell() {
}
}
int
vnodeOpenShellVnode
(
int
vnode
)
{
int
vnodeOpenShellVnode
(
int
vnode
)
{
if
(
shellList
[
vnode
]
!=
NULL
)
{
dError
(
"vid:%d, shell is already opened"
,
vnode
);
return
-
1
;
}
const
int32_t
MIN_NUM_OF_SESSIONS
=
300
;
const
int32_t
MIN_NUM_OF_SESSIONS
=
300
;
SVnodeCfg
*
pCfg
=
&
vnodeList
[
vnode
].
cfg
;
SVnodeCfg
*
pCfg
=
&
vnodeList
[
vnode
].
cfg
;
...
@@ -162,23 +168,29 @@ int vnodeOpenShellVnode(int vnode) {
...
@@ -162,23 +168,29 @@ int vnodeOpenShellVnode(int vnode) {
size_t
size
=
sessions
*
sizeof
(
SShellObj
);
size_t
size
=
sessions
*
sizeof
(
SShellObj
);
shellList
[
vnode
]
=
(
SShellObj
*
)
calloc
(
1
,
size
);
shellList
[
vnode
]
=
(
SShellObj
*
)
calloc
(
1
,
size
);
if
(
shellList
[
vnode
]
==
NULL
)
{
if
(
shellList
[
vnode
]
==
NULL
)
{
dError
(
"vid:%d
failed to allocate shellObj, size:%d"
,
vnode
,
size
);
dError
(
"vid:%d
, sessions:%d, failed to allocate shellObj, size:%d"
,
vnode
,
pCfg
->
maxSessions
,
size
);
return
-
1
;
return
-
1
;
}
}
if
(
taosOpenRpcChannWithQ
(
pShellServer
,
vnode
,
sessions
,
rpcQhandle
[(
vnode
+
1
)
%
tsMaxQueues
])
!=
TSDB_CODE_SUCCESS
)
{
if
(
taosOpenRpcChannWithQ
(
pShellServer
,
vnode
,
sessions
,
rpcQhandle
[(
vnode
+
1
)
%
tsMaxQueues
])
!=
TSDB_CODE_SUCCESS
)
{
dError
(
"vid:%d, sessions:%d, failed to open shell"
,
vnode
,
pCfg
->
maxSessions
);
return
-
1
;
return
-
1
;
}
}
dTrace
(
"vid:%d, sessions:%d, shell is opened"
,
vnode
,
pCfg
->
maxSessions
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
vnodeDelayedFreeResource
(
void
*
param
,
void
*
tmrId
)
{
static
void
vnodeDelayedFreeResource
(
void
*
param
,
void
*
tmrId
)
{
int32_t
vnode
=
*
(
int32_t
*
)
param
;
int32_t
vnode
=
*
(
int32_t
*
)
param
;
taosCloseRpcChann
(
pShellServer
,
vnode
);
// close connection
dTrace
(
"vid:%d, start to free resources"
,
vnode
);
tfree
(
shellList
[
vnode
]);
//free SShellObj
taosCloseRpcChann
(
pShellServer
,
vnode
);
// close connection
tfree
(
shellList
[
vnode
]);
//free SShellObj
tfree
(
param
);
tfree
(
param
);
memset
(
vnodeList
+
vnode
,
0
,
sizeof
(
SVnodeObj
));
vnodeCalcOpenVnodes
();
}
}
void
vnodeCloseShellVnode
(
int
vnode
)
{
void
vnodeCloseShellVnode
(
int
vnode
)
{
...
...
src/system/detail/src/vnodeStore.c
浏览文件 @
f7e40d0e
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "vnode.h"
#include "vnode.h"
#include "vnodeStore.h"
#include "vnodeStore.h"
#include "vnodeUtil.h"
#include "vnodeUtil.h"
#include "tstatus.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic push
#pragma GCC diagnostic warning "-Woverflow"
#pragma GCC diagnostic warning "-Woverflow"
...
@@ -30,12 +31,14 @@ int tsMaxVnode = -1;
...
@@ -30,12 +31,14 @@ int tsMaxVnode = -1;
int
tsOpenVnodes
=
0
;
int
tsOpenVnodes
=
0
;
SVnodeObj
*
vnodeList
=
NULL
;
SVnodeObj
*
vnodeList
=
NULL
;
int
vnodeInitStoreVnode
(
int
vnode
)
{
static
int
vnodeInitStoreVnode
(
int
vnode
)
{
SVnodeObj
*
pVnode
=
vnodeList
+
vnode
;
SVnodeObj
*
pVnode
=
vnodeList
+
vnode
;
pVnode
->
vnode
=
vnode
;
pVnode
->
vnode
=
vnode
;
vnodeOpenMetersVnode
(
vnode
);
vnodeOpenMetersVnode
(
vnode
);
if
(
pVnode
->
cfg
.
maxSessions
==
0
)
return
0
;
if
(
pVnode
->
cfg
.
maxSessions
<=
0
)
{
return
TSDB_CODE_SUCCESS
;
}
pVnode
->
firstKey
=
taosGetTimestamp
(
pVnode
->
cfg
.
precision
);
pVnode
->
firstKey
=
taosGetTimestamp
(
pVnode
->
cfg
.
precision
);
...
@@ -45,9 +48,10 @@ int vnodeInitStoreVnode(int vnode) {
...
@@ -45,9 +48,10 @@ int vnodeInitStoreVnode(int vnode) {
return
-
1
;
return
-
1
;
}
}
if
(
vnodeInitFile
(
vnode
)
<
0
)
return
-
1
;
if
(
vnodeInitFile
(
vnode
)
<
0
)
{
dError
(
"vid:%d, files init failed."
,
pVnode
->
vnode
);
// vnodeOpenMeterMgmtStoreVnode(vnode);
return
-
1
;
}
if
(
vnodeInitCommit
(
vnode
)
<
0
)
{
if
(
vnodeInitCommit
(
vnode
)
<
0
)
{
dError
(
"vid:%d, commit init failed."
,
pVnode
->
vnode
);
dError
(
"vid:%d, commit init failed."
,
pVnode
->
vnode
);
...
@@ -70,10 +74,17 @@ int vnodeOpenVnode(int vnode) {
...
@@ -70,10 +74,17 @@ int vnodeOpenVnode(int vnode) {
pVnode
->
accessState
=
TSDB_VN_ALL_ACCCESS
;
pVnode
->
accessState
=
TSDB_VN_ALL_ACCCESS
;
// vnode is empty
// vnode is empty
if
(
pVnode
->
cfg
.
maxSessions
==
0
)
return
0
;
if
(
pVnode
->
cfg
.
maxSessions
<=
0
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
!
(
pVnode
->
vnodeStatus
==
TSDB_VNODE_STATUS_OFFLINE
||
pVnode
->
vnodeStatus
==
TSDB_VNODE_STATUS_CREATING
))
{
dError
(
"vid:%d, status:%s, cannot enter open operation"
,
vnode
,
taosGetVnodeStatusStr
(
pVnode
->
vnodeStatus
));
return
TSDB_CODE_INVALID_VNODE_STATUS
;
}
dTrace
(
"vid:%d, status:%s, start to open"
,
vnode
,
taosGetVnodeStatusStr
(
pVnode
->
vnodeStatus
));
pthread_mutex_lock
(
&
dmutex
);
pthread_mutex_lock
(
&
dmutex
);
// vnodeOpenMeterMgmtVnode(vnode);
// not enough memory, abort
// not enough memory, abort
if
((
code
=
vnodeOpenShellVnode
(
vnode
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
vnodeOpenShellVnode
(
vnode
))
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -93,14 +104,13 @@ int vnodeOpenVnode(int vnode) {
...
@@ -93,14 +104,13 @@ int vnodeOpenVnode(int vnode) {
vnodeOpenStreams
(
pVnode
,
NULL
);
vnodeOpenStreams
(
pVnode
,
NULL
);
#endif
#endif
dTrace
(
"vid:%d, vnode is opened, openVnodes:%d
"
,
vnode
,
tsOpenVnodes
);
dTrace
(
"vid:%d, vnode is opened, openVnodes:%d
, status:%s"
,
vnode
,
tsOpenVnodes
,
taosGetVnodeStatusStr
(
pVnode
->
vnodeStatus
)
);
return
0
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
vnodeMarkAllMetersDropped
(
SVnodeObj
*
pVnode
)
{
static
int32_t
vnodeMarkAllMetersDropped
(
SVnodeObj
*
pVnode
)
{
if
(
pVnode
->
meterList
==
NULL
)
{
if
(
pVnode
->
meterList
==
NULL
)
{
assert
(
pVnode
->
cfg
.
maxSessions
==
0
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -119,7 +129,7 @@ static int32_t vnodeMarkAllMetersDropped(SVnodeObj* pVnode) {
...
@@ -119,7 +129,7 @@ static int32_t vnodeMarkAllMetersDropped(SVnodeObj* pVnode) {
return
ready
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_ACTION_IN_PROGRESS
;
return
ready
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_ACTION_IN_PROGRESS
;
}
}
int
vnodeCloseVnode
(
int
vnode
)
{
static
int
vnodeCloseVnode
(
int
vnode
)
{
if
(
vnodeList
==
NULL
)
return
TSDB_CODE_SUCCESS
;
if
(
vnodeList
==
NULL
)
return
TSDB_CODE_SUCCESS
;
SVnodeObj
*
pVnode
=
&
vnodeList
[
vnode
];
SVnodeObj
*
pVnode
=
&
vnodeList
[
vnode
];
...
@@ -130,12 +140,23 @@ int vnodeCloseVnode(int vnode) {
...
@@ -130,12 +140,23 @@ int vnodeCloseVnode(int vnode) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
pVnode
->
vnodeStatus
==
TSDB_VNODE_STATUS_DELETING
)
{
dTrace
(
"vid:%d, status:%s, another thread performed delete operation"
,
vnode
,
taosGetVnodeStatusStr
(
pVnode
->
vnodeStatus
));
return
TSDB_CODE_SUCCESS
;
}
else
{
dTrace
(
"vid:%d, status:%s, enter close operation"
,
vnode
,
taosGetVnodeStatusStr
(
pVnode
->
vnodeStatus
));
pVnode
->
vnodeStatus
=
TSDB_VNODE_STATUS_CLOSING
;
}
// set the meter is dropped flag
// set the meter is dropped flag
if
(
vnodeMarkAllMetersDropped
(
pVnode
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
vnodeMarkAllMetersDropped
(
pVnode
)
!=
TSDB_CODE_SUCCESS
)
{
pthread_mutex_unlock
(
&
dmutex
);
pthread_mutex_unlock
(
&
dmutex
);
return
TSDB_CODE_ACTION_IN_PROGRESS
;
return
TSDB_CODE_ACTION_IN_PROGRESS
;
}
}
dTrace
(
"vid:%d, status:%s, enter delete operation"
,
vnode
,
taosGetVnodeStatusStr
(
pVnode
->
vnodeStatus
));
pVnode
->
vnodeStatus
=
TSDB_VNODE_STATUS_DELETING
;
vnodeCloseStream
(
vnodeList
+
vnode
);
vnodeCloseStream
(
vnodeList
+
vnode
);
vnodeCancelCommit
(
vnodeList
+
vnode
);
vnodeCancelCommit
(
vnodeList
+
vnode
);
vnodeClosePeerVnode
(
vnode
);
vnodeClosePeerVnode
(
vnode
);
...
@@ -149,9 +170,6 @@ int vnodeCloseVnode(int vnode) {
...
@@ -149,9 +170,6 @@ int vnodeCloseVnode(int vnode) {
if
(
tsMaxVnode
==
vnode
)
tsMaxVnode
=
vnode
-
1
;
if
(
tsMaxVnode
==
vnode
)
tsMaxVnode
=
vnode
-
1
;
tfree
(
vnodeList
[
vnode
].
meterIndex
);
tfree
(
vnodeList
[
vnode
].
meterIndex
);
memset
(
vnodeList
+
vnode
,
0
,
sizeof
(
SVnodeObj
));
vnodeCalcOpenVnodes
();
pthread_mutex_unlock
(
&
dmutex
);
pthread_mutex_unlock
(
&
dmutex
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -160,7 +178,12 @@ int vnodeCloseVnode(int vnode) {
...
@@ -160,7 +178,12 @@ int vnodeCloseVnode(int vnode) {
int
vnodeCreateVnode
(
int
vnode
,
SVnodeCfg
*
pCfg
,
SVPeerDesc
*
pDesc
)
{
int
vnodeCreateVnode
(
int
vnode
,
SVnodeCfg
*
pCfg
,
SVPeerDesc
*
pDesc
)
{
char
fileName
[
128
];
char
fileName
[
128
];
vnodeList
[
vnode
].
status
=
TSDB_STATUS_CREATING
;
if
(
vnodeList
[
vnode
].
vnodeStatus
!=
TSDB_VNODE_STATUS_OFFLINE
)
{
dError
(
"vid:%d, status:%s, cannot enter create operation"
,
vnode
,
taosGetVnodeStatusStr
(
vnodeList
[
vnode
].
vnodeStatus
));
return
TSDB_CODE_INVALID_VNODE_STATUS
;
}
vnodeList
[
vnode
].
vnodeStatus
=
TSDB_VNODE_STATUS_CREATING
;
sprintf
(
fileName
,
"%s/vnode%d"
,
tsDirectory
,
vnode
);
sprintf
(
fileName
,
"%s/vnode%d"
,
tsDirectory
,
vnode
);
mkdir
(
fileName
,
0755
);
mkdir
(
fileName
,
0755
);
...
@@ -177,14 +200,14 @@ int vnodeCreateVnode(int vnode, SVnodeCfg *pCfg, SVPeerDesc *pDesc) {
...
@@ -177,14 +200,14 @@ int vnodeCreateVnode(int vnode, SVnodeCfg *pCfg, SVPeerDesc *pDesc) {
return
TSDB_CODE_VG_INIT_FAILED
;
return
TSDB_CODE_VG_INIT_FAILED
;
}
}
if
(
vnodeInitStoreVnode
(
vnode
)
!=
0
)
{
if
(
vnodeInitStoreVnode
(
vnode
)
<
0
)
{
return
TSDB_CODE_VG_COMMITLOG_INIT_FAILED
;
return
TSDB_CODE_VG_COMMITLOG_INIT_FAILED
;
}
}
return
vnodeOpenVnode
(
vnode
);
return
vnodeOpenVnode
(
vnode
);
}
}
void
vnodeRemoveDataFiles
(
int
vnode
)
{
static
void
vnodeRemoveDataFiles
(
int
vnode
)
{
char
vnodeDir
[
TSDB_FILENAME_LEN
];
char
vnodeDir
[
TSDB_FILENAME_LEN
];
char
dfilePath
[
TSDB_FILENAME_LEN
];
char
dfilePath
[
TSDB_FILENAME_LEN
];
char
linkFile
[
TSDB_FILENAME_LEN
];
char
linkFile
[
TSDB_FILENAME_LEN
];
...
@@ -227,19 +250,28 @@ void vnodeRemoveDataFiles(int vnode) {
...
@@ -227,19 +250,28 @@ void vnodeRemoveDataFiles(int vnode) {
sprintf
(
vnodeDir
,
"%s/vnode%d"
,
tsDirectory
,
vnode
);
sprintf
(
vnodeDir
,
"%s/vnode%d"
,
tsDirectory
,
vnode
);
rmdir
(
vnodeDir
);
rmdir
(
vnodeDir
);
dTrace
(
"v
node %d
is removed!"
,
vnode
);
dTrace
(
"v
id:%d, vnode
is removed!"
,
vnode
);
}
}
int
vnodeRemoveVnode
(
int
vnode
)
{
int
vnodeRemoveVnode
(
int
vnode
)
{
if
(
vnodeList
==
NULL
)
return
TSDB_CODE_SUCCESS
;
if
(
vnodeList
==
NULL
)
return
TSDB_CODE_SUCCESS
;
if
(
vnodeList
[
vnode
].
cfg
.
maxSessions
>
0
)
{
if
(
vnodeList
[
vnode
].
cfg
.
maxSessions
>
0
)
{
int32_t
ret
=
vnodeCloseVnode
(
vnode
);
SVnodeObj
*
pVnode
=
&
vnodeList
[
vnode
];
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
pVnode
->
vnodeStatus
==
TSDB_VNODE_STATUS_CREATING
return
ret
;
||
pVnode
->
vnodeStatus
==
TSDB_VNODE_STATUS_OFFLINE
||
pVnode
->
vnodeStatus
==
TSDB_VNODE_STATUS_DELETING
)
{
dError
(
"vid:%d, status:%s, cannot enter close/delete operation"
,
vnode
,
taosGetVnodeStatusStr
(
pVnode
->
vnodeStatus
));
return
TSDB_CODE_ACTION_IN_PROGRESS
;
}
else
{
int32_t
ret
=
vnodeCloseVnode
(
vnode
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
vnodeRemoveDataFiles
(
vnode
);
}
}
vnodeRemoveDataFiles
(
vnode
);
}
else
{
}
else
{
dTrace
(
"vid:%d, max sessions:%d, this vnode already dropped!!!"
,
vnode
,
vnodeList
[
vnode
].
cfg
.
maxSessions
);
dTrace
(
"vid:%d, max sessions:%d, this vnode already dropped!!!"
,
vnode
,
vnodeList
[
vnode
].
cfg
.
maxSessions
);
vnodeList
[
vnode
].
cfg
.
maxSessions
=
0
;
//reset value
vnodeList
[
vnode
].
cfg
.
maxSessions
=
0
;
//reset value
...
@@ -293,7 +325,7 @@ void vnodeCleanUpOneVnode(int vnode) {
...
@@ -293,7 +325,7 @@ void vnodeCleanUpOneVnode(int vnode) {
again
=
1
;
again
=
1
;
if
(
vnodeList
[
vnode
].
pCachePool
)
{
if
(
vnodeList
[
vnode
].
pCachePool
)
{
vnodeList
[
vnode
].
status
=
TSDB
_STATUS_OFFLINE
;
vnodeList
[
vnode
].
vnodeStatus
=
TSDB_VNODE
_STATUS_OFFLINE
;
vnodeClosePeerVnode
(
vnode
);
vnodeClosePeerVnode
(
vnode
);
}
}
...
@@ -322,7 +354,7 @@ void vnodeCleanUpVnodes() {
...
@@ -322,7 +354,7 @@ void vnodeCleanUpVnodes() {
for
(
int
vnode
=
0
;
vnode
<
TSDB_MAX_VNODES
;
++
vnode
)
{
for
(
int
vnode
=
0
;
vnode
<
TSDB_MAX_VNODES
;
++
vnode
)
{
if
(
vnodeList
[
vnode
].
pCachePool
)
{
if
(
vnodeList
[
vnode
].
pCachePool
)
{
vnodeList
[
vnode
].
status
=
TSDB
_STATUS_OFFLINE
;
vnodeList
[
vnode
].
vnodeStatus
=
TSDB_VNODE
_STATUS_OFFLINE
;
vnodeClosePeerVnode
(
vnode
);
vnodeClosePeerVnode
(
vnode
);
}
}
}
}
...
...
src/system/detail/src/vnodeStream.c
浏览文件 @
f7e40d0e
...
@@ -171,7 +171,7 @@ void vnodeCloseStream(SVnodeObj *pVnode) {
...
@@ -171,7 +171,7 @@ void vnodeCloseStream(SVnodeObj *pVnode) {
void
vnodeUpdateStreamRole
(
SVnodeObj
*
pVnode
)
{
void
vnodeUpdateStreamRole
(
SVnodeObj
*
pVnode
)
{
/* SMeterObj *pObj; */
/* SMeterObj *pObj; */
int
newRole
=
(
pVnode
->
status
==
TSDB
_STATUS_MASTER
)
?
1
:
0
;
int
newRole
=
(
pVnode
->
vnodeStatus
==
TSDB_VNODE
_STATUS_MASTER
)
?
1
:
0
;
if
(
newRole
!=
pVnode
->
streamRole
)
{
if
(
newRole
!=
pVnode
->
streamRole
)
{
dTrace
(
"vid:%d, stream role is changed to:%d"
,
pVnode
->
vnode
,
newRole
);
dTrace
(
"vid:%d, stream role is changed to:%d"
,
pVnode
->
vnode
,
newRole
);
pVnode
->
streamRole
=
newRole
;
pVnode
->
streamRole
=
newRole
;
...
...
src/system/lite/src/dnodeMgmt.spec.c
浏览文件 @
f7e40d0e
...
@@ -50,7 +50,7 @@ char *taosBuildReqMsgToMnode(SMgmtObj *pObj, char type) {
...
@@ -50,7 +50,7 @@ char *taosBuildReqMsgToMnode(SMgmtObj *pObj, char type) {
}
}
int
taosSendMsgToMnode
(
SMgmtObj
*
pObj
,
char
*
msg
,
int
msgLen
)
{
int
taosSendMsgToMnode
(
SMgmtObj
*
pObj
,
char
*
msg
,
int
msgLen
)
{
m
Trace
(
"msg:%s is sent to mnode"
,
taosMsg
[
*
(
msg
-
1
)]);
d
Trace
(
"msg:%s is sent to mnode"
,
taosMsg
[
*
(
msg
-
1
)]);
/*
/*
* Lite version has no message header, so minus one
* Lite version has no message header, so minus one
...
...
src/system/lite/src/mgmtDnode.spec.c
浏览文件 @
f7e40d0e
...
@@ -30,7 +30,7 @@ int mgmtInitDnodes() {
...
@@ -30,7 +30,7 @@ int mgmtInitDnodes() {
dnodeObj
.
createdTime
=
(
int64_t
)
tsRebootTime
*
1000
;
dnodeObj
.
createdTime
=
(
int64_t
)
tsRebootTime
*
1000
;
dnodeObj
.
lastReboot
=
tsRebootTime
;
dnodeObj
.
lastReboot
=
tsRebootTime
;
dnodeObj
.
numOfCores
=
(
uint16_t
)
tsNumOfCores
;
dnodeObj
.
numOfCores
=
(
uint16_t
)
tsNumOfCores
;
dnodeObj
.
status
=
TSDB_STATUS_READY
;
dnodeObj
.
status
=
TSDB_
DNODE_
STATUS_READY
;
dnodeObj
.
alternativeRole
=
TSDB_DNODE_ROLE_ANY
;
dnodeObj
.
alternativeRole
=
TSDB_DNODE_ROLE_ANY
;
dnodeObj
.
numOfTotalVnodes
=
tsNumOfTotalVnodes
;
dnodeObj
.
numOfTotalVnodes
=
tsNumOfTotalVnodes
;
dnodeObj
.
thandle
=
(
void
*
)(
1
);
//hack way
dnodeObj
.
thandle
=
(
void
*
)(
1
);
//hack way
...
...
src/system/lite/src/mgmtDnodeInt.spec.c
浏览文件 @
f7e40d0e
...
@@ -82,7 +82,7 @@ void mgmtCleanUpDnodeInt() {}
...
@@ -82,7 +82,7 @@ void mgmtCleanUpDnodeInt() {}
void
mgmtProcessDnodeStatus
(
void
*
handle
,
void
*
tmrId
)
{
void
mgmtProcessDnodeStatus
(
void
*
handle
,
void
*
tmrId
)
{
SDnodeObj
*
pObj
=
&
dnodeObj
;
SDnodeObj
*
pObj
=
&
dnodeObj
;
pObj
->
openVnodes
=
tsOpenVnodes
;
pObj
->
openVnodes
=
tsOpenVnodes
;
pObj
->
status
=
TSDB_STATUS_READY
;
pObj
->
status
=
TSDB_
DNODE_
STATUS_READY
;
float
memoryUsedMB
=
0
;
float
memoryUsedMB
=
0
;
taosGetSysMemory
(
&
memoryUsedMB
);
taosGetSysMemory
(
&
memoryUsedMB
);
...
@@ -97,7 +97,7 @@ void mgmtProcessDnodeStatus(void *handle, void *tmrId) {
...
@@ -97,7 +97,7 @@ void mgmtProcessDnodeStatus(void *handle, void *tmrId) {
if
(
vnodeList
[
vnode
].
cfg
.
maxSessions
<=
0
)
{
if
(
vnodeList
[
vnode
].
cfg
.
maxSessions
<=
0
)
{
pVload
->
dropStatus
=
TSDB_VN_STATUS_READY
;
pVload
->
dropStatus
=
TSDB_VN_STATUS_READY
;
pVload
->
status
=
TSDB_VN_STATUS_READY
;
pVload
->
status
=
TSDB_VN_STATUS_READY
;
mPrint
(
"
vid:%d, drop finished"
,
pObj
->
privateIp
,
vnode
);
mPrint
(
"
dnode:%s, vid:%d, drop finished"
,
taosIpStr
(
pObj
->
privateIp
)
,
vnode
);
taosTmrStart
(
mgmtMonitorDbDrop
,
10000
,
NULL
,
mgmtTmr
);
taosTmrStart
(
mgmtMonitorDbDrop
,
10000
,
NULL
,
mgmtTmr
);
}
}
}
}
...
...
src/system/lite/src/vnodePeer.spec.c
浏览文件 @
f7e40d0e
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "vnode.h"
#include "vnode.h"
#include "tstatus.h"
int
vnodeInitPeer
(
int
numOfThreads
)
{
return
0
;
}
int
vnodeInitPeer
(
int
numOfThreads
)
{
return
0
;
}
...
@@ -30,8 +31,8 @@ void vnodeBroadcastStatusToUnsyncedPeer(SVnodeObj *pVnode) {}
...
@@ -30,8 +31,8 @@ void vnodeBroadcastStatusToUnsyncedPeer(SVnodeObj *pVnode) {}
int
vnodeOpenPeerVnode
(
int
vnode
)
{
int
vnodeOpenPeerVnode
(
int
vnode
)
{
SVnodeObj
*
pVnode
=
vnodeList
+
vnode
;
SVnodeObj
*
pVnode
=
vnodeList
+
vnode
;
pVnode
->
status
=
(
pVnode
->
cfg
.
replications
>
1
)
?
TSDB_STATUS_UNSYNCED
:
TSDB
_STATUS_MASTER
;
pVnode
->
vnodeStatus
=
(
pVnode
->
cfg
.
replications
>
1
)
?
TSDB_VNODE_STATUS_UNSYNCED
:
TSDB_VNODE
_STATUS_MASTER
;
dTrace
(
"vid:%d,
vnode status:%d numOfPeers:%d"
,
vnode
,
pVnode
->
status
,
pVnode
->
cfg
.
replications
-
1
);
dTrace
(
"vid:%d,
status:%s numOfPeers:%d"
,
vnode
,
taosGetVnodeStatusStr
(
pVnode
->
vnodeStatus
),
pVnode
->
cfg
.
replications
-
1
);
vnodeUpdateStreamRole
(
pVnode
);
vnodeUpdateStreamRole
(
pVnode
);
return
0
;
return
0
;
}
}
...
...
src/util/src/tstatus.c
浏览文件 @
f7e40d0e
...
@@ -13,10 +13,54 @@
...
@@ -13,10 +13,54 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
char
*
sdbDnodeStatusStr
[]
=
{
"offline"
,
"creating"
,
"unsynced"
,
"slave"
,
"master"
,
"ready"
};
#include "taosmsg.h"
#include "tsdb.h"
char
*
sdbDnodeBalanceStateStr
[]
=
{
"balanced"
,
"balancing"
,
"offline removing"
,
"shell removing"
};
const
char
*
taosGetVnodeStatusStr
(
int
vnodeStatus
)
{
switch
(
vnodeStatus
)
{
case
TSDB_VNODE_STATUS_OFFLINE
:
return
"offline"
;
case
TSDB_VNODE_STATUS_CREATING
:
return
"creating"
;
case
TSDB_VNODE_STATUS_UNSYNCED
:
return
"unsynced"
;
case
TSDB_VNODE_STATUS_SLAVE
:
return
"slave"
;
case
TSDB_VNODE_STATUS_MASTER
:
return
"master"
;
case
TSDB_VNODE_STATUS_CLOSING
:
return
"closing"
;
case
TSDB_VNODE_STATUS_DELETING
:
return
"deleting"
;
default:
return
"undefined"
;
}
}
char
*
sdbVnodeSyncStatusStr
[]
=
{
"init"
,
"syncing"
,
"sync_cache"
,
"sync_file"
};
const
char
*
taosGetDnodeStatusStr
(
int
dnodeStatus
)
{
switch
(
dnodeStatus
)
{
case
TSDB_DNODE_STATUS_OFFLINE
:
return
"offline"
;
case
TSDB_DNODE_STATUS_READY
:
return
"ready"
;
default:
return
"undefined"
;
}
}
char
*
sdbVnodeDropStateStr
[]
=
{
"ready"
,
"dropping"
};
const
char
*
taosGetDnodeBalanceStateStr
(
int
dnodeBalanceStatus
)
{
switch
(
dnodeBalanceStatus
)
{
case
LB_DNODE_STATE_BALANCED
:
return
"balanced"
;
case
LB_DNODE_STATE_BALANCING
:
return
"balancing"
;
case
LB_DNODE_STATE_OFFLINE_REMOVING
:
return
"offline removing"
;
case
LB_DNODE_STATE_SHELL_REMOVING
:
return
"removing"
;
default:
return
"undefined"
;
}
}
const
char
*
taosGetVnodeSyncStatusStr
(
int
vnodeSyncStatus
)
{
switch
(
vnodeSyncStatus
)
{
case
STDB_SSTATUS_INIT
:
return
"init"
;
case
TSDB_SSTATUS_SYNCING
:
return
"syncing"
;
case
TSDB_SSTATUS_SYNC_CACHE
:
return
"sync_cache"
;
case
TSDB_SSTATUS_SYNC_FILE
:
return
"sync_file"
;
default:
return
"undefined"
;
}
}
const
char
*
taosGetVnodeDropStatusStr
(
int
dropping
)
{
switch
(
dropping
)
{
case
0
:
return
"ready"
;
case
1
:
return
"dropping"
;
default:
return
"undefined"
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录