Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小楼昨夜-听风雨
TDengine
提交
8527587b
T
TDengine
项目概览
小楼昨夜-听风雨
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8527587b
编写于
11月 18, 2019
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TBASE-1186]
上级
b1bb894e
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
199 addition
and
80 deletion
+199
-80
src/inc/taoserror.h
src/inc/taoserror.h
+1
-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
+1
-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
+19
-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/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
+16
-4
src/system/detail/src/vnodeStore.c
src/system/detail/src/vnodeStore.c
+55
-23
src/system/detail/src/vnodeStream.c
src/system/detail/src/vnodeStream.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
浏览文件 @
8527587b
...
...
@@ -134,6 +134,7 @@ extern "C" {
#define TSDB_CODE_INVALID_SUBMIT_MSG 113
#define TSDB_CODE_NOT_ACTIVE_TABLE 114
#define TSDB_CODE_INVALID_TABLE_ID 115
#define TSDB_CODE_INVALID_VNODE_STATUS 116
#ifdef __cplusplus
}
...
...
src/inc/tsdb.h
浏览文件 @
8527587b
...
...
@@ -44,22 +44,40 @@ extern "C" {
#define TSDB_TIME_PRECISION_MILLI_STR "ms"
#define TSDB_TIME_PRECISION_MICRO_STR "us"
enum
_status
{
TSDB_STATUS_OFFLINE
,
TSDB_STATUS_CREATING
,
TSDB_STATUS_UNSYNCED
,
TSDB_STATUS_SLAVE
,
TSDB_STATUS_MASTER
,
TSDB_STATUS_READY
,
enum
_vnode_status
{
TSDB_VNODE_STATUS_OFFLINE
,
TSDB_VNODE_STATUS_CREATING
,
TSDB_VNODE_STATUS_UNSYNCED
,
TSDB_VNODE_STATUS_SLAVE
,
TSDB_VNODE_STATUS_MASTER
,
TSDB_VNODE_STATUS_CLOSING
,
TSDB_VNODE_STATUS_DELETING
,
};
enum
_
sync
status
{
enum
_
vnode_sync_
status
{
STDB_SSTATUS_INIT
,
TSDB_SSTATUS_SYNCING
,
TSDB_SSTATUS_SYNC_CACHE
,
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_TINYINT 2 // 1 byte
#define TSDB_DATA_TYPE_SMALLINT 3 // 2 bytes
...
...
src/inc/tstatus.h
浏览文件 @
8527587b
...
...
@@ -20,10 +20,11 @@
extern
"C"
{
#endif
extern
char
*
sdbDnodeStatusStr
[];
extern
char
*
sdbDnodeBalanceStateStr
[];
extern
char
*
sdbVnodeDropStateStr
[];
extern
char
*
sdbVnodeSyncStatusStr
[];
const
char
*
taosGetVnodeStatusStr
(
int
vnodeStatus
);
const
char
*
taosGetDnodeStatusStr
(
int
dnodeStatus
);
const
char
*
taosGetDnodeBalanceStateStr
(
int
dnodeBalanceStatus
);
const
char
*
taosGetVnodeSyncStatusStr
(
int
vnodeSyncStatus
);
const
char
*
taosGetVnodeDropStatusStr
(
int
dropping
);
#ifdef __cplusplus
}
...
...
src/rpc/src/trpc.c
浏览文件 @
8527587b
...
...
@@ -354,6 +354,8 @@ int taosOpenRpcChannWithQ(void *handle, int cid, int sessions, void *qhandle) {
STaosRpc
*
pServer
=
(
STaosRpc
*
)
handle
;
SRpcChann
*
pChann
;
tTrace
(
"cid:%d, handle:%p open rpc chann"
,
cid
,
handle
);
if
(
pServer
==
NULL
)
return
-
1
;
if
(
cid
>=
pServer
->
numOfChanns
||
cid
<
0
)
{
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) {
STaosRpc
*
pServer
=
(
STaosRpc
*
)
handle
;
SRpcChann
*
pChann
;
tTrace
(
"cid:%d, handle:%p close rpc chann"
,
cid
,
handle
);
if
(
pServer
==
NULL
)
return
;
if
(
cid
>=
pServer
->
numOfChanns
||
cid
<
0
)
{
tError
(
"%s cid:%d, chann is out of range, max:%d"
,
pServer
->
label
,
cid
,
pServer
->
numOfChanns
);
...
...
src/rpc/src/tstring.c
浏览文件 @
8527587b
...
...
@@ -240,4 +240,5 @@ char *tsError[] = {"success",
"invalid submit message"
,
"not active table(not created yet or deleted already)"
,
//114
"invalid table id"
,
"invalid vnode status"
,
//116
};
src/system/detail/inc/mgmtBalance.h
浏览文件 @
8527587b
...
...
@@ -28,15 +28,6 @@ extern "C" {
#include "tstatus.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
mgmtReleaseDnodeOrderList
();
...
...
src/system/detail/inc/vnode.h
浏览文件 @
8527587b
...
...
@@ -92,7 +92,7 @@ typedef struct {
SVPeerDesc
vpeers
[
TSDB_VNODES_SUPPORT
];
SVnodePeer
*
peerInfo
[
TSDB_VNODES_SUPPORT
];
char
selfIndex
;
char
s
tatus
;
char
vnodeS
tatus
;
char
accessState
;
// Vnode access state, Readable/Writable
char
syncStatus
;
char
commitInProcess
;
...
...
src/system/detail/src/dnodeMgmt.c
浏览文件 @
8527587b
...
...
@@ -26,6 +26,7 @@
#include "vnodeMgmt.h"
#include "vnodeSystem.h"
#include "vnodeUtil.h"
#include "tstatus.h"
SMgmtObj
mgmtObj
;
extern
uint64_t
tsCreatedTime
;
...
...
@@ -330,7 +331,7 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
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
);
return
0
;
}
...
...
@@ -359,13 +360,23 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
}
if
(
vnodeList
[
vnode
].
cfg
.
maxSessions
==
0
)
{
dTrace
(
"vid:%d, vnode is empty"
,
vnode
);
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
{
dTrace
(
"vid:%d, vnode is not empty"
,
vnode
);
if
(
pCfg
->
maxSessions
>
0
)
{
dTrace
(
"vid:%d, status:%s, start to update vnode"
,
vnode
,
taosGetVnodeStatusStr
(
vnodeList
[
vnode
].
vnodeStatus
));
/*
if (pCfg->maxSessions != vnodeList[vnode].cfg.maxSessions) {
vnodeCleanUpOneVnode
(
vnode
);
vnodeCleanUpOneVnode(vnode);
}
vnodeConfigVPeers(vnode, pCfg->replications, pMsg->vpeerDesc);
...
...
@@ -376,7 +387,10 @@ int vnodeProcessVPeerCfg(char *msg, int msgLen, SMgmtObj *pMgmtObj) {
vnodeList[vnode].cfg.maxSessions = pCfg->maxSessions;
vnodeOpenVnode(vnode);
}
*/
return
0
;
}
else
{
dTrace
(
"vid:%d, status:%s, start to delete vnode"
,
vnode
,
taosGetVnodeStatusStr
(
vnodeList
[
vnode
].
vnodeStatus
));
vnodeRemoveVnode
(
vnode
);
}
}
...
...
@@ -434,11 +448,11 @@ int vnodeProcessFreeVnodeRequest(char *pMsg, int msgLen, SMgmtObj *pMgmtObj) {
pFree
->
vnode
=
htons
(
pFree
->
vnode
);
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
;
}
dTrace
(
"vid:%d receive free vnode message"
,
pFree
->
vnode
);
dTrace
(
"vid:%d
,
receive free vnode message"
,
pFree
->
vnode
);
int32_t
code
=
vnodeRemoveVnode
(
pFree
->
vnode
);
assert
(
code
==
TSDB_CODE_SUCCESS
||
code
==
TSDB_CODE_ACTION_IN_PROGRESS
);
...
...
src/system/detail/src/mgmtDb.c
浏览文件 @
8527587b
...
...
@@ -141,11 +141,10 @@ int mgmtCheckDbParams(SCreateDbMsg *pCreate) {
if
(
pCreate
->
cacheNumOfBlocks
.
fraction
<
0
)
pCreate
->
cacheNumOfBlocks
.
fraction
=
tsAverageCacheBlocks
;
//
//-1 for balance
#ifdef CLUSTER
if
(
pCreate
->
replications
>
TSDB_VNODES_SUPPORT
-
1
)
pCreate
->
replications
=
TSDB_VNODES_SUPPORT
-
1
;
#else
pCreate
->
replications
=
1
;
#endif
if
(
pCreate
->
replications
<=
0
||
pCreate
->
replications
>
TSDB_REPLICA_MAX_NUM
)
{
mTrace
(
"invalid db option replications: %d"
,
pCreate
->
replications
);
return
TSDB_CODE_INVALID_OPTION
;
}
if
(
pCreate
->
commitLog
<
0
||
pCreate
->
commitLog
>
1
)
{
mTrace
(
"invalid db option commitLog: %d"
,
pCreate
->
commitLog
);
...
...
@@ -316,7 +315,7 @@ bool mgmtCheckDropDbFinished(SDbObj *pDb) {
SDnodeObj
*
pDnode
=
mgmtGetDnode
(
pVnodeGid
->
ip
);
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
];
if
(
pVload
->
dropStatus
==
TSDB_VN_STATUS_DROPPING
)
{
...
...
src/system/detail/src/mgmtDnode.c
浏览文件 @
8527587b
...
...
@@ -21,6 +21,7 @@
#include "mgmt.h"
#include "tschemautil.h"
#include "tstatus.h"
#include "tstatus.h"
bool
mgmtCheckModuleInDnode
(
SDnodeObj
*
pDnode
,
int
moduleType
);
int
mgmtGetDnodesNum
();
...
...
@@ -43,9 +44,9 @@ void mgmtSetDnodeMaxVnodes(SDnodeObj *pDnode) {
pDnode
->
openVnodes
=
0
;
#ifdef CLUSTER
pDnode
->
status
=
TSDB_STATUS_OFFLINE
;
pDnode
->
status
=
TSDB_
DNODE_
STATUS_OFFLINE
;
#else
pDnode
->
status
=
TSDB_STATUS_READY
;
pDnode
->
status
=
TSDB_
DNODE_
STATUS_READY
;
#endif
}
...
...
@@ -57,9 +58,9 @@ void mgmtCalcNumOfFreeVnodes(SDnodeObj *pDnode) {
if
(
pVload
->
vgId
!=
0
)
{
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
,
pVload
->
status
,
sdbDnodeStatusStr
[
pVload
->
status
]
,
pVload
->
dropStatus
,
sdbVnodeDropStateStr
[
pVload
->
dropStatus
]
,
pVload
->
syncStatus
,
sdbVnodeSyncStatusStr
[
pVload
->
syncStatus
]
);
pVload
->
status
,
taosGetDnodeStatusStr
(
pVload
->
status
)
,
pVload
->
dropStatus
,
taosGetVnodeDropStatusStr
(
pVload
->
dropStatus
)
,
pVload
->
syncStatus
,
taosGetVnodeSyncStatusStr
(
pVload
->
syncStatus
)
);
totalVnodes
++
;
}
}
...
...
@@ -196,11 +197,11 @@ int mgmtRetrieveDnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
sdbDnodeStatusStr
[
pDnode
->
status
]
);
strcpy
(
pWrite
,
taosGetDnodeStatusStr
(
pDnode
->
status
)
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
sdbDnodeBalanceStateStr
[
pDnode
->
lbState
]
);
strcpy
(
pWrite
,
taosGetDnodeBalanceStateStr
(
pDnode
->
lbState
)
);
cols
++
;
tinet_ntoa
(
ipstr
,
pDnode
->
publicIp
);
...
...
@@ -292,7 +293,7 @@ int mgmtRetrieveModules(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strcpy
(
pWrite
,
sdbDnodeStatusStr
[
pDnode
->
status
]
);
strcpy
(
pWrite
,
taosGetDnodeStatusStr
(
pDnode
->
status
)
);
cols
++
;
numOfRows
++
;
...
...
src/system/detail/src/vnodeCache.c
浏览文件 @
8527587b
...
...
@@ -296,7 +296,7 @@ pthread_t vnodeCreateCommitThread(SVnodeObj *pVnode) {
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
);
dTrace
(
"vid:%d, it is in unsyc state, commit later"
,
pVnode
->
vnode
);
return
pVnode
->
commitThread
;
...
...
src/system/detail/src/vnodeFile.c
浏览文件 @
8527587b
...
...
@@ -1290,7 +1290,7 @@ int vnodeWriteBlockToFile(SMeterObj *pObj, SCompBlock *pCompBlock, SData *data[]
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
->
numOfPoints
=
points
;
...
...
src/system/detail/src/vnodeShell.c
浏览文件 @
8527587b
...
...
@@ -27,6 +27,7 @@
#include "vnode.h"
#include "vnodeRead.h"
#include "vnodeUtil.h"
#include "vnodeStore.h"
#pragma GCC diagnostic ignored "-Wint-conversion"
extern
int
tsMaxQueues
;
...
...
@@ -154,6 +155,11 @@ int vnodeInitShell() {
}
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
;
SVnodeCfg
*
pCfg
=
&
vnodeList
[
vnode
].
cfg
;
...
...
@@ -162,23 +168,29 @@ int vnodeOpenShellVnode(int vnode) {
size_t
size
=
sessions
*
sizeof
(
SShellObj
);
shellList
[
vnode
]
=
(
SShellObj
*
)
calloc
(
1
,
size
);
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
;
}
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
;
}
dTrace
(
"vid:%d, sessions:%d, shell is opened"
,
vnode
,
pCfg
->
maxSessions
);
return
TSDB_CODE_SUCCESS
;
}
static
void
vnodeDelayedFreeResource
(
void
*
param
,
void
*
tmrId
)
{
int32_t
vnode
=
*
(
int32_t
*
)
param
;
taosCloseRpcChann
(
pShellServer
,
vnode
);
// close connection
tfree
(
shellList
[
vnode
]);
//free SShellObj
dTrace
(
"vid:%d, start to free resources"
,
vnode
);
taosCloseRpcChann
(
pShellServer
,
vnode
);
// close connection
tfree
(
shellList
[
vnode
]);
//free SShellObj
tfree
(
param
);
memset
(
vnodeList
+
vnode
,
0
,
sizeof
(
SVnodeObj
));
vnodeCalcOpenVnodes
();
}
void
vnodeCloseShellVnode
(
int
vnode
)
{
...
...
@@ -197,7 +209,7 @@ void vnodeCloseShellVnode(int vnode) {
* 2. Free connection may cause *(SRpcConn*)pObj->thandle to be invalid to access.
*/
dTrace
(
"vid:%d, free resources in 500ms"
,
vnode
);
taosTmrStart
(
vnodeDelayedFreeResource
,
500
,
v
,
vnodeTmrCtrl
);
taosTmrStart
(
vnodeDelayedFreeResource
,
500
0
,
v
,
vnodeTmrCtrl
);
}
void
vnodeCleanUpShell
()
{
...
...
src/system/detail/src/vnodeStore.c
浏览文件 @
8527587b
...
...
@@ -22,6 +22,7 @@
#include "vnode.h"
#include "vnodeStore.h"
#include "vnodeUtil.h"
#include "tstatus.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic warning "-Woverflow"
...
...
@@ -30,12 +31,14 @@ int tsMaxVnode = -1;
int
tsOpenVnodes
=
0
;
SVnodeObj
*
vnodeList
=
NULL
;
int
vnodeInitStoreVnode
(
int
vnode
)
{
static
int
vnodeInitStoreVnode
(
int
vnode
)
{
SVnodeObj
*
pVnode
=
vnodeList
+
vnode
;
pVnode
->
vnode
=
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
);
...
...
@@ -45,9 +48,10 @@ int vnodeInitStoreVnode(int vnode) {
return
-
1
;
}
if
(
vnodeInitFile
(
vnode
)
<
0
)
return
-
1
;
// vnodeOpenMeterMgmtStoreVnode(vnode);
if
(
vnodeInitFile
(
vnode
)
<
0
)
{
dError
(
"vid:%d, files init failed."
,
pVnode
->
vnode
);
return
-
1
;
}
if
(
vnodeInitCommit
(
vnode
)
<
0
)
{
dError
(
"vid:%d, commit init failed."
,
pVnode
->
vnode
);
...
...
@@ -70,10 +74,17 @@ int vnodeOpenVnode(int vnode) {
pVnode
->
accessState
=
TSDB_VN_ALL_ACCCESS
;
// 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
);
// vnodeOpenMeterMgmtVnode(vnode);
// not enough memory, abort
if
((
code
=
vnodeOpenShellVnode
(
vnode
))
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -93,14 +104,13 @@ int vnodeOpenVnode(int vnode) {
vnodeOpenStreams
(
pVnode
,
NULL
);
#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
)
{
if
(
pVnode
->
meterList
==
NULL
)
{
assert
(
pVnode
->
cfg
.
maxSessions
==
0
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -119,7 +129,7 @@ static int32_t vnodeMarkAllMetersDropped(SVnodeObj* pVnode) {
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
;
SVnodeObj
*
pVnode
=
&
vnodeList
[
vnode
];
...
...
@@ -130,12 +140,23 @@ int vnodeCloseVnode(int vnode) {
return
TSDB_CODE_SUCCESS
;
}
if
(
pVnode
->
vnodeStatus
==
TSDB_VNODE_STATUS_DELETING
)
{
dTrace
(
"vid:%d, status:%s, another 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
if
(
vnodeMarkAllMetersDropped
(
pVnode
)
!=
TSDB_CODE_SUCCESS
)
{
pthread_mutex_unlock
(
&
dmutex
);
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
);
vnodeCancelCommit
(
vnodeList
+
vnode
);
vnodeClosePeerVnode
(
vnode
);
...
...
@@ -149,9 +170,6 @@ int vnodeCloseVnode(int vnode) {
if
(
tsMaxVnode
==
vnode
)
tsMaxVnode
=
vnode
-
1
;
tfree
(
vnodeList
[
vnode
].
meterIndex
);
memset
(
vnodeList
+
vnode
,
0
,
sizeof
(
SVnodeObj
));
vnodeCalcOpenVnodes
();
pthread_mutex_unlock
(
&
dmutex
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -160,7 +178,12 @@ int vnodeCloseVnode(int vnode) {
int
vnodeCreateVnode
(
int
vnode
,
SVnodeCfg
*
pCfg
,
SVPeerDesc
*
pDesc
)
{
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
);
mkdir
(
fileName
,
0755
);
...
...
@@ -177,14 +200,14 @@ int vnodeCreateVnode(int vnode, SVnodeCfg *pCfg, SVPeerDesc *pDesc) {
return
TSDB_CODE_VG_INIT_FAILED
;
}
if
(
vnodeInitStoreVnode
(
vnode
)
!=
0
)
{
if
(
vnodeInitStoreVnode
(
vnode
)
<
0
)
{
return
TSDB_CODE_VG_COMMITLOG_INIT_FAILED
;
}
return
vnodeOpenVnode
(
vnode
);
}
void
vnodeRemoveDataFiles
(
int
vnode
)
{
static
void
vnodeRemoveDataFiles
(
int
vnode
)
{
char
vnodeDir
[
TSDB_FILENAME_LEN
];
char
dfilePath
[
TSDB_FILENAME_LEN
];
char
linkFile
[
TSDB_FILENAME_LEN
];
...
...
@@ -234,12 +257,21 @@ int vnodeRemoveVnode(int vnode) {
if
(
vnodeList
==
NULL
)
return
TSDB_CODE_SUCCESS
;
if
(
vnodeList
[
vnode
].
cfg
.
maxSessions
>
0
)
{
int32_t
ret
=
vnodeCloseVnode
(
vnode
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
SVnodeObj
*
pVnode
=
&
vnodeList
[
vnode
];
if
(
pVnode
->
vnodeStatus
==
TSDB_VNODE_STATUS_CREATING
||
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
{
dTrace
(
"vid:%d, max sessions:%d, this vnode already dropped!!!"
,
vnode
,
vnodeList
[
vnode
].
cfg
.
maxSessions
);
vnodeList
[
vnode
].
cfg
.
maxSessions
=
0
;
//reset value
...
...
@@ -293,7 +325,7 @@ void vnodeCleanUpOneVnode(int vnode) {
again
=
1
;
if
(
vnodeList
[
vnode
].
pCachePool
)
{
vnodeList
[
vnode
].
status
=
TSDB
_STATUS_OFFLINE
;
vnodeList
[
vnode
].
vnodeStatus
=
TSDB_VNODE
_STATUS_OFFLINE
;
vnodeClosePeerVnode
(
vnode
);
}
...
...
@@ -322,7 +354,7 @@ void vnodeCleanUpVnodes() {
for
(
int
vnode
=
0
;
vnode
<
TSDB_MAX_VNODES
;
++
vnode
)
{
if
(
vnodeList
[
vnode
].
pCachePool
)
{
vnodeList
[
vnode
].
status
=
TSDB
_STATUS_OFFLINE
;
vnodeList
[
vnode
].
vnodeStatus
=
TSDB_VNODE
_STATUS_OFFLINE
;
vnodeClosePeerVnode
(
vnode
);
}
}
...
...
src/system/detail/src/vnodeStream.c
浏览文件 @
8527587b
...
...
@@ -171,7 +171,7 @@ void vnodeCloseStream(SVnodeObj *pVnode) {
void
vnodeUpdateStreamRole
(
SVnodeObj
*
pVnode
)
{
/* 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
)
{
dTrace
(
"vid:%d, stream role is changed to:%d"
,
pVnode
->
vnode
,
newRole
);
pVnode
->
streamRole
=
newRole
;
...
...
src/system/lite/src/mgmtDnode.spec.c
浏览文件 @
8527587b
...
...
@@ -30,7 +30,7 @@ int mgmtInitDnodes() {
dnodeObj
.
createdTime
=
(
int64_t
)
tsRebootTime
*
1000
;
dnodeObj
.
lastReboot
=
tsRebootTime
;
dnodeObj
.
numOfCores
=
(
uint16_t
)
tsNumOfCores
;
dnodeObj
.
status
=
TSDB_STATUS_READY
;
dnodeObj
.
status
=
TSDB_
DNODE_
STATUS_READY
;
dnodeObj
.
alternativeRole
=
TSDB_DNODE_ROLE_ANY
;
dnodeObj
.
numOfTotalVnodes
=
tsNumOfTotalVnodes
;
dnodeObj
.
thandle
=
(
void
*
)(
1
);
//hack way
...
...
src/system/lite/src/mgmtDnodeInt.spec.c
浏览文件 @
8527587b
...
...
@@ -82,7 +82,7 @@ void mgmtCleanUpDnodeInt() {}
void
mgmtProcessDnodeStatus
(
void
*
handle
,
void
*
tmrId
)
{
SDnodeObj
*
pObj
=
&
dnodeObj
;
pObj
->
openVnodes
=
tsOpenVnodes
;
pObj
->
status
=
TSDB_STATUS_READY
;
pObj
->
status
=
TSDB_
DNODE_
STATUS_READY
;
float
memoryUsedMB
=
0
;
taosGetSysMemory
(
&
memoryUsedMB
);
...
...
@@ -97,7 +97,7 @@ void mgmtProcessDnodeStatus(void *handle, void *tmrId) {
if
(
vnodeList
[
vnode
].
cfg
.
maxSessions
<=
0
)
{
pVload
->
dropStatus
=
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
);
}
}
...
...
src/system/lite/src/vnodePeer.spec.c
浏览文件 @
8527587b
...
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#include "vnode.h"
#include "tstatus.h"
int
vnodeInitPeer
(
int
numOfThreads
)
{
return
0
;
}
...
...
@@ -30,8 +31,8 @@ void vnodeBroadcastStatusToUnsyncedPeer(SVnodeObj *pVnode) {}
int
vnodeOpenPeerVnode
(
int
vnode
)
{
SVnodeObj
*
pVnode
=
vnodeList
+
vnode
;
pVnode
->
status
=
(
pVnode
->
cfg
.
replications
>
1
)
?
TSDB_STATUS_UNSYNCED
:
TSDB
_STATUS_MASTER
;
dTrace
(
"vid:%d,
vnode status:%d numOfPeers:%d"
,
vnode
,
pVnode
->
status
,
pVnode
->
cfg
.
replications
-
1
);
pVnode
->
vnodeStatus
=
(
pVnode
->
cfg
.
replications
>
1
)
?
TSDB_VNODE_STATUS_UNSYNCED
:
TSDB_VNODE
_STATUS_MASTER
;
dTrace
(
"vid:%d,
status:%s numOfPeers:%d"
,
vnode
,
taosGetVnodeStatusStr
(
pVnode
->
vnodeStatus
),
pVnode
->
cfg
.
replications
-
1
);
vnodeUpdateStreamRole
(
pVnode
);
return
0
;
}
...
...
src/util/src/tstatus.c
浏览文件 @
8527587b
...
...
@@ -13,10 +13,54 @@
* 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录