Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小楼昨夜-听风雨
TDengine
提交
83d2acd5
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,发现更多精彩内容 >>
未验证
提交
83d2acd5
编写于
11月 08, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
11月 08, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4149 from taosdata/feature/table
Feature/table
上级
c91ca88e
855ecf59
变更
29
显示空白变更内容
内联
并排
Showing
29 changed file
with
524 addition
and
513 deletion
+524
-513
src/dnode/inc/dnodeMPeer.h
src/dnode/inc/dnodeMPeer.h
+5
-5
src/dnode/inc/dnodeMRead.h
src/dnode/inc/dnodeMRead.h
+5
-5
src/dnode/inc/dnodeMWrite.h
src/dnode/inc/dnodeMWrite.h
+5
-5
src/dnode/src/dnodeMPeer.c
src/dnode/src/dnodeMPeer.c
+34
-35
src/dnode/src/dnodeMRead.c
src/dnode/src/dnodeMRead.c
+42
-43
src/dnode/src/dnodeMWrite.c
src/dnode/src/dnodeMWrite.c
+43
-45
src/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+13
-13
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+34
-22
src/dnode/src/dnodePeer.c
src/dnode/src/dnodePeer.c
+22
-21
src/dnode/src/dnodeShell.c
src/dnode/src/dnodeShell.c
+44
-44
src/dnode/src/dnodeVWrite.c
src/dnode/src/dnodeVWrite.c
+1
-1
src/inc/dnode.h
src/inc/dnode.h
+16
-16
src/inc/mnode.h
src/inc/mnode.h
+10
-9
src/inc/taosdef.h
src/inc/taosdef.h
+29
-28
src/mnode/inc/mnodeDef.h
src/mnode/inc/mnodeDef.h
+4
-4
src/mnode/inc/mnodeTable.h
src/mnode/inc/mnodeTable.h
+2
-2
src/mnode/inc/mnodeVgroup.h
src/mnode/inc/mnodeVgroup.h
+2
-2
src/mnode/src/mnodeInt.c
src/mnode/src/mnodeInt.c
+13
-4
src/mnode/src/mnodeMain.c
src/mnode/src/mnodeMain.c
+6
-6
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+2
-2
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+104
-102
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+8
-8
src/plugins/http/src/httpQueue.c
src/plugins/http/src/httpQueue.c
+1
-1
src/plugins/monitor/src/monitorMain.c
src/plugins/monitor/src/monitorMain.c
+32
-32
src/vnode/src/vnodeCfg.c
src/vnode/src/vnodeCfg.c
+0
-1
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+12
-18
src/vnode/src/vnodeRead.c
src/vnode/src/vnodeRead.c
+32
-35
src/vnode/src/vnodeWrite.c
src/vnode/src/vnodeWrite.c
+1
-2
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+2
-2
未找到文件。
src/dnode/inc/dnodeMPeer.h
浏览文件 @
83d2acd5
...
@@ -20,11 +20,11 @@
...
@@ -20,11 +20,11 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
int32_t
dnodeInitM
node
Peer
();
int32_t
dnodeInitMPeer
();
void
dnodeCleanupM
node
Peer
();
void
dnodeCleanupMPeer
();
int32_t
dnodeAllocateM
nodePq
ueue
();
int32_t
dnodeAllocateM
PeerQ
ueue
();
void
dnodeFreeM
nodePq
ueue
();
void
dnodeFreeM
PeerQ
ueue
();
void
dnodeDispatchToM
node
PeerQueue
(
SRpcMsg
*
pMsg
);
void
dnodeDispatchToMPeerQueue
(
SRpcMsg
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/dnode/inc/dnodeMRead.h
浏览文件 @
83d2acd5
...
@@ -20,11 +20,11 @@
...
@@ -20,11 +20,11 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
int32_t
dnodeInitM
node
Read
();
int32_t
dnodeInitMRead
();
void
dnodeCleanupM
node
Read
();
void
dnodeCleanupMRead
();
int32_t
dnodeAlloc
ateMnodeRq
ueue
();
int32_t
dnodeAlloc
MReadQ
ueue
();
void
dnodeFreeM
nodeRq
ueue
();
void
dnodeFreeM
ReadQ
ueue
();
void
dnodeDispatchToM
node
ReadQueue
(
SRpcMsg
*
rpcMsg
);
void
dnodeDispatchToMReadQueue
(
SRpcMsg
*
rpcMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/dnode/inc/dnodeMWrite.h
浏览文件 @
83d2acd5
...
@@ -20,11 +20,11 @@
...
@@ -20,11 +20,11 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
int32_t
dnodeInitM
node
Write
();
int32_t
dnodeInitMWrite
();
void
dnodeCleanupM
node
Write
();
void
dnodeCleanupMWrite
();
int32_t
dnodeAlloc
ateMnodeW
queue
();
int32_t
dnodeAlloc
MWrite
queue
();
void
dnodeFreeM
nodeW
queue
();
void
dnodeFreeM
Write
queue
();
void
dnodeDispatchToM
node
WriteQueue
(
SRpcMsg
*
pMsg
);
void
dnodeDispatchToMWriteQueue
(
SRpcMsg
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/dnode/src/dnodeMPeer.c
浏览文件 @
83d2acd5
...
@@ -35,44 +35,44 @@ typedef struct {
...
@@ -35,44 +35,44 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int32_t
curNum
;
int32_t
curNum
;
int32_t
maxNum
;
int32_t
maxNum
;
SMPeerWorker
*
peerW
orker
;
SMPeerWorker
*
w
orker
;
}
SMPeerWorkerPool
;
}
SMPeerWorkerPool
;
static
SMPeerWorkerPool
tsMPeer
Pool
;
static
SMPeerWorkerPool
tsMPeer
WP
;
static
taos_qset
tsMPeerQset
;
static
taos_qset
tsMPeerQset
;
static
taos_queue
tsMPeerQueue
;
static
taos_queue
tsMPeerQueue
;
static
void
*
dnodeProcessM
node
PeerQueue
(
void
*
param
);
static
void
*
dnodeProcessMPeerQueue
(
void
*
param
);
int32_t
dnodeInitM
node
Peer
()
{
int32_t
dnodeInitMPeer
()
{
tsMPeerQset
=
taosOpenQset
();
tsMPeerQset
=
taosOpenQset
();
tsMPeer
Pool
.
maxNum
=
1
;
tsMPeer
WP
.
maxNum
=
1
;
tsMPeer
Pool
.
curNum
=
0
;
tsMPeer
WP
.
curNum
=
0
;
tsMPeer
Pool
.
peerWorker
=
(
SMPeerWorker
*
)
calloc
(
sizeof
(
SMPeerWorker
),
tsMPeerPool
.
maxNum
);
tsMPeer
WP
.
worker
=
(
SMPeerWorker
*
)
calloc
(
sizeof
(
SMPeerWorker
),
tsMPeerWP
.
maxNum
);
if
(
tsMPeer
Pool
.
peerW
orker
==
NULL
)
return
-
1
;
if
(
tsMPeer
WP
.
w
orker
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
tsMPeer
Pool
.
maxNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tsMPeer
WP
.
maxNum
;
++
i
)
{
SMPeerWorker
*
pWorker
=
tsMPeer
Pool
.
peerW
orker
+
i
;
SMPeerWorker
*
pWorker
=
tsMPeer
WP
.
w
orker
+
i
;
pWorker
->
workerId
=
i
;
pWorker
->
workerId
=
i
;
dDebug
(
"dnode mpeer worker:%d is created"
,
i
);
dDebug
(
"dnode mpeer worker:%d is created"
,
i
);
}
}
dDebug
(
"dnode mpeer is initialized, workers:%d qset:%p"
,
tsMPeer
Pool
.
maxNum
,
tsMPeerQset
);
dDebug
(
"dnode mpeer is initialized, workers:%d qset:%p"
,
tsMPeer
WP
.
maxNum
,
tsMPeerQset
);
return
0
;
return
0
;
}
}
void
dnodeCleanupM
node
Peer
()
{
void
dnodeCleanupMPeer
()
{
for
(
int32_t
i
=
0
;
i
<
tsMPeer
Pool
.
maxNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tsMPeer
WP
.
maxNum
;
++
i
)
{
SMPeerWorker
*
pWorker
=
tsMPeer
Pool
.
peerW
orker
+
i
;
SMPeerWorker
*
pWorker
=
tsMPeer
WP
.
w
orker
+
i
;
if
(
pWorker
->
thread
)
{
if
(
pWorker
->
thread
)
{
taosQsetThreadResume
(
tsMPeerQset
);
taosQsetThreadResume
(
tsMPeerQset
);
}
}
dDebug
(
"dnode mpeer worker:%d is closed"
,
i
);
dDebug
(
"dnode mpeer worker:%d is closed"
,
i
);
}
}
for
(
int32_t
i
=
0
;
i
<
tsMPeer
Pool
.
maxNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tsMPeer
WP
.
maxNum
;
++
i
)
{
SMPeerWorker
*
pWorker
=
tsMPeer
Pool
.
peerW
orker
+
i
;
SMPeerWorker
*
pWorker
=
tsMPeer
WP
.
w
orker
+
i
;
dDebug
(
"dnode mpeer worker:%d start to join"
,
i
);
dDebug
(
"dnode mpeer worker:%d start to join"
,
i
);
if
(
pWorker
->
thread
)
{
if
(
pWorker
->
thread
)
{
pthread_join
(
pWorker
->
thread
,
NULL
);
pthread_join
(
pWorker
->
thread
,
NULL
);
...
@@ -84,61 +84,60 @@ void dnodeCleanupMnodePeer() {
...
@@ -84,61 +84,60 @@ void dnodeCleanupMnodePeer() {
taosCloseQset
(
tsMPeerQset
);
taosCloseQset
(
tsMPeerQset
);
tsMPeerQset
=
NULL
;
tsMPeerQset
=
NULL
;
taosTFree
(
tsMPeer
Pool
.
peerW
orker
);
taosTFree
(
tsMPeer
WP
.
w
orker
);
}
}
int32_t
dnodeAllocateM
nodePq
ueue
()
{
int32_t
dnodeAllocateM
PeerQ
ueue
()
{
tsMPeerQueue
=
taosOpenQueue
();
tsMPeerQueue
=
taosOpenQueue
();
if
(
tsMPeerQueue
==
NULL
)
return
TSDB_CODE_DND_OUT_OF_MEMORY
;
if
(
tsMPeerQueue
==
NULL
)
return
TSDB_CODE_DND_OUT_OF_MEMORY
;
taosAddIntoQset
(
tsMPeerQset
,
tsMPeerQueue
,
NULL
);
taosAddIntoQset
(
tsMPeerQset
,
tsMPeerQueue
,
NULL
);
for
(
int32_t
i
=
tsMPeer
Pool
.
curNum
;
i
<
tsMPeerPool
.
maxNum
;
++
i
)
{
for
(
int32_t
i
=
tsMPeer
WP
.
curNum
;
i
<
tsMPeerWP
.
maxNum
;
++
i
)
{
SMPeerWorker
*
pWorker
=
tsMPeer
Pool
.
peerW
orker
+
i
;
SMPeerWorker
*
pWorker
=
tsMPeer
WP
.
w
orker
+
i
;
pWorker
->
workerId
=
i
;
pWorker
->
workerId
=
i
;
pthread_attr_t
thAttr
;
pthread_attr_t
thAttr
;
pthread_attr_init
(
&
thAttr
);
pthread_attr_init
(
&
thAttr
);
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
if
(
pthread_create
(
&
pWorker
->
thread
,
&
thAttr
,
dnodeProcessM
node
PeerQueue
,
pWorker
)
!=
0
)
{
if
(
pthread_create
(
&
pWorker
->
thread
,
&
thAttr
,
dnodeProcessMPeerQueue
,
pWorker
)
!=
0
)
{
dError
(
"failed to create thread to process mpeer queue, reason:%s"
,
strerror
(
errno
));
dError
(
"failed to create thread to process mpeer queue, reason:%s"
,
strerror
(
errno
));
}
}
pthread_attr_destroy
(
&
thAttr
);
pthread_attr_destroy
(
&
thAttr
);
tsMPeer
Pool
.
curNum
=
i
+
1
;
tsMPeer
WP
.
curNum
=
i
+
1
;
dDebug
(
"dnode mpeer worker:%d is launched, total:%d"
,
pWorker
->
workerId
,
tsMPeer
Pool
.
maxNum
);
dDebug
(
"dnode mpeer worker:%d is launched, total:%d"
,
pWorker
->
workerId
,
tsMPeer
WP
.
maxNum
);
}
}
dDebug
(
"dnode mpeer queue:%p is allocated"
,
tsMPeerQueue
);
dDebug
(
"dnode mpeer queue:%p is allocated"
,
tsMPeerQueue
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
void
dnodeFreeM
nodePq
ueue
()
{
void
dnodeFreeM
PeerQ
ueue
()
{
dDebug
(
"dnode mpeer queue:%p is freed"
,
tsMPeerQueue
);
dDebug
(
"dnode mpeer queue:%p is freed"
,
tsMPeerQueue
);
taosCloseQueue
(
tsMPeerQueue
);
taosCloseQueue
(
tsMPeerQueue
);
tsMPeerQueue
=
NULL
;
tsMPeerQueue
=
NULL
;
}
}
void
dnodeDispatchToM
node
PeerQueue
(
SRpcMsg
*
pMsg
)
{
void
dnodeDispatchToMPeerQueue
(
SRpcMsg
*
pMsg
)
{
if
(
!
mnodeIsRunning
()
||
tsMPeerQueue
==
NULL
)
{
if
(
!
mnodeIsRunning
()
||
tsMPeerQueue
==
NULL
)
{
dnodeSendRedirectMsg
(
pMsg
,
false
);
dnodeSendRedirectMsg
(
pMsg
,
false
);
rpcFreeCont
(
pMsg
->
pCont
);
}
else
{
return
;
SMnodeMsg
*
pPeer
=
mnodeCreateMsg
(
pMsg
);
taosWriteQitem
(
tsMPeerQueue
,
TAOS_QTYPE_RPC
,
pPeer
);
}
}
SMnodeMsg
*
pPeer
=
(
SMnodeMsg
*
)
taosAllocateQitem
(
sizeof
(
SMnodeMsg
));
rpcFreeCont
(
pMsg
->
pCont
);
mnodeCreateMsg
(
pPeer
,
pMsg
);
taosWriteQitem
(
tsMPeerQueue
,
TAOS_QTYPE_RPC
,
pPeer
);
}
}
static
void
dnodeFreeM
node
PeerMsg
(
SMnodeMsg
*
pPeer
)
{
static
void
dnodeFreeMPeerMsg
(
SMnodeMsg
*
pPeer
)
{
mnodeCleanupMsg
(
pPeer
);
mnodeCleanupMsg
(
pPeer
);
taosFreeQitem
(
pPeer
);
taosFreeQitem
(
pPeer
);
}
}
static
void
dnodeSendRpcM
node
PeerRsp
(
SMnodeMsg
*
pPeer
,
int32_t
code
)
{
static
void
dnodeSendRpcMPeerRsp
(
SMnodeMsg
*
pPeer
,
int32_t
code
)
{
if
(
code
==
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
return
;
SRpcMsg
rpcRsp
=
{
SRpcMsg
rpcRsp
=
{
...
@@ -149,10 +148,10 @@ static void dnodeSendRpcMnodePeerRsp(SMnodeMsg *pPeer, int32_t code) {
...
@@ -149,10 +148,10 @@ static void dnodeSendRpcMnodePeerRsp(SMnodeMsg *pPeer, int32_t code) {
};
};
rpcSendResponse
(
&
rpcRsp
);
rpcSendResponse
(
&
rpcRsp
);
dnodeFreeM
node
PeerMsg
(
pPeer
);
dnodeFreeMPeerMsg
(
pPeer
);
}
}
static
void
*
dnodeProcessM
node
PeerQueue
(
void
*
param
)
{
static
void
*
dnodeProcessMPeerQueue
(
void
*
param
)
{
SMnodeMsg
*
pPeerMsg
;
SMnodeMsg
*
pPeerMsg
;
int32_t
type
;
int32_t
type
;
void
*
unUsed
;
void
*
unUsed
;
...
@@ -165,7 +164,7 @@ static void *dnodeProcessMnodePeerQueue(void *param) {
...
@@ -165,7 +164,7 @@ static void *dnodeProcessMnodePeerQueue(void *param) {
dDebug
(
"msg:%s will be processed in mpeer queue"
,
taosMsg
[
pPeerMsg
->
rpcMsg
.
msgType
]);
dDebug
(
"msg:%s will be processed in mpeer queue"
,
taosMsg
[
pPeerMsg
->
rpcMsg
.
msgType
]);
int32_t
code
=
mnodeProcessPeerReq
(
pPeerMsg
);
int32_t
code
=
mnodeProcessPeerReq
(
pPeerMsg
);
dnodeSendRpcM
node
PeerRsp
(
pPeerMsg
,
code
);
dnodeSendRpcMPeerRsp
(
pPeerMsg
,
code
);
}
}
return
NULL
;
return
NULL
;
...
...
src/dnode/src/dnodeMRead.c
浏览文件 @
83d2acd5
...
@@ -35,46 +35,46 @@ typedef struct {
...
@@ -35,46 +35,46 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int32_t
curNum
;
int32_t
curNum
;
int32_t
maxNum
;
int32_t
maxNum
;
SMReadWorker
*
readW
orker
;
SMReadWorker
*
w
orker
;
}
SMReadWorkerPool
;
}
SMReadWorkerPool
;
static
SMReadWorkerPool
tsMRead
Pool
;
static
SMReadWorkerPool
tsMRead
WP
;
static
taos_qset
tsMReadQset
;
static
taos_qset
tsMReadQset
;
static
taos_queue
tsMReadQueue
;
static
taos_queue
tsMReadQueue
;
static
void
*
dnodeProcessM
node
ReadQueue
(
void
*
param
);
static
void
*
dnodeProcessMReadQueue
(
void
*
param
);
int32_t
dnodeInitM
node
Read
()
{
int32_t
dnodeInitMRead
()
{
tsMReadQset
=
taosOpenQset
();
tsMReadQset
=
taosOpenQset
();
tsMRead
Pool
.
maxNum
=
tsNumOfCores
*
tsNumOfThreadsPerCore
/
2
;
tsMRead
WP
.
maxNum
=
tsNumOfCores
*
tsNumOfThreadsPerCore
/
2
;
tsMRead
Pool
.
maxNum
=
MAX
(
2
,
tsMReadPool
.
maxNum
);
tsMRead
WP
.
maxNum
=
MAX
(
2
,
tsMReadWP
.
maxNum
);
tsMRead
Pool
.
maxNum
=
MIN
(
4
,
tsMReadPool
.
maxNum
);
tsMRead
WP
.
maxNum
=
MIN
(
4
,
tsMReadWP
.
maxNum
);
tsMRead
Pool
.
curNum
=
0
;
tsMRead
WP
.
curNum
=
0
;
tsMRead
Pool
.
readWorker
=
(
SMReadWorker
*
)
calloc
(
sizeof
(
SMReadWorker
),
tsMReadPool
.
maxNum
);
tsMRead
WP
.
worker
=
(
SMReadWorker
*
)
calloc
(
sizeof
(
SMReadWorker
),
tsMReadWP
.
maxNum
);
if
(
tsMRead
Pool
.
readW
orker
==
NULL
)
return
-
1
;
if
(
tsMRead
WP
.
w
orker
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
tsMRead
Pool
.
maxNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tsMRead
WP
.
maxNum
;
++
i
)
{
SMReadWorker
*
pWorker
=
tsMRead
Pool
.
readW
orker
+
i
;
SMReadWorker
*
pWorker
=
tsMRead
WP
.
w
orker
+
i
;
pWorker
->
workerId
=
i
;
pWorker
->
workerId
=
i
;
dDebug
(
"dnode mread worker:%d is created"
,
i
);
dDebug
(
"dnode mread worker:%d is created"
,
i
);
}
}
dDebug
(
"dnode mread is initialized, workers:%d qset:%p"
,
tsMRead
Pool
.
maxNum
,
tsMReadQset
);
dDebug
(
"dnode mread is initialized, workers:%d qset:%p"
,
tsMRead
WP
.
maxNum
,
tsMReadQset
);
return
0
;
return
0
;
}
}
void
dnodeCleanupM
node
Read
()
{
void
dnodeCleanupMRead
()
{
for
(
int32_t
i
=
0
;
i
<
tsMRead
Pool
.
maxNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tsMRead
WP
.
maxNum
;
++
i
)
{
SMReadWorker
*
pWorker
=
tsMRead
Pool
.
readW
orker
+
i
;
SMReadWorker
*
pWorker
=
tsMRead
WP
.
w
orker
+
i
;
if
(
pWorker
->
thread
)
{
if
(
pWorker
->
thread
)
{
taosQsetThreadResume
(
tsMReadQset
);
taosQsetThreadResume
(
tsMReadQset
);
}
}
dDebug
(
"dnode mread worker:%d is closed"
,
i
);
dDebug
(
"dnode mread worker:%d is closed"
,
i
);
}
}
for
(
int32_t
i
=
0
;
i
<
tsMRead
Pool
.
maxNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tsMRead
WP
.
maxNum
;
++
i
)
{
SMReadWorker
*
pWorker
=
tsMRead
Pool
.
readW
orker
+
i
;
SMReadWorker
*
pWorker
=
tsMRead
WP
.
w
orker
+
i
;
dDebug
(
"dnode mread worker:%d start to join"
,
i
);
dDebug
(
"dnode mread worker:%d start to join"
,
i
);
if
(
pWorker
->
thread
)
{
if
(
pWorker
->
thread
)
{
pthread_join
(
pWorker
->
thread
,
NULL
);
pthread_join
(
pWorker
->
thread
,
NULL
);
...
@@ -86,64 +86,63 @@ void dnodeCleanupMnodeRead() {
...
@@ -86,64 +86,63 @@ void dnodeCleanupMnodeRead() {
taosCloseQset
(
tsMReadQset
);
taosCloseQset
(
tsMReadQset
);
tsMReadQset
=
NULL
;
tsMReadQset
=
NULL
;
free
(
tsMRead
Pool
.
readW
orker
);
free
(
tsMRead
WP
.
w
orker
);
}
}
int32_t
dnodeAlloc
ateMnodeRq
ueue
()
{
int32_t
dnodeAlloc
MReadQ
ueue
()
{
tsMReadQueue
=
taosOpenQueue
();
tsMReadQueue
=
taosOpenQueue
();
if
(
tsMReadQueue
==
NULL
)
return
TSDB_CODE_DND_OUT_OF_MEMORY
;
if
(
tsMReadQueue
==
NULL
)
return
TSDB_CODE_DND_OUT_OF_MEMORY
;
taosAddIntoQset
(
tsMReadQset
,
tsMReadQueue
,
NULL
);
taosAddIntoQset
(
tsMReadQset
,
tsMReadQueue
,
NULL
);
for
(
int32_t
i
=
tsMRead
Pool
.
curNum
;
i
<
tsMReadPool
.
maxNum
;
++
i
)
{
for
(
int32_t
i
=
tsMRead
WP
.
curNum
;
i
<
tsMReadWP
.
maxNum
;
++
i
)
{
SMReadWorker
*
pWorker
=
tsMRead
Pool
.
readW
orker
+
i
;
SMReadWorker
*
pWorker
=
tsMRead
WP
.
w
orker
+
i
;
pWorker
->
workerId
=
i
;
pWorker
->
workerId
=
i
;
pthread_attr_t
thAttr
;
pthread_attr_t
thAttr
;
pthread_attr_init
(
&
thAttr
);
pthread_attr_init
(
&
thAttr
);
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
if
(
pthread_create
(
&
pWorker
->
thread
,
&
thAttr
,
dnodeProcessM
node
ReadQueue
,
pWorker
)
!=
0
)
{
if
(
pthread_create
(
&
pWorker
->
thread
,
&
thAttr
,
dnodeProcessMReadQueue
,
pWorker
)
!=
0
)
{
dError
(
"failed to create thread to process mread queue, reason:%s"
,
strerror
(
errno
));
dError
(
"failed to create thread to process mread queue, reason:%s"
,
strerror
(
errno
));
}
}
pthread_attr_destroy
(
&
thAttr
);
pthread_attr_destroy
(
&
thAttr
);
tsMRead
Pool
.
curNum
=
i
+
1
;
tsMRead
WP
.
curNum
=
i
+
1
;
dDebug
(
"dnode mread worker:%d is launched, total:%d"
,
pWorker
->
workerId
,
tsMRead
Pool
.
maxNum
);
dDebug
(
"dnode mread worker:%d is launched, total:%d"
,
pWorker
->
workerId
,
tsMRead
WP
.
maxNum
);
}
}
dDebug
(
"dnode mread queue:%p is allocated"
,
tsMReadQueue
);
dDebug
(
"dnode mread queue:%p is allocated"
,
tsMReadQueue
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
void
dnodeFreeM
nodeRq
ueue
()
{
void
dnodeFreeM
ReadQ
ueue
()
{
dDebug
(
"dnode mread queue:%p is freed"
,
tsMReadQueue
);
dDebug
(
"dnode mread queue:%p is freed"
,
tsMReadQueue
);
taosCloseQueue
(
tsMReadQueue
);
taosCloseQueue
(
tsMReadQueue
);
tsMReadQueue
=
NULL
;
tsMReadQueue
=
NULL
;
}
}
void
dnodeDispatchToM
node
ReadQueue
(
SRpcMsg
*
pMsg
)
{
void
dnodeDispatchToMReadQueue
(
SRpcMsg
*
pMsg
)
{
if
(
!
mnodeIsRunning
()
||
tsMReadQueue
==
NULL
)
{
if
(
!
mnodeIsRunning
()
||
tsMReadQueue
==
NULL
)
{
dnodeSendRedirectMsg
(
pMsg
,
true
);
dnodeSendRedirectMsg
(
pMsg
,
true
);
rpcFreeCont
(
pMsg
->
pCont
);
}
else
{
return
;
SMnodeMsg
*
pRead
=
mnodeCreateMsg
(
pMsg
);
taosWriteQitem
(
tsMReadQueue
,
TAOS_QTYPE_RPC
,
pRead
);
}
}
SMnodeMsg
*
pRead
=
(
SMnodeMsg
*
)
taosAllocateQitem
(
sizeof
(
SMnodeMsg
));
rpcFreeCont
(
pMsg
->
pCont
);
mnodeCreateMsg
(
pRead
,
pMsg
);
taosWriteQitem
(
tsMReadQueue
,
TAOS_QTYPE_RPC
,
pRead
);
}
}
static
void
dnodeFreeM
node
ReadMsg
(
SMnodeMsg
*
pRead
)
{
static
void
dnodeFreeMReadMsg
(
SMnodeMsg
*
pRead
)
{
mnodeCleanupMsg
(
pRead
);
mnodeCleanupMsg
(
pRead
);
taosFreeQitem
(
pRead
);
taosFreeQitem
(
pRead
);
}
}
static
void
dnodeSendRpcM
node
ReadRsp
(
SMnodeMsg
*
pRead
,
int32_t
code
)
{
static
void
dnodeSendRpcMReadRsp
(
SMnodeMsg
*
pRead
,
int32_t
code
)
{
if
(
code
==
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_MND_ACTION_NEED_REPROCESSED
)
{
if
(
code
==
TSDB_CODE_MND_ACTION_NEED_REPROCESSED
)
{
// may be a auto create req, should put into write queue
// may be a auto create req, should put into write queue
dnodeReprocessM
node
WriteMsg
(
pRead
);
dnodeReprocessMWriteMsg
(
pRead
);
return
;
return
;
}
}
...
@@ -155,23 +154,23 @@ static void dnodeSendRpcMnodeReadRsp(SMnodeMsg *pRead, int32_t code) {
...
@@ -155,23 +154,23 @@ static void dnodeSendRpcMnodeReadRsp(SMnodeMsg *pRead, int32_t code) {
};
};
rpcSendResponse
(
&
rpcRsp
);
rpcSendResponse
(
&
rpcRsp
);
dnodeFreeM
node
ReadMsg
(
pRead
);
dnodeFreeMReadMsg
(
pRead
);
}
}
static
void
*
dnodeProcessM
node
ReadQueue
(
void
*
param
)
{
static
void
*
dnodeProcessMReadQueue
(
void
*
param
)
{
SMnodeMsg
*
pRead
Msg
;
SMnodeMsg
*
pRead
;
int32_t
type
;
int32_t
type
;
void
*
unUsed
;
void
*
unUsed
;
while
(
1
)
{
while
(
1
)
{
if
(
taosReadQitemFromQset
(
tsMReadQset
,
&
type
,
(
void
**
)
&
pRead
Msg
,
&
unUsed
)
==
0
)
{
if
(
taosReadQitemFromQset
(
tsMReadQset
,
&
type
,
(
void
**
)
&
pRead
,
&
unUsed
)
==
0
)
{
dDebug
(
"qset:%p, mnode read got no message from qset, exiting"
,
tsMReadQset
);
dDebug
(
"qset:%p, mnode read got no message from qset, exiting"
,
tsMReadQset
);
break
;
break
;
}
}
dDebug
(
"%p, msg:%s will be processed in mread queue"
,
pRead
Msg
->
rpcMsg
.
ahandle
,
taosMsg
[
pReadMsg
->
rpcMsg
.
msgType
]);
dDebug
(
"%p, msg:%s will be processed in mread queue"
,
pRead
->
rpcMsg
.
ahandle
,
taosMsg
[
pRead
->
rpcMsg
.
msgType
]);
int32_t
code
=
mnodeProcessRead
(
pRead
Msg
);
int32_t
code
=
mnodeProcessRead
(
pRead
);
dnodeSendRpcM
nodeReadRsp
(
pReadMsg
,
code
);
dnodeSendRpcM
ReadRsp
(
pRead
,
code
);
}
}
return
NULL
;
return
NULL
;
...
...
src/dnode/src/dnodeMWrite.c
浏览文件 @
83d2acd5
...
@@ -36,45 +36,45 @@ typedef struct {
...
@@ -36,45 +36,45 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int32_t
curNum
;
int32_t
curNum
;
int32_t
maxNum
;
int32_t
maxNum
;
SMWriteWorker
*
w
riteW
orker
;
SMWriteWorker
*
worker
;
}
SMWriteWorkerPool
;
}
SMWriteWorkerPool
;
static
SMWriteWorkerPool
tsMWrite
Pool
;
static
SMWriteWorkerPool
tsMWrite
WP
;
static
taos_qset
tsMWriteQset
;
static
taos_qset
tsMWriteQset
;
static
taos_queue
tsMWriteQueue
;
static
taos_queue
tsMWriteQueue
;
extern
void
*
tsDnodeTmr
;
extern
void
*
tsDnodeTmr
;
static
void
*
dnodeProcessM
node
WriteQueue
(
void
*
param
);
static
void
*
dnodeProcessMWriteQueue
(
void
*
param
);
int32_t
dnodeInitM
node
Write
()
{
int32_t
dnodeInitMWrite
()
{
tsMWriteQset
=
taosOpenQset
();
tsMWriteQset
=
taosOpenQset
();
tsMWrite
Pool
.
maxNum
=
1
;
tsMWrite
WP
.
maxNum
=
1
;
tsMWrite
Pool
.
curNum
=
0
;
tsMWrite
WP
.
curNum
=
0
;
tsMWrite
Pool
.
writeWorker
=
(
SMWriteWorker
*
)
calloc
(
sizeof
(
SMWriteWorker
),
tsMWritePool
.
maxNum
);
tsMWrite
WP
.
worker
=
(
SMWriteWorker
*
)
calloc
(
sizeof
(
SMWriteWorker
),
tsMWriteWP
.
maxNum
);
if
(
tsMWrite
Pool
.
writeW
orker
==
NULL
)
return
-
1
;
if
(
tsMWrite
WP
.
w
orker
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
tsMWrite
Pool
.
maxNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tsMWrite
WP
.
maxNum
;
++
i
)
{
SMWriteWorker
*
pWorker
=
tsMWrite
Pool
.
writeW
orker
+
i
;
SMWriteWorker
*
pWorker
=
tsMWrite
WP
.
w
orker
+
i
;
pWorker
->
workerId
=
i
;
pWorker
->
workerId
=
i
;
dDebug
(
"dnode mwrite worker:%d is created"
,
i
);
dDebug
(
"dnode mwrite worker:%d is created"
,
i
);
}
}
dDebug
(
"dnode mwrite is initialized, workers:%d qset:%p"
,
tsMWrite
Pool
.
maxNum
,
tsMWriteQset
);
dDebug
(
"dnode mwrite is initialized, workers:%d qset:%p"
,
tsMWrite
WP
.
maxNum
,
tsMWriteQset
);
return
0
;
return
0
;
}
}
void
dnodeCleanupM
node
Write
()
{
void
dnodeCleanupMWrite
()
{
for
(
int32_t
i
=
0
;
i
<
tsMWrite
Pool
.
maxNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tsMWrite
WP
.
maxNum
;
++
i
)
{
SMWriteWorker
*
pWorker
=
tsMWrite
Pool
.
writeW
orker
+
i
;
SMWriteWorker
*
pWorker
=
tsMWrite
WP
.
w
orker
+
i
;
if
(
pWorker
->
thread
)
{
if
(
pWorker
->
thread
)
{
taosQsetThreadResume
(
tsMWriteQset
);
taosQsetThreadResume
(
tsMWriteQset
);
}
}
dDebug
(
"dnode mwrite worker:%d is closed"
,
i
);
dDebug
(
"dnode mwrite worker:%d is closed"
,
i
);
}
}
for
(
int32_t
i
=
0
;
i
<
tsMWrite
Pool
.
maxNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tsMWrite
WP
.
maxNum
;
++
i
)
{
SMWriteWorker
*
pWorker
=
tsMWrite
Pool
.
writeW
orker
+
i
;
SMWriteWorker
*
pWorker
=
tsMWrite
WP
.
w
orker
+
i
;
dDebug
(
"dnode mwrite worker:%d start to join"
,
i
);
dDebug
(
"dnode mwrite worker:%d start to join"
,
i
);
if
(
pWorker
->
thread
)
{
if
(
pWorker
->
thread
)
{
pthread_join
(
pWorker
->
thread
,
NULL
);
pthread_join
(
pWorker
->
thread
,
NULL
);
...
@@ -86,58 +86,56 @@ void dnodeCleanupMnodeWrite() {
...
@@ -86,58 +86,56 @@ void dnodeCleanupMnodeWrite() {
taosCloseQset
(
tsMWriteQset
);
taosCloseQset
(
tsMWriteQset
);
tsMWriteQset
=
NULL
;
tsMWriteQset
=
NULL
;
taosTFree
(
tsMWrite
Pool
.
writeW
orker
);
taosTFree
(
tsMWrite
WP
.
w
orker
);
}
}
int32_t
dnodeAlloc
ateMnodeW
queue
()
{
int32_t
dnodeAlloc
MWrite
queue
()
{
tsMWriteQueue
=
taosOpenQueue
();
tsMWriteQueue
=
taosOpenQueue
();
if
(
tsMWriteQueue
==
NULL
)
return
TSDB_CODE_DND_OUT_OF_MEMORY
;
if
(
tsMWriteQueue
==
NULL
)
return
TSDB_CODE_DND_OUT_OF_MEMORY
;
taosAddIntoQset
(
tsMWriteQset
,
tsMWriteQueue
,
NULL
);
taosAddIntoQset
(
tsMWriteQset
,
tsMWriteQueue
,
NULL
);
for
(
int32_t
i
=
tsMWrite
Pool
.
curNum
;
i
<
tsMWritePool
.
maxNum
;
++
i
)
{
for
(
int32_t
i
=
tsMWrite
WP
.
curNum
;
i
<
tsMWriteWP
.
maxNum
;
++
i
)
{
SMWriteWorker
*
pWorker
=
tsMWrite
Pool
.
writeW
orker
+
i
;
SMWriteWorker
*
pWorker
=
tsMWrite
WP
.
w
orker
+
i
;
pWorker
->
workerId
=
i
;
pWorker
->
workerId
=
i
;
pthread_attr_t
thAttr
;
pthread_attr_t
thAttr
;
pthread_attr_init
(
&
thAttr
);
pthread_attr_init
(
&
thAttr
);
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
if
(
pthread_create
(
&
pWorker
->
thread
,
&
thAttr
,
dnodeProcessM
node
WriteQueue
,
pWorker
)
!=
0
)
{
if
(
pthread_create
(
&
pWorker
->
thread
,
&
thAttr
,
dnodeProcessMWriteQueue
,
pWorker
)
!=
0
)
{
dError
(
"failed to create thread to process mwrite queue, reason:%s"
,
strerror
(
errno
));
dError
(
"failed to create thread to process mwrite queue, reason:%s"
,
strerror
(
errno
));
}
}
pthread_attr_destroy
(
&
thAttr
);
pthread_attr_destroy
(
&
thAttr
);
tsMWrite
Pool
.
curNum
=
i
+
1
;
tsMWrite
WP
.
curNum
=
i
+
1
;
dDebug
(
"dnode mwrite worker:%d is launched, total:%d"
,
pWorker
->
workerId
,
tsMWrite
Pool
.
maxNum
);
dDebug
(
"dnode mwrite worker:%d is launched, total:%d"
,
pWorker
->
workerId
,
tsMWrite
WP
.
maxNum
);
}
}
dDebug
(
"dnode mwrite queue:%p is allocated"
,
tsMWriteQueue
);
dDebug
(
"dnode mwrite queue:%p is allocated"
,
tsMWriteQueue
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
void
dnodeFreeM
nodeW
queue
()
{
void
dnodeFreeM
Write
queue
()
{
dDebug
(
"dnode mwrite queue:%p is freed"
,
tsMWriteQueue
);
dDebug
(
"dnode mwrite queue:%p is freed"
,
tsMWriteQueue
);
taosCloseQueue
(
tsMWriteQueue
);
taosCloseQueue
(
tsMWriteQueue
);
tsMWriteQueue
=
NULL
;
tsMWriteQueue
=
NULL
;
}
}
void
dnodeDispatchToM
node
WriteQueue
(
SRpcMsg
*
pMsg
)
{
void
dnodeDispatchToMWriteQueue
(
SRpcMsg
*
pMsg
)
{
if
(
!
mnodeIsRunning
()
||
tsMWriteQueue
==
NULL
)
{
if
(
!
mnodeIsRunning
()
||
tsMWriteQueue
==
NULL
)
{
dnodeSendRedirectMsg
(
pMsg
,
true
);
dnodeSendRedirectMsg
(
pMsg
,
true
);
rpcFreeCont
(
pMsg
->
pCont
);
}
else
{
return
;
SMnodeMsg
*
pWrite
=
mnodeCreateMsg
(
pMsg
);
}
SMnodeMsg
*
pWrite
=
(
SMnodeMsg
*
)
taosAllocateQitem
(
sizeof
(
SMnodeMsg
));
mnodeCreateMsg
(
pWrite
,
pMsg
);
dDebug
(
"app:%p:%p, msg:%s is put into mwrite queue:%p"
,
pWrite
->
rpcMsg
.
ahandle
,
pWrite
,
dDebug
(
"app:%p:%p, msg:%s is put into mwrite queue:%p"
,
pWrite
->
rpcMsg
.
ahandle
,
pWrite
,
taosMsg
[
pWrite
->
rpcMsg
.
msgType
],
tsMWriteQueue
);
taosMsg
[
pWrite
->
rpcMsg
.
msgType
],
tsMWriteQueue
);
taosWriteQitem
(
tsMWriteQueue
,
TAOS_QTYPE_RPC
,
pWrite
);
taosWriteQitem
(
tsMWriteQueue
,
TAOS_QTYPE_RPC
,
pWrite
);
}
rpcFreeCont
(
pMsg
->
pCont
);
}
}
static
void
dnodeFreeM
node
WriteMsg
(
SMnodeMsg
*
pWrite
)
{
static
void
dnodeFreeMWriteMsg
(
SMnodeMsg
*
pWrite
)
{
dDebug
(
"app:%p:%p, msg:%s is freed from mwrite queue:%p"
,
pWrite
->
rpcMsg
.
ahandle
,
pWrite
,
dDebug
(
"app:%p:%p, msg:%s is freed from mwrite queue:%p"
,
pWrite
->
rpcMsg
.
ahandle
,
pWrite
,
taosMsg
[
pWrite
->
rpcMsg
.
msgType
],
tsMWriteQueue
);
taosMsg
[
pWrite
->
rpcMsg
.
msgType
],
tsMWriteQueue
);
...
@@ -145,12 +143,12 @@ static void dnodeFreeMnodeWriteMsg(SMnodeMsg *pWrite) {
...
@@ -145,12 +143,12 @@ static void dnodeFreeMnodeWriteMsg(SMnodeMsg *pWrite) {
taosFreeQitem
(
pWrite
);
taosFreeQitem
(
pWrite
);
}
}
void
dnodeSendRpcM
node
WriteRsp
(
void
*
pMsg
,
int32_t
code
)
{
void
dnodeSendRpcMWriteRsp
(
void
*
pMsg
,
int32_t
code
)
{
SMnodeMsg
*
pWrite
=
pMsg
;
SMnodeMsg
*
pWrite
=
pMsg
;
if
(
pWrite
==
NULL
)
return
;
if
(
pWrite
==
NULL
)
return
;
if
(
code
==
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_MND_ACTION_NEED_REPROCESSED
)
{
if
(
code
==
TSDB_CODE_MND_ACTION_NEED_REPROCESSED
)
{
dnodeReprocessM
node
WriteMsg
(
pWrite
);
dnodeReprocessMWriteMsg
(
pWrite
);
return
;
return
;
}
}
...
@@ -162,10 +160,10 @@ void dnodeSendRpcMnodeWriteRsp(void *pMsg, int32_t code) {
...
@@ -162,10 +160,10 @@ void dnodeSendRpcMnodeWriteRsp(void *pMsg, int32_t code) {
};
};
rpcSendResponse
(
&
rpcRsp
);
rpcSendResponse
(
&
rpcRsp
);
dnodeFreeM
node
WriteMsg
(
pWrite
);
dnodeFreeMWriteMsg
(
pWrite
);
}
}
static
void
*
dnodeProcessM
node
WriteQueue
(
void
*
param
)
{
static
void
*
dnodeProcessMWriteQueue
(
void
*
param
)
{
SMnodeMsg
*
pWrite
;
SMnodeMsg
*
pWrite
;
int32_t
type
;
int32_t
type
;
void
*
unUsed
;
void
*
unUsed
;
...
@@ -180,13 +178,13 @@ static void *dnodeProcessMnodeWriteQueue(void *param) {
...
@@ -180,13 +178,13 @@ static void *dnodeProcessMnodeWriteQueue(void *param) {
taosMsg
[
pWrite
->
rpcMsg
.
msgType
]);
taosMsg
[
pWrite
->
rpcMsg
.
msgType
]);
int32_t
code
=
mnodeProcessWrite
(
pWrite
);
int32_t
code
=
mnodeProcessWrite
(
pWrite
);
dnodeSendRpcM
node
WriteRsp
(
pWrite
,
code
);
dnodeSendRpcMWriteRsp
(
pWrite
,
code
);
}
}
return
NULL
;
return
NULL
;
}
}
void
dnodeReprocessM
node
WriteMsg
(
void
*
pMsg
)
{
void
dnodeReprocessMWriteMsg
(
void
*
pMsg
)
{
SMnodeMsg
*
pWrite
=
pMsg
;
SMnodeMsg
*
pWrite
=
pMsg
;
if
(
!
mnodeIsRunning
()
||
tsMWriteQueue
==
NULL
)
{
if
(
!
mnodeIsRunning
()
||
tsMWriteQueue
==
NULL
)
{
...
@@ -194,7 +192,7 @@ void dnodeReprocessMnodeWriteMsg(void *pMsg) {
...
@@ -194,7 +192,7 @@ void dnodeReprocessMnodeWriteMsg(void *pMsg) {
taosMsg
[
pWrite
->
rpcMsg
.
msgType
],
pWrite
->
retry
);
taosMsg
[
pWrite
->
rpcMsg
.
msgType
],
pWrite
->
retry
);
dnodeSendRedirectMsg
(
pMsg
,
true
);
dnodeSendRedirectMsg
(
pMsg
,
true
);
dnodeFreeM
node
WriteMsg
(
pWrite
);
dnodeFreeMWriteMsg
(
pWrite
);
}
else
{
}
else
{
dDebug
(
"app:%p:%p, msg:%s is reput into mwrite queue:%p, retry times:%d"
,
pWrite
->
rpcMsg
.
ahandle
,
pWrite
,
dDebug
(
"app:%p:%p, msg:%s is reput into mwrite queue:%p, retry times:%d"
,
pWrite
->
rpcMsg
.
ahandle
,
pWrite
,
taosMsg
[
pWrite
->
rpcMsg
.
msgType
],
tsMWriteQueue
,
pWrite
->
retry
);
taosMsg
[
pWrite
->
rpcMsg
.
msgType
],
tsMWriteQueue
,
pWrite
->
retry
);
...
@@ -203,12 +201,12 @@ void dnodeReprocessMnodeWriteMsg(void *pMsg) {
...
@@ -203,12 +201,12 @@ void dnodeReprocessMnodeWriteMsg(void *pMsg) {
}
}
}
}
static
void
dnodeDoDelayReprocessM
node
WriteMsg
(
void
*
param
,
void
*
tmrId
)
{
static
void
dnodeDoDelayReprocessMWriteMsg
(
void
*
param
,
void
*
tmrId
)
{
dnodeReprocessM
node
WriteMsg
(
param
);
dnodeReprocessMWriteMsg
(
param
);
}
}
void
dnodeDelayReprocessM
node
WriteMsg
(
void
*
pMsg
)
{
void
dnodeDelayReprocessMWriteMsg
(
void
*
pMsg
)
{
SMnodeMsg
*
mnodeMsg
=
pMsg
;
SMnodeMsg
*
mnodeMsg
=
pMsg
;
void
*
unUsed
=
NULL
;
void
*
unUsed
=
NULL
;
taosTmrReset
(
dnodeDoDelayReprocessM
node
WriteMsg
,
300
,
mnodeMsg
,
tsDnodeTmr
,
&
unUsed
);
taosTmrReset
(
dnodeDoDelayReprocessMWriteMsg
,
300
,
mnodeMsg
,
tsDnodeTmr
,
&
unUsed
);
}
}
src/dnode/src/dnodeMain.c
浏览文件 @
83d2acd5
...
@@ -37,11 +37,11 @@
...
@@ -37,11 +37,11 @@
#include "dnodeShell.h"
#include "dnodeShell.h"
#include "dnodeTelemetry.h"
#include "dnodeTelemetry.h"
static
S
DnodeRunStatus
tsDnodeRunStatus
=
TSDB_DNODE
_RUN_STATUS_STOPPED
;
static
S
RunStatus
tsRunStatus
=
TSDB
_RUN_STATUS_STOPPED
;
static
int32_t
dnodeInitStorage
();
static
int32_t
dnodeInitStorage
();
static
void
dnodeCleanupStorage
();
static
void
dnodeCleanupStorage
();
static
void
dnodeSetRunStatus
(
S
Dnode
RunStatus
status
);
static
void
dnodeSetRunStatus
(
SRunStatus
status
);
static
void
dnodeCheckDataDirOpenned
(
char
*
dir
);
static
void
dnodeCheckDataDirOpenned
(
char
*
dir
);
static
int32_t
dnodeInitComponents
();
static
int32_t
dnodeInitComponents
();
static
void
dnodeCleanupComponents
(
int32_t
stepId
);
static
void
dnodeCleanupComponents
(
int32_t
stepId
);
...
@@ -63,9 +63,9 @@ static const SDnodeComponent tsDnodeComponents[] = {
...
@@ -63,9 +63,9 @@ static const SDnodeComponent tsDnodeComponents[] = {
{
"check"
,
dnodeInitCheck
,
dnodeCleanupCheck
},
// NOTES: dnodeInitCheck must be behind the dnodeinitStorage component !!!
{
"check"
,
dnodeInitCheck
,
dnodeCleanupCheck
},
// NOTES: dnodeInitCheck must be behind the dnodeinitStorage component !!!
{
"vread"
,
dnodeInitVRead
,
dnodeCleanupVRead
},
{
"vread"
,
dnodeInitVRead
,
dnodeCleanupVRead
},
{
"vwrite"
,
dnodeInitVWrite
,
dnodeCleanupVWrite
},
{
"vwrite"
,
dnodeInitVWrite
,
dnodeCleanupVWrite
},
{
"mread"
,
dnodeInitM
nodeRead
,
dnodeCleanupMnode
Read
},
{
"mread"
,
dnodeInitM
Read
,
dnodeCleanupM
Read
},
{
"mwrite"
,
dnodeInitM
nodeWrite
,
dnodeCleanupMnode
Write
},
{
"mwrite"
,
dnodeInitM
Write
,
dnodeCleanupM
Write
},
{
"mpeer"
,
dnodeInitM
nodePeer
,
dnodeCleanupMnode
Peer
},
{
"mpeer"
,
dnodeInitM
Peer
,
dnodeCleanupM
Peer
},
{
"client"
,
dnodeInitClient
,
dnodeCleanupClient
},
{
"client"
,
dnodeInitClient
,
dnodeCleanupClient
},
{
"server"
,
dnodeInitServer
,
dnodeCleanupServer
},
{
"server"
,
dnodeInitServer
,
dnodeCleanupServer
},
{
"mgmt"
,
dnodeInitMgmt
,
dnodeCleanupMgmt
},
{
"mgmt"
,
dnodeInitMgmt
,
dnodeCleanupMgmt
},
...
@@ -104,7 +104,7 @@ static int32_t dnodeInitComponents() {
...
@@ -104,7 +104,7 @@ static int32_t dnodeInitComponents() {
}
}
int32_t
dnodeInitSystem
()
{
int32_t
dnodeInitSystem
()
{
dnodeSetRunStatus
(
TSDB_
DNODE_
RUN_STATUS_INITIALIZE
);
dnodeSetRunStatus
(
TSDB_RUN_STATUS_INITIALIZE
);
tscEmbedded
=
1
;
tscEmbedded
=
1
;
taosBlockSIGPIPE
();
taosBlockSIGPIPE
();
taosResolveCRC
();
taosResolveCRC
();
...
@@ -137,7 +137,7 @@ int32_t dnodeInitSystem() {
...
@@ -137,7 +137,7 @@ int32_t dnodeInitSystem() {
}
}
dnodeStartModules
();
dnodeStartModules
();
dnodeSetRunStatus
(
TSDB_
DNODE_
RUN_STATUS_RUNING
);
dnodeSetRunStatus
(
TSDB_RUN_STATUS_RUNING
);
dInfo
(
"TDengine is initialized successfully"
);
dInfo
(
"TDengine is initialized successfully"
);
...
@@ -145,20 +145,20 @@ int32_t dnodeInitSystem() {
...
@@ -145,20 +145,20 @@ int32_t dnodeInitSystem() {
}
}
void
dnodeCleanUpSystem
()
{
void
dnodeCleanUpSystem
()
{
if
(
dnodeGetRunStatus
()
!=
TSDB_
DNODE_
RUN_STATUS_STOPPED
)
{
if
(
dnodeGetRunStatus
()
!=
TSDB_RUN_STATUS_STOPPED
)
{
dnodeSetRunStatus
(
TSDB_
DNODE_
RUN_STATUS_STOPPED
);
dnodeSetRunStatus
(
TSDB_RUN_STATUS_STOPPED
);
dnodeCleanupComponents
(
sizeof
(
tsDnodeComponents
)
/
sizeof
(
tsDnodeComponents
[
0
])
-
1
);
dnodeCleanupComponents
(
sizeof
(
tsDnodeComponents
)
/
sizeof
(
tsDnodeComponents
[
0
])
-
1
);
taos_cleanup
();
taos_cleanup
();
taosCloseLog
();
taosCloseLog
();
}
}
}
}
S
Dnode
RunStatus
dnodeGetRunStatus
()
{
SRunStatus
dnodeGetRunStatus
()
{
return
ts
Dnode
RunStatus
;
return
tsRunStatus
;
}
}
static
void
dnodeSetRunStatus
(
S
Dnode
RunStatus
status
)
{
static
void
dnodeSetRunStatus
(
SRunStatus
status
)
{
ts
Dnode
RunStatus
=
status
;
tsRunStatus
=
status
;
}
}
static
void
dnodeCheckDataDirOpenned
(
char
*
dir
)
{
static
void
dnodeCheckDataDirOpenned
(
char
*
dir
)
{
...
...
src/dnode/src/dnodeMgmt.c
浏览文件 @
83d2acd5
...
@@ -47,6 +47,11 @@ typedef struct {
...
@@ -47,6 +47,11 @@ typedef struct {
int32_t
*
vnodeList
;
int32_t
*
vnodeList
;
}
SOpenVnodeThread
;
}
SOpenVnodeThread
;
typedef
struct
{
SRpcMsg
rpcMsg
;
char
pCont
[];
}
SMgmtMsg
;
void
*
tsDnodeTmr
=
NULL
;
void
*
tsDnodeTmr
=
NULL
;
static
void
*
tsStatusTimer
=
NULL
;
static
void
*
tsStatusTimer
=
NULL
;
static
uint32_t
tsRebootTime
;
static
uint32_t
tsRebootTime
;
...
@@ -172,38 +177,46 @@ void dnodeCleanupMgmt() {
...
@@ -172,38 +177,46 @@ void dnodeCleanupMgmt() {
vnodeCleanupResources
();
vnodeCleanupResources
();
}
}
void
dnodeDispatchToMgmtQueue
(
SRpcMsg
*
pMsg
)
{
static
int32_t
dnodeWriteToMgmtQueue
(
SRpcMsg
*
pMsg
)
{
void
*
item
;
int32_t
size
=
sizeof
(
SMgmtMsg
)
+
pMsg
->
contLen
;
SMgmtMsg
*
pMgmt
=
taosAllocateQitem
(
size
);
if
(
pMgmt
==
NULL
)
{
return
TSDB_CODE_DND_OUT_OF_MEMORY
;
}
item
=
taosAllocateQitem
(
sizeof
(
SRpcMsg
));
pMgmt
->
rpcMsg
=
*
pMsg
;
if
(
item
)
{
pMgmt
->
rpcMsg
.
pCont
=
pMgmt
->
pCont
;
memcpy
(
item
,
pMsg
,
sizeof
(
SRpcMsg
));
memcpy
(
pMgmt
->
pCont
,
pMsg
->
pCont
,
pMsg
->
contLen
);
taosWriteQitem
(
tsMgmtQueue
,
1
,
item
);
taosWriteQitem
(
tsMgmtQueue
,
TAOS_QTYPE_RPC
,
pMgmt
);
}
else
{
SRpcMsg
rsp
=
{
.
handle
=
pMsg
->
handle
,
.
pCont
=
NULL
,
.
code
=
TSDB_CODE_DND_OUT_OF_MEMORY
};
return
TSDB_CODE_SUCCESS
;
}
void
dnodeDispatchToMgmtQueue
(
SRpcMsg
*
pMsg
)
{
int32_t
code
=
dnodeWriteToMgmtQueue
(
pMsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
SRpcMsg
rsp
=
{.
handle
=
pMsg
->
handle
,
.
code
=
code
};
rpcSendResponse
(
&
rsp
);
rpcSendResponse
(
&
rsp
);
rpcFreeCont
(
pMsg
->
pCont
);
}
}
rpcFreeCont
(
pMsg
->
pCont
);
}
}
static
void
*
dnodeProcessMgmtQueue
(
void
*
param
)
{
static
void
*
dnodeProcessMgmtQueue
(
void
*
param
)
{
SRpcMsg
*
pMsg
;
SMgmtMsg
*
pMgmt
;
SRpcMsg
*
pMsg
;
SRpcMsg
rsp
=
{
0
};
SRpcMsg
rsp
=
{
0
};
int
type
;
int
32_t
q
type
;
void
*
handle
;
void
*
handle
;
while
(
1
)
{
while
(
1
)
{
if
(
taosReadQitemFromQset
(
tsMgmtQset
,
&
type
,
(
void
**
)
&
pMsg
,
&
handle
)
==
0
)
{
if
(
taosReadQitemFromQset
(
tsMgmtQset
,
&
qtype
,
(
void
**
)
&
pMgmt
,
&
handle
)
==
0
)
{
dDebug
(
"qset:%p, dnode mgmt got no message from qset, exit"
,
tsMgmtQset
);
dDebug
(
"qset:%p, dnode mgmt got no message from qset, exit"
,
tsMgmtQset
);
break
;
break
;
}
}
dDebug
(
"%p, msg:%s will be processed"
,
pMsg
->
ahandle
,
taosMsg
[
pMsg
->
msgType
]);
pMsg
=
&
pMgmt
->
rpcMsg
;
dDebug
(
"%p, msg:%p:%s will be processed"
,
pMsg
->
ahandle
,
pMgmt
,
taosMsg
[
pMsg
->
msgType
]);
if
(
dnodeProcessMgmtMsgFp
[
pMsg
->
msgType
])
{
if
(
dnodeProcessMgmtMsgFp
[
pMsg
->
msgType
])
{
rsp
.
code
=
(
*
dnodeProcessMgmtMsgFp
[
pMsg
->
msgType
])(
pMsg
);
rsp
.
code
=
(
*
dnodeProcessMgmtMsgFp
[
pMsg
->
msgType
])(
pMsg
);
}
else
{
}
else
{
...
@@ -214,7 +227,6 @@ static void *dnodeProcessMgmtQueue(void *param) {
...
@@ -214,7 +227,6 @@ static void *dnodeProcessMgmtQueue(void *param) {
rsp
.
pCont
=
NULL
;
rsp
.
pCont
=
NULL
;
rpcSendResponse
(
&
rsp
);
rpcSendResponse
(
&
rsp
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
taosFreeQitem
(
pMsg
);
}
}
...
...
src/dnode/src/dnodePeer.c
浏览文件 @
83d2acd5
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
* to dnode. All theses messages are handled from here
* to dnode. All theses messages are handled from here
*/
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "taosmsg.h"
#include "taosmsg.h"
#include "tglobal.h"
#include "tglobal.h"
...
@@ -34,8 +35,8 @@ static void (*dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
...
@@ -34,8 +35,8 @@ static void (*dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
static
void
dnodeProcessReqMsgFromDnode
(
SRpcMsg
*
pMsg
,
SRpcEpSet
*
);
static
void
dnodeProcessReqMsgFromDnode
(
SRpcMsg
*
pMsg
,
SRpcEpSet
*
);
static
void
(
*
dnodeProcessRspMsgFp
[
TSDB_MSG_TYPE_MAX
])(
SRpcMsg
*
rpcMsg
);
static
void
(
*
dnodeProcessRspMsgFp
[
TSDB_MSG_TYPE_MAX
])(
SRpcMsg
*
rpcMsg
);
static
void
dnodeProcessRspFromDnode
(
SRpcMsg
*
pMsg
,
SRpcEpSet
*
pEpSet
);
static
void
dnodeProcessRspFromDnode
(
SRpcMsg
*
pMsg
,
SRpcEpSet
*
pEpSet
);
static
void
*
ts
Dnode
ServerRpc
=
NULL
;
static
void
*
tsServerRpc
=
NULL
;
static
void
*
ts
Dnode
ClientRpc
=
NULL
;
static
void
*
tsClientRpc
=
NULL
;
int32_t
dnodeInitServer
()
{
int32_t
dnodeInitServer
()
{
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_CREATE_TABLE
]
=
dnodeDispatchToVWriteQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_CREATE_TABLE
]
=
dnodeDispatchToVWriteQueue
;
...
@@ -50,11 +51,11 @@ int32_t dnodeInitServer() {
...
@@ -50,11 +51,11 @@ int32_t dnodeInitServer() {
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_CONFIG_DNODE
]
=
dnodeDispatchToMgmtQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_CONFIG_DNODE
]
=
dnodeDispatchToMgmtQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_CREATE_MNODE
]
=
dnodeDispatchToMgmtQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_MD_CREATE_MNODE
]
=
dnodeDispatchToMgmtQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_CONFIG_TABLE
]
=
dnodeDispatchToM
node
PeerQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_CONFIG_TABLE
]
=
dnodeDispatchToMPeerQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_CONFIG_VNODE
]
=
dnodeDispatchToM
node
PeerQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_CONFIG_VNODE
]
=
dnodeDispatchToMPeerQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_AUTH
]
=
dnodeDispatchToM
node
PeerQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_AUTH
]
=
dnodeDispatchToMPeerQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_GRANT
]
=
dnodeDispatchToM
node
PeerQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_GRANT
]
=
dnodeDispatchToMPeerQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_STATUS
]
=
dnodeDispatchToM
node
PeerQueue
;
dnodeProcessReqMsgFp
[
TSDB_MSG_TYPE_DM_STATUS
]
=
dnodeDispatchToMPeerQueue
;
SRpcInit
rpcInit
;
SRpcInit
rpcInit
;
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
...
@@ -66,8 +67,8 @@ int32_t dnodeInitServer() {
...
@@ -66,8 +67,8 @@ int32_t dnodeInitServer() {
rpcInit
.
connType
=
TAOS_CONN_SERVER
;
rpcInit
.
connType
=
TAOS_CONN_SERVER
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
ts
Dnode
ServerRpc
=
rpcOpen
(
&
rpcInit
);
tsServerRpc
=
rpcOpen
(
&
rpcInit
);
if
(
ts
Dnode
ServerRpc
==
NULL
)
{
if
(
tsServerRpc
==
NULL
)
{
dError
(
"failed to init inter-dnodes RPC server"
);
dError
(
"failed to init inter-dnodes RPC server"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -77,9 +78,9 @@ int32_t dnodeInitServer() {
...
@@ -77,9 +78,9 @@ int32_t dnodeInitServer() {
}
}
void
dnodeCleanupServer
()
{
void
dnodeCleanupServer
()
{
if
(
ts
Dnode
ServerRpc
)
{
if
(
tsServerRpc
)
{
rpcClose
(
ts
Dnode
ServerRpc
);
rpcClose
(
tsServerRpc
);
ts
Dnode
ServerRpc
=
NULL
;
tsServerRpc
=
NULL
;
dInfo
(
"inter-dnodes RPC server is closed"
);
dInfo
(
"inter-dnodes RPC server is closed"
);
}
}
}
}
...
@@ -93,7 +94,7 @@ static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
...
@@ -93,7 +94,7 @@ static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
if
(
pMsg
->
pCont
==
NULL
)
return
;
if
(
pMsg
->
pCont
==
NULL
)
return
;
if
(
dnodeGetRunStatus
()
!=
TSDB_
DNODE_
RUN_STATUS_RUNING
)
{
if
(
dnodeGetRunStatus
()
!=
TSDB_RUN_STATUS_RUNING
)
{
rspMsg
.
code
=
TSDB_CODE_APP_NOT_READY
;
rspMsg
.
code
=
TSDB_CODE_APP_NOT_READY
;
rpcSendResponse
(
&
rspMsg
);
rpcSendResponse
(
&
rspMsg
);
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
...
@@ -131,8 +132,8 @@ int32_t dnodeInitClient() {
...
@@ -131,8 +132,8 @@ int32_t dnodeInitClient() {
rpcInit
.
ckey
=
"key"
;
rpcInit
.
ckey
=
"key"
;
rpcInit
.
secret
=
secret
;
rpcInit
.
secret
=
secret
;
ts
Dnode
ClientRpc
=
rpcOpen
(
&
rpcInit
);
tsClientRpc
=
rpcOpen
(
&
rpcInit
);
if
(
ts
Dnode
ClientRpc
==
NULL
)
{
if
(
tsClientRpc
==
NULL
)
{
dError
(
"failed to init mnode rpc client"
);
dError
(
"failed to init mnode rpc client"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -142,9 +143,9 @@ int32_t dnodeInitClient() {
...
@@ -142,9 +143,9 @@ int32_t dnodeInitClient() {
}
}
void
dnodeCleanupClient
()
{
void
dnodeCleanupClient
()
{
if
(
ts
Dnode
ClientRpc
)
{
if
(
tsClientRpc
)
{
rpcClose
(
ts
Dnode
ClientRpc
);
rpcClose
(
tsClientRpc
);
ts
Dnode
ClientRpc
=
NULL
;
tsClientRpc
=
NULL
;
dInfo
(
"dnode inter-dnodes rpc client is closed"
);
dInfo
(
"dnode inter-dnodes rpc client is closed"
);
}
}
}
}
...
@@ -168,15 +169,15 @@ void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) {
...
@@ -168,15 +169,15 @@ void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) {
}
}
void
dnodeSendMsgToDnode
(
SRpcEpSet
*
epSet
,
SRpcMsg
*
rpcMsg
)
{
void
dnodeSendMsgToDnode
(
SRpcEpSet
*
epSet
,
SRpcMsg
*
rpcMsg
)
{
rpcSendRequest
(
ts
Dnode
ClientRpc
,
epSet
,
rpcMsg
);
rpcSendRequest
(
tsClientRpc
,
epSet
,
rpcMsg
);
}
}
void
dnodeSendMsgToMnodeRecv
(
SRpcMsg
*
rpcMsg
,
SRpcMsg
*
rpcRsp
)
{
void
dnodeSendMsgToMnodeRecv
(
SRpcMsg
*
rpcMsg
,
SRpcMsg
*
rpcRsp
)
{
SRpcEpSet
epSet
=
{
0
};
SRpcEpSet
epSet
=
{
0
};
dnodeGetEpSetForPeer
(
&
epSet
);
dnodeGetEpSetForPeer
(
&
epSet
);
rpcSendRecv
(
ts
Dnode
ClientRpc
,
&
epSet
,
rpcMsg
,
rpcRsp
);
rpcSendRecv
(
tsClientRpc
,
&
epSet
,
rpcMsg
,
rpcRsp
);
}
}
void
dnodeSendMsgToDnodeRecv
(
SRpcMsg
*
rpcMsg
,
SRpcMsg
*
rpcRsp
,
SRpcEpSet
*
epSet
)
{
void
dnodeSendMsgToDnodeRecv
(
SRpcMsg
*
rpcMsg
,
SRpcMsg
*
rpcRsp
,
SRpcEpSet
*
epSet
)
{
rpcSendRecv
(
ts
Dnode
ClientRpc
,
epSet
,
rpcMsg
,
rpcRsp
);
rpcSendRecv
(
tsClientRpc
,
epSet
,
rpcMsg
,
rpcRsp
);
}
}
\ No newline at end of file
src/dnode/src/dnodeShell.c
浏览文件 @
83d2acd5
...
@@ -33,9 +33,9 @@
...
@@ -33,9 +33,9 @@
static
void
(
*
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_MAX
])(
SRpcMsg
*
);
static
void
(
*
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_MAX
])(
SRpcMsg
*
);
static
void
dnodeProcessMsgFromShell
(
SRpcMsg
*
pMsg
,
SRpcEpSet
*
);
static
void
dnodeProcessMsgFromShell
(
SRpcMsg
*
pMsg
,
SRpcEpSet
*
);
static
int
dnodeRetrieveUserAuthInfo
(
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
static
int
dnodeRetrieveUserAuthInfo
(
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
static
void
*
ts
Dnode
ShellRpc
=
NULL
;
static
void
*
tsShellRpc
=
NULL
;
static
int32_t
ts
Dnode
QueryReqNum
=
0
;
static
int32_t
tsQueryReqNum
=
0
;
static
int32_t
ts
Dnode
SubmitReqNum
=
0
;
static
int32_t
tsSubmitReqNum
=
0
;
int32_t
dnodeInitShell
()
{
int32_t
dnodeInitShell
()
{
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_SUBMIT
]
=
dnodeDispatchToVWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_SUBMIT
]
=
dnodeDispatchToVWriteQueue
;
...
@@ -44,35 +44,35 @@ int32_t dnodeInitShell() {
...
@@ -44,35 +44,35 @@ int32_t dnodeInitShell() {
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_UPDATE_TAG_VAL
]
=
dnodeDispatchToVWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_UPDATE_TAG_VAL
]
=
dnodeDispatchToVWriteQueue
;
// the following message shall be treated as mnode write
// the following message shall be treated as mnode write
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_ACCT
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_ACCT
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_ACCT
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_ACCT
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_ACCT
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_ACCT
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_USER
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_USER
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_USER
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_USER
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_USER
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_USER
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_DNODE
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_DNODE
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_DNODE
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_DNODE
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_DB
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_DB
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_DB
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_DB
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_DB
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_DB
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_TABLE
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_TABLE
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_TABLE
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_TABLE
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_TABLE
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_TABLE
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_STREAM
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_STREAM
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_KILL_QUERY
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_KILL_QUERY
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_KILL_STREAM
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_KILL_STREAM
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_KILL_CONN
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_KILL_CONN
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CONFIG_DNODE
]
=
dnodeDispatchToM
node
WriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CONFIG_DNODE
]
=
dnodeDispatchToMWriteQueue
;
// the following message shall be treated as mnode query
// the following message shall be treated as mnode query
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_HEARTBEAT
]
=
dnodeDispatchToM
node
ReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_HEARTBEAT
]
=
dnodeDispatchToMReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CONNECT
]
=
dnodeDispatchToM
node
ReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CONNECT
]
=
dnodeDispatchToMReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_USE_DB
]
=
dnodeDispatchToM
node
ReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_USE_DB
]
=
dnodeDispatchToMReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_TABLE_META
]
=
dnodeDispatchToM
node
ReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_TABLE_META
]
=
dnodeDispatchToMReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_STABLE_VGROUP
]
=
dnodeDispatchToM
node
ReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_STABLE_VGROUP
]
=
dnodeDispatchToMReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_TABLES_META
]
=
dnodeDispatchToM
node
ReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_TABLES_META
]
=
dnodeDispatchToMReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_SHOW
]
=
dnodeDispatchToM
node
ReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_SHOW
]
=
dnodeDispatchToMReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_RETRIEVE
]
=
dnodeDispatchToM
node
ReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_RETRIEVE
]
=
dnodeDispatchToMReadQueue
;
int32_t
numOfThreads
=
tsNumOfCores
*
tsNumOfThreadsPerCore
;
int32_t
numOfThreads
=
tsNumOfCores
*
tsNumOfThreadsPerCore
;
numOfThreads
=
(
int32_t
)
((
1
.
0
-
tsRatioOfQueryThreads
)
*
numOfThreads
/
2
.
0
);
numOfThreads
=
(
int32_t
)
((
1
.
0
-
tsRatioOfQueryThreads
)
*
numOfThreads
/
2
.
0
);
...
@@ -91,8 +91,8 @@ int32_t dnodeInitShell() {
...
@@ -91,8 +91,8 @@ int32_t dnodeInitShell() {
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
.
idleTime
=
tsShellActivityTimer
*
1000
;
rpcInit
.
afp
=
dnodeRetrieveUserAuthInfo
;
rpcInit
.
afp
=
dnodeRetrieveUserAuthInfo
;
ts
Dnode
ShellRpc
=
rpcOpen
(
&
rpcInit
);
tsShellRpc
=
rpcOpen
(
&
rpcInit
);
if
(
ts
Dnode
ShellRpc
==
NULL
)
{
if
(
tsShellRpc
==
NULL
)
{
dError
(
"failed to init shell rpc server"
);
dError
(
"failed to init shell rpc server"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -102,13 +102,13 @@ int32_t dnodeInitShell() {
...
@@ -102,13 +102,13 @@ int32_t dnodeInitShell() {
}
}
void
dnodeCleanupShell
()
{
void
dnodeCleanupShell
()
{
if
(
ts
Dnode
ShellRpc
)
{
if
(
tsShellRpc
)
{
rpcClose
(
ts
Dnode
ShellRpc
);
rpcClose
(
tsShellRpc
);
ts
Dnode
ShellRpc
=
NULL
;
tsShellRpc
=
NULL
;
}
}
}
}
void
dnodeProcessMsgFromShell
(
SRpcMsg
*
pMsg
,
SRpcEpSet
*
pEpSet
)
{
static
void
dnodeProcessMsgFromShell
(
SRpcMsg
*
pMsg
,
SRpcEpSet
*
pEpSet
)
{
SRpcMsg
rpcMsg
=
{
SRpcMsg
rpcMsg
=
{
.
handle
=
pMsg
->
handle
,
.
handle
=
pMsg
->
handle
,
.
pCont
=
NULL
,
.
pCont
=
NULL
,
...
@@ -117,7 +117,7 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
...
@@ -117,7 +117,7 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
if
(
pMsg
->
pCont
==
NULL
)
return
;
if
(
pMsg
->
pCont
==
NULL
)
return
;
if
(
dnodeGetRunStatus
()
!=
TSDB_
DNODE_
RUN_STATUS_RUNING
)
{
if
(
dnodeGetRunStatus
()
!=
TSDB_RUN_STATUS_RUNING
)
{
dError
(
"RPC %p, shell msg:%s is ignored since dnode not running"
,
pMsg
->
handle
,
taosMsg
[
pMsg
->
msgType
]);
dError
(
"RPC %p, shell msg:%s is ignored since dnode not running"
,
pMsg
->
handle
,
taosMsg
[
pMsg
->
msgType
]);
rpcMsg
.
code
=
TSDB_CODE_APP_NOT_READY
;
rpcMsg
.
code
=
TSDB_CODE_APP_NOT_READY
;
rpcSendResponse
(
&
rpcMsg
);
rpcSendResponse
(
&
rpcMsg
);
...
@@ -126,9 +126,9 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
...
@@ -126,9 +126,9 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
}
}
if
(
pMsg
->
msgType
==
TSDB_MSG_TYPE_QUERY
)
{
if
(
pMsg
->
msgType
==
TSDB_MSG_TYPE_QUERY
)
{
atomic_fetch_add_32
(
&
ts
Dnode
QueryReqNum
,
1
);
atomic_fetch_add_32
(
&
tsQueryReqNum
,
1
);
}
else
if
(
pMsg
->
msgType
==
TSDB_MSG_TYPE_SUBMIT
)
{
}
else
if
(
pMsg
->
msgType
==
TSDB_MSG_TYPE_SUBMIT
)
{
atomic_fetch_add_32
(
&
ts
Dnode
SubmitReqNum
,
1
);
atomic_fetch_add_32
(
&
tsSubmitReqNum
,
1
);
}
else
{}
}
else
{}
if
(
dnodeProcessShellMsgFp
[
pMsg
->
msgType
]
)
{
if
(
dnodeProcessShellMsgFp
[
pMsg
->
msgType
]
)
{
...
@@ -211,12 +211,12 @@ void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t tid) {
...
@@ -211,12 +211,12 @@ void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t tid) {
}
}
}
}
S
Dnode
StatisInfo
dnodeGetStatisInfo
()
{
SStatisInfo
dnodeGetStatisInfo
()
{
S
Dnode
StatisInfo
info
=
{
0
};
SStatisInfo
info
=
{
0
};
if
(
dnodeGetRunStatus
()
==
TSDB_
DNODE_
RUN_STATUS_RUNING
)
{
if
(
dnodeGetRunStatus
()
==
TSDB_RUN_STATUS_RUNING
)
{
info
.
httpReqNum
=
httpGetReqCount
();
info
.
httpReqNum
=
httpGetReqCount
();
info
.
queryReqNum
=
atomic_exchange_32
(
&
ts
Dnode
QueryReqNum
,
0
);
info
.
queryReqNum
=
atomic_exchange_32
(
&
tsQueryReqNum
,
0
);
info
.
submitReqNum
=
atomic_exchange_32
(
&
ts
Dnode
SubmitReqNum
,
0
);
info
.
submitReqNum
=
atomic_exchange_32
(
&
tsSubmitReqNum
,
0
);
}
}
return
info
;
return
info
;
...
...
src/dnode/src/dnodeVWrite.c
浏览文件 @
83d2acd5
...
@@ -113,7 +113,7 @@ void dnodeDispatchToVWriteQueue(SRpcMsg *pRpcMsg) {
...
@@ -113,7 +113,7 @@ void dnodeDispatchToVWriteQueue(SRpcMsg *pRpcMsg) {
void
*
dnodeAllocVWriteQueue
(
void
*
pVnode
)
{
void
*
dnodeAllocVWriteQueue
(
void
*
pVnode
)
{
pthread_mutex_lock
(
&
tsVWriteWP
.
mutex
);
pthread_mutex_lock
(
&
tsVWriteWP
.
mutex
);
SVWriteWorker
*
pWorker
=
tsVWriteWP
.
worker
+
tsVWriteWP
.
nextId
;
SVWriteWorker
*
pWorker
=
tsVWriteWP
.
worker
+
tsVWriteWP
.
nextId
;
void
*
queue
=
taosOpenQueue
();
taos_queue
*
queue
=
taosOpenQueue
();
if
(
queue
==
NULL
)
{
if
(
queue
==
NULL
)
{
pthread_mutex_unlock
(
&
tsVWriteWP
.
mutex
);
pthread_mutex_unlock
(
&
tsVWriteWP
.
mutex
);
return
NULL
;
return
NULL
;
...
...
src/inc/dnode.h
浏览文件 @
83d2acd5
...
@@ -27,16 +27,16 @@ typedef struct {
...
@@ -27,16 +27,16 @@ typedef struct {
int32_t
queryReqNum
;
int32_t
queryReqNum
;
int32_t
submitReqNum
;
int32_t
submitReqNum
;
int32_t
httpReqNum
;
int32_t
httpReqNum
;
}
S
Dnode
StatisInfo
;
}
SStatisInfo
;
typedef
enum
{
typedef
enum
{
TSDB_
DNODE_
RUN_STATUS_INITIALIZE
,
TSDB_RUN_STATUS_INITIALIZE
,
TSDB_
DNODE_
RUN_STATUS_RUNING
,
TSDB_RUN_STATUS_RUNING
,
TSDB_
DNODE_
RUN_STATUS_STOPPED
TSDB_RUN_STATUS_STOPPED
}
S
Dnode
RunStatus
;
}
SRunStatus
;
S
DnodeRunStatus
dnodeGetRunStatus
();
S
RunStatus
dnodeGetRunStatus
();
S
Dnode
StatisInfo
dnodeGetStatisInfo
();
SStatisInfo
dnodeGetStatisInfo
();
bool
dnodeIsFirstDeploy
();
bool
dnodeIsFirstDeploy
();
bool
dnodeIsMasterEp
(
char
*
ep
);
bool
dnodeIsMasterEp
(
char
*
ep
);
...
@@ -59,15 +59,15 @@ void dnodeSendRpcVWriteRsp(void *pVnode, void *param, int32_t code);
...
@@ -59,15 +59,15 @@ void dnodeSendRpcVWriteRsp(void *pVnode, void *param, int32_t code);
void
*
dnodeAllocVReadQueue
(
void
*
pVnode
);
void
*
dnodeAllocVReadQueue
(
void
*
pVnode
);
void
dnodeFreeVReadQueue
(
void
*
rqueue
);
void
dnodeFreeVReadQueue
(
void
*
rqueue
);
int32_t
dnodeAllocateM
nodePq
ueue
();
int32_t
dnodeAllocateM
PeerQ
ueue
();
void
dnodeFreeM
nodePq
ueue
();
void
dnodeFreeM
PeerQ
ueue
();
int32_t
dnodeAlloc
ateMnodeRq
ueue
();
int32_t
dnodeAlloc
MReadQ
ueue
();
void
dnodeFreeM
nodeRq
ueue
();
void
dnodeFreeM
ReadQ
ueue
();
int32_t
dnodeAlloc
ateMnodeW
queue
();
int32_t
dnodeAlloc
MWrite
queue
();
void
dnodeFreeM
nodeW
queue
();
void
dnodeFreeM
Write
queue
();
void
dnodeSendRpcM
node
WriteRsp
(
void
*
pMsg
,
int32_t
code
);
void
dnodeSendRpcMWriteRsp
(
void
*
pMsg
,
int32_t
code
);
void
dnodeReprocessM
node
WriteMsg
(
void
*
pMsg
);
void
dnodeReprocessMWriteMsg
(
void
*
pMsg
);
void
dnodeDelayReprocessM
node
WriteMsg
(
void
*
pMsg
);
void
dnodeDelayReprocessMWriteMsg
(
void
*
pMsg
);
void
dnodeSendStatusMsgToMnode
();
void
dnodeSendStatusMsgToMnode
();
...
...
src/inc/mnode.h
浏览文件 @
83d2acd5
...
@@ -35,7 +35,13 @@ typedef struct {
...
@@ -35,7 +35,13 @@ typedef struct {
}
SMnodeRsp
;
}
SMnodeRsp
;
typedef
struct
SMnodeMsg
{
typedef
struct
SMnodeMsg
{
SRpcMsg
rpcMsg
;
struct
SAcctObj
*
pAcct
;
struct
SDnodeObj
*
pDnode
;
struct
SUserObj
*
pUser
;
struct
SDbObj
*
pDb
;
struct
SVgObj
*
pVgroup
;
struct
STableObj
*
pTable
;
struct
SSTableObj
*
pSTable
;
SMnodeRsp
rpcRsp
;
SMnodeRsp
rpcRsp
;
int8_t
received
;
int8_t
received
;
int8_t
successed
;
int8_t
successed
;
...
@@ -43,16 +49,11 @@ typedef struct SMnodeMsg {
...
@@ -43,16 +49,11 @@ typedef struct SMnodeMsg {
int8_t
retry
;
int8_t
retry
;
int32_t
code
;
int32_t
code
;
void
*
pObj
;
void
*
pObj
;
struct
SAcctObj
*
pAcct
;
SRpcMsg
rpcMsg
;
struct
SDnodeObj
*
pDnode
;
char
pCont
[];
struct
SUserObj
*
pUser
;
struct
SDbObj
*
pDb
;
struct
SVgObj
*
pVgroup
;
struct
STableObj
*
pTable
;
struct
SSuperTableObj
*
pSTable
;
}
SMnodeMsg
;
}
SMnodeMsg
;
void
mnodeCreateMsg
(
SMnodeMsg
*
pMsg
,
SRpcMsg
*
r
pcMsg
);
void
*
mnodeCreateMsg
(
SRpcMsg
*
pR
pcMsg
);
int32_t
mnodeInitMsg
(
SMnodeMsg
*
pMsg
);
int32_t
mnodeInitMsg
(
SMnodeMsg
*
pMsg
);
void
mnodeCleanupMsg
(
SMnodeMsg
*
pMsg
);
void
mnodeCleanupMsg
(
SMnodeMsg
*
pMsg
);
...
...
src/inc/taosdef.h
浏览文件 @
83d2acd5
...
@@ -431,11 +431,13 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf
...
@@ -431,11 +431,13 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf
#define TSDB_PORT_HTTP 11
#define TSDB_PORT_HTTP 11
#define TSDB_PORT_ARBITRATOR 12
#define TSDB_PORT_ARBITRATOR 12
#define TAOS_QTYPE_RPC 0
typedef
enum
{
#define TAOS_QTYPE_FWD 1
TAOS_QTYPE_RPC
=
0
,
#define TAOS_QTYPE_WAL 2
TAOS_QTYPE_FWD
=
1
,
#define TAOS_QTYPE_CQ 3
TAOS_QTYPE_WAL
=
2
,
#define TAOS_QTYPE_QUERY 4
TAOS_QTYPE_CQ
=
3
,
TAOS_QTYPE_QUERY
=
4
}
EQType
;
typedef
enum
{
typedef
enum
{
TSDB_SUPER_TABLE
=
0
,
// super table
TSDB_SUPER_TABLE
=
0
,
// super table
...
@@ -446,14 +448,14 @@ typedef enum {
...
@@ -446,14 +448,14 @@ typedef enum {
}
ETableType
;
}
ETableType
;
typedef
enum
{
typedef
enum
{
TSDB_MOD_MNODE
,
TSDB_MOD_MNODE
=
0
,
TSDB_MOD_HTTP
,
TSDB_MOD_HTTP
=
1
,
TSDB_MOD_MONITOR
,
TSDB_MOD_MONITOR
=
2
,
TSDB_MOD_MQTT
,
TSDB_MOD_MQTT
=
3
,
TSDB_MOD_MAX
TSDB_MOD_MAX
=
4
}
EModuleType
;
}
EModuleType
;
typedef
enum
{
typedef
enum
{
TSDB_CHECK_ITEM_NETWORK
,
TSDB_CHECK_ITEM_NETWORK
,
TSDB_CHECK_ITEM_MEM
,
TSDB_CHECK_ITEM_MEM
,
TSDB_CHECK_ITEM_CPU
,
TSDB_CHECK_ITEM_CPU
,
...
@@ -463,8 +465,7 @@ typedef enum {
...
@@ -463,8 +465,7 @@ typedef enum {
TSDB_CHECK_ITEM_VERSION
,
TSDB_CHECK_ITEM_VERSION
,
TSDB_CHECK_ITEM_DATAFILE
,
TSDB_CHECK_ITEM_DATAFILE
,
TSDB_CHECK_ITEM_MAX
TSDB_CHECK_ITEM_MAX
}
ECheckItemType
;
}
ECheckItemType
;
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/mnode/inc/mnodeDef.h
浏览文件 @
83d2acd5
...
@@ -89,7 +89,7 @@ typedef struct STableObj {
...
@@ -89,7 +89,7 @@ typedef struct STableObj {
int8_t
type
;
int8_t
type
;
}
STableObj
;
}
STableObj
;
typedef
struct
SS
uper
TableObj
{
typedef
struct
SSTableObj
{
STableObj
info
;
STableObj
info
;
int8_t
reserved0
[
9
];
// for fill struct STableObj to 4byte align
int8_t
reserved0
[
9
];
// for fill struct STableObj to 4byte align
int16_t
nextColId
;
int16_t
nextColId
;
...
@@ -104,7 +104,7 @@ typedef struct SSuperTableObj {
...
@@ -104,7 +104,7 @@ typedef struct SSuperTableObj {
int32_t
numOfTables
;
int32_t
numOfTables
;
SSchema
*
schema
;
SSchema
*
schema
;
void
*
vgHash
;
void
*
vgHash
;
}
SS
uper
TableObj
;
}
SSTableObj
;
typedef
struct
{
typedef
struct
{
STableObj
info
;
STableObj
info
;
...
@@ -122,8 +122,8 @@ typedef struct {
...
@@ -122,8 +122,8 @@ typedef struct {
int32_t
refCount
;
int32_t
refCount
;
char
*
sql
;
//used by normal table
char
*
sql
;
//used by normal table
SSchema
*
schema
;
//used by normal table
SSchema
*
schema
;
//used by normal table
SS
uperTableObj
*
superTable
;
SS
TableObj
*
superTable
;
}
SC
hild
TableObj
;
}
SCTableObj
;
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
...
...
src/mnode/inc/mnodeTable.h
浏览文件 @
83d2acd5
...
@@ -29,8 +29,8 @@ int64_t mnodeGetChildTableNum();
...
@@ -29,8 +29,8 @@ int64_t mnodeGetChildTableNum();
void
*
mnodeGetTable
(
char
*
tableId
);
void
*
mnodeGetTable
(
char
*
tableId
);
void
mnodeIncTableRef
(
void
*
pTable
);
void
mnodeIncTableRef
(
void
*
pTable
);
void
mnodeDecTableRef
(
void
*
pTable
);
void
mnodeDecTableRef
(
void
*
pTable
);
void
*
mnodeGetNextChildTable
(
void
*
pIter
,
SC
hild
TableObj
**
pTable
);
void
*
mnodeGetNextChildTable
(
void
*
pIter
,
SCTableObj
**
pTable
);
void
*
mnodeGetNextSuperTable
(
void
*
pIter
,
SS
uper
TableObj
**
pTable
);
void
*
mnodeGetNextSuperTable
(
void
*
pIter
,
SSTableObj
**
pTable
);
void
mnodeDropAllChildTables
(
SDbObj
*
pDropDb
);
void
mnodeDropAllChildTables
(
SDbObj
*
pDropDb
);
void
mnodeDropAllSuperTables
(
SDbObj
*
pDropDb
);
void
mnodeDropAllSuperTables
(
SDbObj
*
pDropDb
);
void
mnodeDropAllChildTablesInVgroups
(
SVgObj
*
pVgroup
);
void
mnodeDropAllChildTablesInVgroups
(
SVgObj
*
pVgroup
);
...
...
src/mnode/inc/mnodeVgroup.h
浏览文件 @
83d2acd5
...
@@ -43,8 +43,8 @@ void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle);
...
@@ -43,8 +43,8 @@ void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle);
void
mnodeAlterVgroup
(
SVgObj
*
pVgroup
,
void
*
ahandle
);
void
mnodeAlterVgroup
(
SVgObj
*
pVgroup
,
void
*
ahandle
);
int32_t
mnodeGetAvailableVgroup
(
struct
SMnodeMsg
*
pMsg
,
SVgObj
**
pVgroup
,
int32_t
*
sid
);
int32_t
mnodeGetAvailableVgroup
(
struct
SMnodeMsg
*
pMsg
,
SVgObj
**
pVgroup
,
int32_t
*
sid
);
void
mnodeAddTableIntoVgroup
(
SVgObj
*
pVgroup
,
SC
hild
TableObj
*
pTable
);
void
mnodeAddTableIntoVgroup
(
SVgObj
*
pVgroup
,
SCTableObj
*
pTable
);
void
mnodeRemoveTableFromVgroup
(
SVgObj
*
pVgroup
,
SC
hild
TableObj
*
pTable
);
void
mnodeRemoveTableFromVgroup
(
SVgObj
*
pVgroup
,
SCTableObj
*
pTable
);
void
mnodeSendDropVnodeMsg
(
int32_t
vgId
,
SRpcEpSet
*
epSet
,
void
*
ahandle
);
void
mnodeSendDropVnodeMsg
(
int32_t
vgId
,
SRpcEpSet
*
epSet
,
void
*
ahandle
);
void
mnodeSendCreateVgroupMsg
(
SVgObj
*
pVgroup
,
void
*
ahandle
);
void
mnodeSendCreateVgroupMsg
(
SVgObj
*
pVgroup
,
void
*
ahandle
);
void
mnodeSendAlterVgroupMsg
(
SVgObj
*
pVgroup
);
void
mnodeSendAlterVgroupMsg
(
SVgObj
*
pVgroup
);
...
...
src/mnode/src/mnodeInt.c
浏览文件 @
83d2acd5
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
#include "taosmsg.h"
#include "taosmsg.h"
#include "taoserror.h"
#include "taoserror.h"
#include "trpc.h"
#include "trpc.h"
#include "t
cach
e.h"
#include "t
queu
e.h"
#include "mnode.h"
#include "mnode.h"
#include "dnode.h"
#include "dnode.h"
#include "mnodeDef.h"
#include "mnodeDef.h"
...
@@ -34,8 +34,15 @@
...
@@ -34,8 +34,15 @@
#include "mnodeUser.h"
#include "mnodeUser.h"
#include "mnodeVgroup.h"
#include "mnodeVgroup.h"
void
mnodeCreateMsg
(
SMnodeMsg
*
pMsg
,
SRpcMsg
*
rpcMsg
)
{
void
*
mnodeCreateMsg
(
SRpcMsg
*
pRpcMsg
)
{
pMsg
->
rpcMsg
=
*
rpcMsg
;
int32_t
size
=
sizeof
(
SMnodeMsg
)
+
pRpcMsg
->
contLen
;
SMnodeMsg
*
pMsg
=
taosAllocateQitem
(
size
);
pMsg
->
rpcMsg
=
*
pRpcMsg
;
pMsg
->
rpcMsg
.
pCont
=
pMsg
->
pCont
;
memcpy
(
pMsg
->
pCont
,
pRpcMsg
->
pCont
,
pRpcMsg
->
contLen
);
return
pMsg
;
}
}
int32_t
mnodeInitMsg
(
SMnodeMsg
*
pMsg
)
{
int32_t
mnodeInitMsg
(
SMnodeMsg
*
pMsg
)
{
...
@@ -54,7 +61,9 @@ int32_t mnodeInitMsg(SMnodeMsg *pMsg) {
...
@@ -54,7 +61,9 @@ int32_t mnodeInitMsg(SMnodeMsg *pMsg) {
void
mnodeCleanupMsg
(
SMnodeMsg
*
pMsg
)
{
void
mnodeCleanupMsg
(
SMnodeMsg
*
pMsg
)
{
if
(
pMsg
!=
NULL
)
{
if
(
pMsg
!=
NULL
)
{
if
(
pMsg
->
rpcMsg
.
pCont
)
rpcFreeCont
(
pMsg
->
rpcMsg
.
pCont
);
if
(
pMsg
->
rpcMsg
.
pCont
!=
pMsg
->
pCont
)
{
tfree
(
pMsg
->
rpcMsg
.
pCont
);
}
if
(
pMsg
->
pUser
)
mnodeDecUserRef
(
pMsg
->
pUser
);
if
(
pMsg
->
pUser
)
mnodeDecUserRef
(
pMsg
->
pUser
);
if
(
pMsg
->
pDb
)
mnodeDecDbRef
(
pMsg
->
pDb
);
if
(
pMsg
->
pDb
)
mnodeDecDbRef
(
pMsg
->
pDb
);
if
(
pMsg
->
pVgroup
)
mnodeDecVgroupRef
(
pMsg
->
pVgroup
);
if
(
pMsg
->
pVgroup
)
mnodeDecVgroupRef
(
pMsg
->
pVgroup
);
...
...
src/mnode/src/mnodeMain.c
浏览文件 @
83d2acd5
...
@@ -96,9 +96,9 @@ int32_t mnodeStartSystem() {
...
@@ -96,9 +96,9 @@ int32_t mnodeStartSystem() {
return
-
1
;
return
-
1
;
}
}
dnodeAlloc
ateMnodeW
queue
();
dnodeAlloc
MWrite
queue
();
dnodeAlloc
ateMnodeRq
ueue
();
dnodeAlloc
MReadQ
ueue
();
dnodeAllocateM
nodePq
ueue
();
dnodeAllocateM
PeerQ
ueue
();
if
(
mnodeInitComponents
()
!=
0
)
{
if
(
mnodeInitComponents
()
!=
0
)
{
return
-
1
;
return
-
1
;
...
@@ -127,9 +127,9 @@ void mnodeCleanupSystem() {
...
@@ -127,9 +127,9 @@ void mnodeCleanupSystem() {
mInfo
(
"starting to clean up mnode"
);
mInfo
(
"starting to clean up mnode"
);
tsMgmtIsRunning
=
false
;
tsMgmtIsRunning
=
false
;
dnodeFreeM
nodeW
queue
();
dnodeFreeM
Write
queue
();
dnodeFreeM
nodeRq
ueue
();
dnodeFreeM
ReadQ
ueue
();
dnodeFreeM
nodePq
ueue
();
dnodeFreeM
PeerQ
ueue
();
mnodeCleanupTimer
();
mnodeCleanupTimer
();
mnodeCleanupComponents
(
sizeof
(
tsMnodeComponents
)
/
sizeof
(
tsMnodeComponents
[
0
])
-
1
);
mnodeCleanupComponents
(
sizeof
(
tsMnodeComponents
)
/
sizeof
(
tsMnodeComponents
[
0
])
-
1
);
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
83d2acd5
...
@@ -295,7 +295,7 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) {
...
@@ -295,7 +295,7 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) {
if
(
pOper
->
writeCb
!=
NULL
)
{
if
(
pOper
->
writeCb
!=
NULL
)
{
pOper
->
retCode
=
(
*
pOper
->
writeCb
)(
pMsg
,
pOper
->
retCode
);
pOper
->
retCode
=
(
*
pOper
->
writeCb
)(
pMsg
,
pOper
->
retCode
);
}
}
dnodeSendRpcM
node
WriteRsp
(
pMsg
,
pOper
->
retCode
);
dnodeSendRpcMWriteRsp
(
pMsg
,
pOper
->
retCode
);
// if ahandle, means this func is called by sdb write
// if ahandle, means this func is called by sdb write
if
(
ahandle
==
NULL
)
{
if
(
ahandle
==
NULL
)
{
...
@@ -1043,7 +1043,7 @@ void sdbFreeWritequeue() {
...
@@ -1043,7 +1043,7 @@ void sdbFreeWritequeue() {
int32_t
sdbWriteToQueue
(
void
*
param
,
void
*
data
,
int32_t
qtype
,
void
*
pMsg
)
{
int32_t
sdbWriteToQueue
(
void
*
param
,
void
*
data
,
int32_t
qtype
,
void
*
pMsg
)
{
SWalHead
*
pHead
=
data
;
SWalHead
*
pHead
=
data
;
int32_t
size
=
sizeof
(
SWalHead
)
+
pHead
->
len
;
int32_t
size
=
sizeof
(
SWalHead
)
+
pHead
->
len
;
SWalHead
*
pWal
=
(
SWalHead
*
)
taosAllocateQitem
(
size
);
SWalHead
*
pWal
=
taosAllocateQitem
(
size
);
memcpy
(
pWal
,
pHead
,
size
);
memcpy
(
pWal
,
pHead
,
size
);
taosWriteQitem
(
tsSdbWriteQueue
,
qtype
,
pWal
);
taosWriteQitem
(
tsSdbWriteQueue
,
qtype
,
pWal
);
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
83d2acd5
...
@@ -52,9 +52,9 @@ static int32_t tsSuperTableUpdateSize;
...
@@ -52,9 +52,9 @@ static int32_t tsSuperTableUpdateSize;
static
void
*
mnodeGetChildTable
(
char
*
tableId
);
static
void
*
mnodeGetChildTable
(
char
*
tableId
);
static
void
*
mnodeGetSuperTable
(
char
*
tableId
);
static
void
*
mnodeGetSuperTable
(
char
*
tableId
);
static
void
*
mnodeGetSuperTableByUid
(
uint64_t
uid
);
static
void
*
mnodeGetSuperTableByUid
(
uint64_t
uid
);
static
void
mnodeDropAllChildTablesInStable
(
SS
uper
TableObj
*
pStable
);
static
void
mnodeDropAllChildTablesInStable
(
SSTableObj
*
pStable
);
static
void
mnodeAddTableIntoStable
(
SS
uperTableObj
*
pStable
,
SChild
TableObj
*
pCtable
);
static
void
mnodeAddTableIntoStable
(
SS
TableObj
*
pStable
,
SC
TableObj
*
pCtable
);
static
void
mnodeRemoveTableFromStable
(
SS
uperTableObj
*
pStable
,
SChild
TableObj
*
pCtable
);
static
void
mnodeRemoveTableFromStable
(
SS
TableObj
*
pStable
,
SC
TableObj
*
pCtable
);
static
int32_t
mnodeGetShowTableMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeGetShowTableMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeRetrieveShowTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeRetrieveShowTables
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
...
@@ -86,9 +86,9 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg);
...
@@ -86,9 +86,9 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg);
static
int32_t
mnodeProcessAlterTableMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessAlterTableMsg
(
SMnodeMsg
*
pMsg
);
static
void
mnodeProcessAlterTableRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mnodeProcessAlterTableRsp
(
SRpcMsg
*
rpcMsg
);
static
int32_t
mnodeFindSuperTableColumnIndex
(
SS
uper
TableObj
*
pStable
,
char
*
colName
);
static
int32_t
mnodeFindSuperTableColumnIndex
(
SSTableObj
*
pStable
,
char
*
colName
);
static
void
mnodeDestroyChildTable
(
SC
hild
TableObj
*
pTable
)
{
static
void
mnodeDestroyChildTable
(
SCTableObj
*
pTable
)
{
taosTFree
(
pTable
->
info
.
tableId
);
taosTFree
(
pTable
->
info
.
tableId
);
taosTFree
(
pTable
->
schema
);
taosTFree
(
pTable
->
schema
);
taosTFree
(
pTable
->
sql
);
taosTFree
(
pTable
->
sql
);
...
@@ -101,7 +101,7 @@ static int32_t mnodeChildTableActionDestroy(SSdbOper *pOper) {
...
@@ -101,7 +101,7 @@ static int32_t mnodeChildTableActionDestroy(SSdbOper *pOper) {
}
}
static
int32_t
mnodeChildTableActionInsert
(
SSdbOper
*
pOper
)
{
static
int32_t
mnodeChildTableActionInsert
(
SSdbOper
*
pOper
)
{
SC
hild
TableObj
*
pTable
=
pOper
->
pObj
;
SCTableObj
*
pTable
=
pOper
->
pObj
;
SVgObj
*
pVgroup
=
mnodeGetVgroup
(
pTable
->
vgId
);
SVgObj
*
pVgroup
=
mnodeGetVgroup
(
pTable
->
vgId
);
if
(
pVgroup
==
NULL
)
{
if
(
pVgroup
==
NULL
)
{
...
@@ -150,7 +150,7 @@ static int32_t mnodeChildTableActionInsert(SSdbOper *pOper) {
...
@@ -150,7 +150,7 @@ static int32_t mnodeChildTableActionInsert(SSdbOper *pOper) {
}
}
static
int32_t
mnodeChildTableActionDelete
(
SSdbOper
*
pOper
)
{
static
int32_t
mnodeChildTableActionDelete
(
SSdbOper
*
pOper
)
{
SC
hild
TableObj
*
pTable
=
pOper
->
pObj
;
SCTableObj
*
pTable
=
pOper
->
pObj
;
if
(
pTable
->
vgId
==
0
)
{
if
(
pTable
->
vgId
==
0
)
{
return
TSDB_CODE_MND_VGROUP_NOT_EXIST
;
return
TSDB_CODE_MND_VGROUP_NOT_EXIST
;
}
}
...
@@ -186,8 +186,8 @@ static int32_t mnodeChildTableActionDelete(SSdbOper *pOper) {
...
@@ -186,8 +186,8 @@ static int32_t mnodeChildTableActionDelete(SSdbOper *pOper) {
}
}
static
int32_t
mnodeChildTableActionUpdate
(
SSdbOper
*
pOper
)
{
static
int32_t
mnodeChildTableActionUpdate
(
SSdbOper
*
pOper
)
{
SC
hild
TableObj
*
pNew
=
pOper
->
pObj
;
SCTableObj
*
pNew
=
pOper
->
pObj
;
SC
hild
TableObj
*
pTable
=
mnodeGetChildTable
(
pNew
->
info
.
tableId
);
SCTableObj
*
pTable
=
mnodeGetChildTable
(
pNew
->
info
.
tableId
);
if
(
pTable
!=
pNew
)
{
if
(
pTable
!=
pNew
)
{
void
*
oldTableId
=
pTable
->
info
.
tableId
;
void
*
oldTableId
=
pTable
->
info
.
tableId
;
void
*
oldSql
=
pTable
->
sql
;
void
*
oldSql
=
pTable
->
sql
;
...
@@ -195,7 +195,7 @@ static int32_t mnodeChildTableActionUpdate(SSdbOper *pOper) {
...
@@ -195,7 +195,7 @@ static int32_t mnodeChildTableActionUpdate(SSdbOper *pOper) {
void
*
oldSTable
=
pTable
->
superTable
;
void
*
oldSTable
=
pTable
->
superTable
;
int32_t
oldRefCount
=
pTable
->
refCount
;
int32_t
oldRefCount
=
pTable
->
refCount
;
memcpy
(
pTable
,
pNew
,
sizeof
(
SC
hild
TableObj
));
memcpy
(
pTable
,
pNew
,
sizeof
(
SCTableObj
));
pTable
->
refCount
=
oldRefCount
;
pTable
->
refCount
=
oldRefCount
;
pTable
->
sql
=
pNew
->
sql
;
pTable
->
sql
=
pNew
->
sql
;
...
@@ -213,7 +213,7 @@ static int32_t mnodeChildTableActionUpdate(SSdbOper *pOper) {
...
@@ -213,7 +213,7 @@ static int32_t mnodeChildTableActionUpdate(SSdbOper *pOper) {
}
}
static
int32_t
mnodeChildTableActionEncode
(
SSdbOper
*
pOper
)
{
static
int32_t
mnodeChildTableActionEncode
(
SSdbOper
*
pOper
)
{
SC
hild
TableObj
*
pTable
=
pOper
->
pObj
;
SCTableObj
*
pTable
=
pOper
->
pObj
;
assert
(
pTable
!=
NULL
&&
pOper
->
rowData
!=
NULL
);
assert
(
pTable
!=
NULL
&&
pOper
->
rowData
!=
NULL
);
int32_t
len
=
strlen
(
pTable
->
info
.
tableId
);
int32_t
len
=
strlen
(
pTable
->
info
.
tableId
);
...
@@ -244,7 +244,7 @@ static int32_t mnodeChildTableActionEncode(SSdbOper *pOper) {
...
@@ -244,7 +244,7 @@ static int32_t mnodeChildTableActionEncode(SSdbOper *pOper) {
static
int32_t
mnodeChildTableActionDecode
(
SSdbOper
*
pOper
)
{
static
int32_t
mnodeChildTableActionDecode
(
SSdbOper
*
pOper
)
{
assert
(
pOper
->
rowData
!=
NULL
);
assert
(
pOper
->
rowData
!=
NULL
);
SC
hildTableObj
*
pTable
=
calloc
(
1
,
sizeof
(
SChild
TableObj
));
SC
TableObj
*
pTable
=
calloc
(
1
,
sizeof
(
SC
TableObj
));
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
int32_t
len
=
strlen
(
pOper
->
rowData
);
int32_t
len
=
strlen
(
pOper
->
rowData
);
...
@@ -284,7 +284,7 @@ static int32_t mnodeChildTableActionDecode(SSdbOper *pOper) {
...
@@ -284,7 +284,7 @@ static int32_t mnodeChildTableActionDecode(SSdbOper *pOper) {
static
int32_t
mnodeChildTableActionRestored
()
{
static
int32_t
mnodeChildTableActionRestored
()
{
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
SC
hild
TableObj
*
pTable
=
NULL
;
SCTableObj
*
pTable
=
NULL
;
while
(
1
)
{
while
(
1
)
{
pIter
=
mnodeGetNextChildTable
(
pIter
,
&
pTable
);
pIter
=
mnodeGetNextChildTable
(
pIter
,
&
pTable
);
...
@@ -323,7 +323,7 @@ static int32_t mnodeChildTableActionRestored() {
...
@@ -323,7 +323,7 @@ static int32_t mnodeChildTableActionRestored() {
}
}
if
(
pTable
->
info
.
type
==
TSDB_CHILD_TABLE
)
{
if
(
pTable
->
info
.
type
==
TSDB_CHILD_TABLE
)
{
SS
uper
TableObj
*
pSuperTable
=
mnodeGetSuperTableByUid
(
pTable
->
suid
);
SSTableObj
*
pSuperTable
=
mnodeGetSuperTableByUid
(
pTable
->
suid
);
if
(
pSuperTable
==
NULL
)
{
if
(
pSuperTable
==
NULL
)
{
mError
(
"ctable:%s, stable:%"
PRIu64
" not exist"
,
pTable
->
info
.
tableId
,
pTable
->
suid
);
mError
(
"ctable:%s, stable:%"
PRIu64
" not exist"
,
pTable
->
info
.
tableId
,
pTable
->
suid
);
pTable
->
vgId
=
0
;
pTable
->
vgId
=
0
;
...
@@ -344,14 +344,14 @@ static int32_t mnodeChildTableActionRestored() {
...
@@ -344,14 +344,14 @@ static int32_t mnodeChildTableActionRestored() {
}
}
static
int32_t
mnodeInitChildTables
()
{
static
int32_t
mnodeInitChildTables
()
{
SC
hild
TableObj
tObj
;
SCTableObj
tObj
;
tsChildTableUpdateSize
=
(
int8_t
*
)
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
.
info
.
type
;
tsChildTableUpdateSize
=
(
int8_t
*
)
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
.
info
.
type
;
SSdbTableDesc
tableDesc
=
{
SSdbTableDesc
tableDesc
=
{
.
tableId
=
SDB_TABLE_CTABLE
,
.
tableId
=
SDB_TABLE_CTABLE
,
.
tableName
=
"ctables"
,
.
tableName
=
"ctables"
,
.
hashSessions
=
TSDB_DEFAULT_CTABLES_HASH_SIZE
,
.
hashSessions
=
TSDB_DEFAULT_CTABLES_HASH_SIZE
,
.
maxRowSize
=
sizeof
(
SC
hild
TableObj
)
+
sizeof
(
SSchema
)
*
(
TSDB_MAX_TAGS
+
TSDB_MAX_COLUMNS
+
16
)
+
TSDB_TABLE_FNAME_LEN
+
TSDB_CQ_SQL_SIZE
,
.
maxRowSize
=
sizeof
(
SCTableObj
)
+
sizeof
(
SSchema
)
*
(
TSDB_MAX_TAGS
+
TSDB_MAX_COLUMNS
+
16
)
+
TSDB_TABLE_FNAME_LEN
+
TSDB_CQ_SQL_SIZE
,
.
refCountPos
=
(
int8_t
*
)(
&
tObj
.
refCount
)
-
(
int8_t
*
)
&
tObj
,
.
refCountPos
=
(
int8_t
*
)(
&
tObj
.
refCount
)
-
(
int8_t
*
)
&
tObj
,
.
keyType
=
SDB_KEY_VAR_STRING
,
.
keyType
=
SDB_KEY_VAR_STRING
,
.
insertFp
=
mnodeChildTableActionInsert
,
.
insertFp
=
mnodeChildTableActionInsert
,
...
@@ -386,7 +386,7 @@ int64_t mnodeGetChildTableNum() {
...
@@ -386,7 +386,7 @@ int64_t mnodeGetChildTableNum() {
return
sdbGetNumOfRows
(
tsChildTableSdb
);
return
sdbGetNumOfRows
(
tsChildTableSdb
);
}
}
static
void
mnodeAddTableIntoStable
(
SS
uperTableObj
*
pStable
,
SChild
TableObj
*
pCtable
)
{
static
void
mnodeAddTableIntoStable
(
SS
TableObj
*
pStable
,
SC
TableObj
*
pCtable
)
{
atomic_add_fetch_32
(
&
pStable
->
numOfTables
,
1
);
atomic_add_fetch_32
(
&
pStable
->
numOfTables
,
1
);
if
(
pStable
->
vgHash
==
NULL
)
{
if
(
pStable
->
vgHash
==
NULL
)
{
...
@@ -402,7 +402,7 @@ static void mnodeAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCt
...
@@ -402,7 +402,7 @@ static void mnodeAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCt
}
}
}
}
static
void
mnodeRemoveTableFromStable
(
SS
uperTableObj
*
pStable
,
SChild
TableObj
*
pCtable
)
{
static
void
mnodeRemoveTableFromStable
(
SS
TableObj
*
pStable
,
SC
TableObj
*
pCtable
)
{
atomic_sub_fetch_32
(
&
pStable
->
numOfTables
,
1
);
atomic_sub_fetch_32
(
&
pStable
->
numOfTables
,
1
);
if
(
pStable
->
vgHash
==
NULL
)
return
;
if
(
pStable
->
vgHash
==
NULL
)
return
;
...
@@ -416,7 +416,7 @@ static void mnodeRemoveTableFromStable(SSuperTableObj *pStable, SChildTableObj *
...
@@ -416,7 +416,7 @@ static void mnodeRemoveTableFromStable(SSuperTableObj *pStable, SChildTableObj *
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
}
}
static
void
mnodeDestroySuperTable
(
SS
uper
TableObj
*
pStable
)
{
static
void
mnodeDestroySuperTable
(
SSTableObj
*
pStable
)
{
if
(
pStable
->
vgHash
!=
NULL
)
{
if
(
pStable
->
vgHash
!=
NULL
)
{
taosHashCleanup
(
pStable
->
vgHash
);
taosHashCleanup
(
pStable
->
vgHash
);
pStable
->
vgHash
=
NULL
;
pStable
->
vgHash
=
NULL
;
...
@@ -432,7 +432,7 @@ static int32_t mnodeSuperTableActionDestroy(SSdbOper *pOper) {
...
@@ -432,7 +432,7 @@ static int32_t mnodeSuperTableActionDestroy(SSdbOper *pOper) {
}
}
static
int32_t
mnodeSuperTableActionInsert
(
SSdbOper
*
pOper
)
{
static
int32_t
mnodeSuperTableActionInsert
(
SSdbOper
*
pOper
)
{
SS
uper
TableObj
*
pStable
=
pOper
->
pObj
;
SSTableObj
*
pStable
=
pOper
->
pObj
;
SDbObj
*
pDb
=
mnodeGetDbByTableId
(
pStable
->
info
.
tableId
);
SDbObj
*
pDb
=
mnodeGetDbByTableId
(
pStable
->
info
.
tableId
);
if
(
pDb
!=
NULL
&&
pDb
->
status
==
TSDB_DB_STATUS_READY
)
{
if
(
pDb
!=
NULL
&&
pDb
->
status
==
TSDB_DB_STATUS_READY
)
{
mnodeAddSuperTableIntoDb
(
pDb
);
mnodeAddSuperTableIntoDb
(
pDb
);
...
@@ -443,11 +443,11 @@ static int32_t mnodeSuperTableActionInsert(SSdbOper *pOper) {
...
@@ -443,11 +443,11 @@ static int32_t mnodeSuperTableActionInsert(SSdbOper *pOper) {
}
}
static
int32_t
mnodeSuperTableActionDelete
(
SSdbOper
*
pOper
)
{
static
int32_t
mnodeSuperTableActionDelete
(
SSdbOper
*
pOper
)
{
SS
uper
TableObj
*
pStable
=
pOper
->
pObj
;
SSTableObj
*
pStable
=
pOper
->
pObj
;
SDbObj
*
pDb
=
mnodeGetDbByTableId
(
pStable
->
info
.
tableId
);
SDbObj
*
pDb
=
mnodeGetDbByTableId
(
pStable
->
info
.
tableId
);
if
(
pDb
!=
NULL
)
{
if
(
pDb
!=
NULL
)
{
mnodeRemoveSuperTableFromDb
(
pDb
);
mnodeRemoveSuperTableFromDb
(
pDb
);
mnodeDropAllChildTablesInStable
((
SS
uper
TableObj
*
)
pStable
);
mnodeDropAllChildTablesInStable
((
SSTableObj
*
)
pStable
);
}
}
mnodeDecDbRef
(
pDb
);
mnodeDecDbRef
(
pDb
);
...
@@ -455,8 +455,8 @@ static int32_t mnodeSuperTableActionDelete(SSdbOper *pOper) {
...
@@ -455,8 +455,8 @@ static int32_t mnodeSuperTableActionDelete(SSdbOper *pOper) {
}
}
static
int32_t
mnodeSuperTableActionUpdate
(
SSdbOper
*
pOper
)
{
static
int32_t
mnodeSuperTableActionUpdate
(
SSdbOper
*
pOper
)
{
SS
uper
TableObj
*
pNew
=
pOper
->
pObj
;
SSTableObj
*
pNew
=
pOper
->
pObj
;
SS
uper
TableObj
*
pTable
=
mnodeGetSuperTable
(
pNew
->
info
.
tableId
);
SSTableObj
*
pTable
=
mnodeGetSuperTable
(
pNew
->
info
.
tableId
);
if
(
pTable
!=
NULL
&&
pTable
!=
pNew
)
{
if
(
pTable
!=
NULL
&&
pTable
!=
pNew
)
{
void
*
oldTableId
=
pTable
->
info
.
tableId
;
void
*
oldTableId
=
pTable
->
info
.
tableId
;
void
*
oldSchema
=
pTable
->
schema
;
void
*
oldSchema
=
pTable
->
schema
;
...
@@ -464,7 +464,7 @@ static int32_t mnodeSuperTableActionUpdate(SSdbOper *pOper) {
...
@@ -464,7 +464,7 @@ static int32_t mnodeSuperTableActionUpdate(SSdbOper *pOper) {
int32_t
oldRefCount
=
pTable
->
refCount
;
int32_t
oldRefCount
=
pTable
->
refCount
;
int32_t
oldNumOfTables
=
pTable
->
numOfTables
;
int32_t
oldNumOfTables
=
pTable
->
numOfTables
;
memcpy
(
pTable
,
pNew
,
sizeof
(
SS
uper
TableObj
));
memcpy
(
pTable
,
pNew
,
sizeof
(
SSTableObj
));
pTable
->
vgHash
=
oldVgHash
;
pTable
->
vgHash
=
oldVgHash
;
pTable
->
refCount
=
oldRefCount
;
pTable
->
refCount
=
oldRefCount
;
...
@@ -480,7 +480,7 @@ static int32_t mnodeSuperTableActionUpdate(SSdbOper *pOper) {
...
@@ -480,7 +480,7 @@ static int32_t mnodeSuperTableActionUpdate(SSdbOper *pOper) {
}
}
static
int32_t
mnodeSuperTableActionEncode
(
SSdbOper
*
pOper
)
{
static
int32_t
mnodeSuperTableActionEncode
(
SSdbOper
*
pOper
)
{
SS
uper
TableObj
*
pStable
=
pOper
->
pObj
;
SSTableObj
*
pStable
=
pOper
->
pObj
;
assert
(
pOper
->
pObj
!=
NULL
&&
pOper
->
rowData
!=
NULL
);
assert
(
pOper
->
pObj
!=
NULL
&&
pOper
->
rowData
!=
NULL
);
int32_t
len
=
strlen
(
pStable
->
info
.
tableId
);
int32_t
len
=
strlen
(
pStable
->
info
.
tableId
);
...
@@ -504,7 +504,7 @@ static int32_t mnodeSuperTableActionEncode(SSdbOper *pOper) {
...
@@ -504,7 +504,7 @@ static int32_t mnodeSuperTableActionEncode(SSdbOper *pOper) {
static
int32_t
mnodeSuperTableActionDecode
(
SSdbOper
*
pOper
)
{
static
int32_t
mnodeSuperTableActionDecode
(
SSdbOper
*
pOper
)
{
assert
(
pOper
->
rowData
!=
NULL
);
assert
(
pOper
->
rowData
!=
NULL
);
SS
uperTableObj
*
pStable
=
(
SSuperTableObj
*
)
calloc
(
1
,
sizeof
(
SSuper
TableObj
));
SS
TableObj
*
pStable
=
(
SSTableObj
*
)
calloc
(
1
,
sizeof
(
SS
TableObj
));
if
(
pStable
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
if
(
pStable
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
int32_t
len
=
strlen
(
pOper
->
rowData
);
int32_t
len
=
strlen
(
pOper
->
rowData
);
...
@@ -537,14 +537,14 @@ static int32_t mnodeSuperTableActionRestored() {
...
@@ -537,14 +537,14 @@ static int32_t mnodeSuperTableActionRestored() {
}
}
static
int32_t
mnodeInitSuperTables
()
{
static
int32_t
mnodeInitSuperTables
()
{
SS
uper
TableObj
tObj
;
SSTableObj
tObj
;
tsSuperTableUpdateSize
=
(
int8_t
*
)
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
.
info
.
type
;
tsSuperTableUpdateSize
=
(
int8_t
*
)
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
.
info
.
type
;
SSdbTableDesc
tableDesc
=
{
SSdbTableDesc
tableDesc
=
{
.
tableId
=
SDB_TABLE_STABLE
,
.
tableId
=
SDB_TABLE_STABLE
,
.
tableName
=
"stables"
,
.
tableName
=
"stables"
,
.
hashSessions
=
TSDB_DEFAULT_STABLES_HASH_SIZE
,
.
hashSessions
=
TSDB_DEFAULT_STABLES_HASH_SIZE
,
.
maxRowSize
=
sizeof
(
SS
uper
TableObj
)
+
sizeof
(
SSchema
)
*
(
TSDB_MAX_TAGS
+
TSDB_MAX_COLUMNS
+
16
)
+
TSDB_TABLE_FNAME_LEN
,
.
maxRowSize
=
sizeof
(
SSTableObj
)
+
sizeof
(
SSchema
)
*
(
TSDB_MAX_TAGS
+
TSDB_MAX_COLUMNS
+
16
)
+
TSDB_TABLE_FNAME_LEN
,
.
refCountPos
=
(
int8_t
*
)(
&
tObj
.
refCount
)
-
(
int8_t
*
)
&
tObj
,
.
refCountPos
=
(
int8_t
*
)(
&
tObj
.
refCount
)
-
(
int8_t
*
)
&
tObj
,
.
keyType
=
SDB_KEY_VAR_STRING
,
.
keyType
=
SDB_KEY_VAR_STRING
,
.
insertFp
=
mnodeSuperTableActionInsert
,
.
insertFp
=
mnodeSuperTableActionInsert
,
...
@@ -615,7 +615,7 @@ static void *mnodeGetSuperTable(char *tableId) {
...
@@ -615,7 +615,7 @@ static void *mnodeGetSuperTable(char *tableId) {
}
}
static
void
*
mnodeGetSuperTableByUid
(
uint64_t
uid
)
{
static
void
*
mnodeGetSuperTableByUid
(
uint64_t
uid
)
{
SS
uper
TableObj
*
pStable
=
NULL
;
SSTableObj
*
pStable
=
NULL
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
while
(
1
)
{
while
(
1
)
{
...
@@ -647,11 +647,11 @@ void *mnodeGetTable(char *tableId) {
...
@@ -647,11 +647,11 @@ void *mnodeGetTable(char *tableId) {
return
NULL
;
return
NULL
;
}
}
void
*
mnodeGetNextChildTable
(
void
*
pIter
,
SC
hild
TableObj
**
pTable
)
{
void
*
mnodeGetNextChildTable
(
void
*
pIter
,
SCTableObj
**
pTable
)
{
return
sdbFetchRow
(
tsChildTableSdb
,
pIter
,
(
void
**
)
pTable
);
return
sdbFetchRow
(
tsChildTableSdb
,
pIter
,
(
void
**
)
pTable
);
}
}
void
*
mnodeGetNextSuperTable
(
void
*
pIter
,
SS
uper
TableObj
**
pTable
)
{
void
*
mnodeGetNextSuperTable
(
void
*
pIter
,
SSTableObj
**
pTable
)
{
return
sdbFetchRow
(
tsSuperTableSdb
,
pIter
,
(
void
**
)
pTable
);
return
sdbFetchRow
(
tsSuperTableSdb
,
pIter
,
(
void
**
)
pTable
);
}
}
...
@@ -765,12 +765,12 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
...
@@ -765,12 +765,12 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
}
}
if
(
pMsg
->
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
if
(
pMsg
->
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
SS
uperTableObj
*
pSTable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pSTable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
mInfo
(
"app:%p:%p, table:%s, start to drop stable, uid:%"
PRIu64
", numOfChildTables:%d, sizeOfVgList:%d"
,
mInfo
(
"app:%p:%p, table:%s, start to drop stable, uid:%"
PRIu64
", numOfChildTables:%d, sizeOfVgList:%d"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pDrop
->
tableId
,
pSTable
->
uid
,
pSTable
->
numOfTables
,
(
int32_t
)
taosHashGetSize
(
pSTable
->
vgHash
));
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pDrop
->
tableId
,
pSTable
->
uid
,
pSTable
->
numOfTables
,
(
int32_t
)
taosHashGetSize
(
pSTable
->
vgHash
));
return
mnodeProcessDropSuperTableMsg
(
pMsg
);
return
mnodeProcessDropSuperTableMsg
(
pMsg
);
}
else
{
}
else
{
SC
hildTableObj
*
pCTable
=
(
SChild
TableObj
*
)
pMsg
->
pTable
;
SC
TableObj
*
pCTable
=
(
SC
TableObj
*
)
pMsg
->
pTable
;
mInfo
(
"app:%p:%p, table:%s, start to drop ctable, vgId:%d tid:%d uid:%"
PRIu64
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
mInfo
(
"app:%p:%p, table:%s, start to drop ctable, vgId:%d tid:%d uid:%"
PRIu64
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pDrop
->
tableId
,
pCTable
->
vgId
,
pCTable
->
tid
,
pCTable
->
uid
);
pDrop
->
tableId
,
pCTable
->
vgId
,
pCTable
->
tid
,
pCTable
->
uid
);
return
mnodeProcessDropChildTableMsg
(
pMsg
);
return
mnodeProcessDropChildTableMsg
(
pMsg
);
...
@@ -816,7 +816,7 @@ static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *pMsg) {
...
@@ -816,7 +816,7 @@ static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *pMsg) {
}
}
static
int32_t
mnodeCreateSuperTableCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
static
int32_t
mnodeCreateSuperTableCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
SS
uperTableObj
*
pTable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pTable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
assert
(
pTable
);
assert
(
pTable
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
...
@@ -835,7 +835,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
...
@@ -835,7 +835,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
if
(
pMsg
==
NULL
)
return
TSDB_CODE_MND_APP_ERROR
;
if
(
pMsg
==
NULL
)
return
TSDB_CODE_MND_APP_ERROR
;
SCMCreateTableMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SCMCreateTableMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SS
uperTableObj
*
pStable
=
calloc
(
1
,
sizeof
(
SSuper
TableObj
));
SS
TableObj
*
pStable
=
calloc
(
1
,
sizeof
(
SS
TableObj
));
if
(
pStable
==
NULL
)
{
if
(
pStable
==
NULL
)
{
mError
(
"app:%p:%p, table:%s, failed to create, no enough memory"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCreate
->
tableId
);
mError
(
"app:%p:%p, table:%s, failed to create, no enough memory"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCreate
->
tableId
);
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
...
@@ -878,7 +878,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
...
@@ -878,7 +878,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsSuperTableSdb
,
.
table
=
tsSuperTableSdb
,
.
pObj
=
pStable
,
.
pObj
=
pStable
,
.
rowSize
=
sizeof
(
SS
uper
TableObj
)
+
schemaSize
,
.
rowSize
=
sizeof
(
SSTableObj
)
+
schemaSize
,
.
pMsg
=
pMsg
,
.
pMsg
=
pMsg
,
.
writeCb
=
mnodeCreateSuperTableCb
.
writeCb
=
mnodeCreateSuperTableCb
};
};
...
@@ -894,7 +894,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
...
@@ -894,7 +894,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
}
}
static
int32_t
mnodeDropSuperTableCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
static
int32_t
mnodeDropSuperTableCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
SS
uperTableObj
*
pTable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pTable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"app:%p:%p, stable:%s, failed to drop, sdb error"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
mError
(
"app:%p:%p, stable:%s, failed to drop, sdb error"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
}
else
{
}
else
{
...
@@ -907,7 +907,7 @@ static int32_t mnodeDropSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -907,7 +907,7 @@ static int32_t mnodeDropSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
static
int32_t
mnodeProcessDropSuperTableMsg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeProcessDropSuperTableMsg
(
SMnodeMsg
*
pMsg
)
{
if
(
pMsg
==
NULL
)
return
TSDB_CODE_MND_APP_ERROR
;
if
(
pMsg
==
NULL
)
return
TSDB_CODE_MND_APP_ERROR
;
SS
uperTableObj
*
pStable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pStable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
if
(
pStable
->
vgHash
!=
NULL
/*pStable->numOfTables != 0*/
)
{
if
(
pStable
->
vgHash
!=
NULL
/*pStable->numOfTables != 0*/
)
{
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
pStable
->
vgHash
);
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
pStable
->
vgHash
);
while
(
taosHashIterNext
(
pIter
))
{
while
(
taosHashIterNext
(
pIter
))
{
...
@@ -950,7 +950,7 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
...
@@ -950,7 +950,7 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
return
code
;
return
code
;
}
}
static
int32_t
mnodeFindSuperTableTagIndex
(
SS
uper
TableObj
*
pStable
,
const
char
*
tagName
)
{
static
int32_t
mnodeFindSuperTableTagIndex
(
SSTableObj
*
pStable
,
const
char
*
tagName
)
{
SSchema
*
schema
=
(
SSchema
*
)
pStable
->
schema
;
SSchema
*
schema
=
(
SSchema
*
)
pStable
->
schema
;
for
(
int32_t
tag
=
0
;
tag
<
pStable
->
numOfTags
;
tag
++
)
{
for
(
int32_t
tag
=
0
;
tag
<
pStable
->
numOfTags
;
tag
++
)
{
if
(
strcasecmp
(
schema
[
pStable
->
numOfColumns
+
tag
].
name
,
tagName
)
==
0
)
{
if
(
strcasecmp
(
schema
[
pStable
->
numOfColumns
+
tag
].
name
,
tagName
)
==
0
)
{
...
@@ -962,7 +962,7 @@ static int32_t mnodeFindSuperTableTagIndex(SSuperTableObj *pStable, const char *
...
@@ -962,7 +962,7 @@ static int32_t mnodeFindSuperTableTagIndex(SSuperTableObj *pStable, const char *
}
}
static
int32_t
mnodeAddSuperTableTagCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
static
int32_t
mnodeAddSuperTableTagCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
SS
uperTableObj
*
pStable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pStable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
mLInfo
(
"app:%p:%p, stable %s, add tag result:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
mLInfo
(
"app:%p:%p, stable %s, add tag result:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
tstrerror
(
code
));
tstrerror
(
code
));
...
@@ -970,7 +970,7 @@ static int32_t mnodeAddSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -970,7 +970,7 @@ static int32_t mnodeAddSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) {
}
}
static
int32_t
mnodeAddSuperTableTag
(
SMnodeMsg
*
pMsg
,
SSchema
schema
[],
int32_t
ntags
)
{
static
int32_t
mnodeAddSuperTableTag
(
SMnodeMsg
*
pMsg
,
SSchema
schema
[],
int32_t
ntags
)
{
SS
uperTableObj
*
pStable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pStable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
if
(
pStable
->
numOfTags
+
ntags
>
TSDB_MAX_TAGS
)
{
if
(
pStable
->
numOfTags
+
ntags
>
TSDB_MAX_TAGS
)
{
mError
(
"app:%p:%p, stable:%s, add tag, too many tags"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
);
mError
(
"app:%p:%p, stable:%s, add tag, too many tags"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
);
return
TSDB_CODE_MND_TOO_MANY_TAGS
;
return
TSDB_CODE_MND_TOO_MANY_TAGS
;
...
@@ -1018,14 +1018,14 @@ static int32_t mnodeAddSuperTableTag(SMnodeMsg *pMsg, SSchema schema[], int32_t
...
@@ -1018,14 +1018,14 @@ static int32_t mnodeAddSuperTableTag(SMnodeMsg *pMsg, SSchema schema[], int32_t
}
}
static
int32_t
mnodeDropSuperTableTagCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
static
int32_t
mnodeDropSuperTableTagCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
SS
uperTableObj
*
pStable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pStable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
mLInfo
(
"app:%p:%p, stable %s, drop tag result:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
mLInfo
(
"app:%p:%p, stable %s, drop tag result:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
tstrerror
(
code
));
tstrerror
(
code
));
return
code
;
return
code
;
}
}
static
int32_t
mnodeDropSuperTableTag
(
SMnodeMsg
*
pMsg
,
char
*
tagName
)
{
static
int32_t
mnodeDropSuperTableTag
(
SMnodeMsg
*
pMsg
,
char
*
tagName
)
{
SS
uperTableObj
*
pStable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pStable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
int32_t
col
=
mnodeFindSuperTableTagIndex
(
pStable
,
tagName
);
int32_t
col
=
mnodeFindSuperTableTagIndex
(
pStable
,
tagName
);
if
(
col
<
0
)
{
if
(
col
<
0
)
{
mError
(
"app:%p:%p, stable:%s, drop tag, tag:%s not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
mError
(
"app:%p:%p, stable:%s, drop tag, tag:%s not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
...
@@ -1052,14 +1052,14 @@ static int32_t mnodeDropSuperTableTag(SMnodeMsg *pMsg, char *tagName) {
...
@@ -1052,14 +1052,14 @@ static int32_t mnodeDropSuperTableTag(SMnodeMsg *pMsg, char *tagName) {
}
}
static
int32_t
mnodeModifySuperTableTagNameCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
static
int32_t
mnodeModifySuperTableTagNameCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
SS
uperTableObj
*
pStable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pStable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
mLInfo
(
"app:%p:%p, stable %s, modify tag result:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
mLInfo
(
"app:%p:%p, stable %s, modify tag result:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
tstrerror
(
code
));
tstrerror
(
code
));
return
code
;
return
code
;
}
}
static
int32_t
mnodeModifySuperTableTagName
(
SMnodeMsg
*
pMsg
,
char
*
oldTagName
,
char
*
newTagName
)
{
static
int32_t
mnodeModifySuperTableTagName
(
SMnodeMsg
*
pMsg
,
char
*
oldTagName
,
char
*
newTagName
)
{
SS
uperTableObj
*
pStable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pStable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
int32_t
col
=
mnodeFindSuperTableTagIndex
(
pStable
,
oldTagName
);
int32_t
col
=
mnodeFindSuperTableTagIndex
(
pStable
,
oldTagName
);
if
(
col
<
0
)
{
if
(
col
<
0
)
{
mError
(
"app:%p:%p, stable:%s, failed to modify table tag, oldName: %s, newName: %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
mError
(
"app:%p:%p, stable:%s, failed to modify table tag, oldName: %s, newName: %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
...
@@ -1095,7 +1095,7 @@ static int32_t mnodeModifySuperTableTagName(SMnodeMsg *pMsg, char *oldTagName, c
...
@@ -1095,7 +1095,7 @@ static int32_t mnodeModifySuperTableTagName(SMnodeMsg *pMsg, char *oldTagName, c
return
sdbUpdateRow
(
&
oper
);
return
sdbUpdateRow
(
&
oper
);
}
}
static
int32_t
mnodeFindSuperTableColumnIndex
(
SS
uper
TableObj
*
pStable
,
char
*
colName
)
{
static
int32_t
mnodeFindSuperTableColumnIndex
(
SSTableObj
*
pStable
,
char
*
colName
)
{
SSchema
*
schema
=
(
SSchema
*
)
pStable
->
schema
;
SSchema
*
schema
=
(
SSchema
*
)
pStable
->
schema
;
for
(
int32_t
col
=
0
;
col
<
pStable
->
numOfColumns
;
col
++
)
{
for
(
int32_t
col
=
0
;
col
<
pStable
->
numOfColumns
;
col
++
)
{
if
(
strcasecmp
(
schema
[
col
].
name
,
colName
)
==
0
)
{
if
(
strcasecmp
(
schema
[
col
].
name
,
colName
)
==
0
)
{
...
@@ -1107,7 +1107,7 @@ static int32_t mnodeFindSuperTableColumnIndex(SSuperTableObj *pStable, char *col
...
@@ -1107,7 +1107,7 @@ static int32_t mnodeFindSuperTableColumnIndex(SSuperTableObj *pStable, char *col
}
}
static
int32_t
mnodeAddSuperTableColumnCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
static
int32_t
mnodeAddSuperTableColumnCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
SS
uperTableObj
*
pStable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pStable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
mLInfo
(
"app:%p:%p, stable %s, add column result:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
mLInfo
(
"app:%p:%p, stable %s, add column result:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
tstrerror
(
code
));
tstrerror
(
code
));
return
code
;
return
code
;
...
@@ -1115,7 +1115,7 @@ static int32_t mnodeAddSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -1115,7 +1115,7 @@ static int32_t mnodeAddSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
static
int32_t
mnodeAddSuperTableColumn
(
SMnodeMsg
*
pMsg
,
SSchema
schema
[],
int32_t
ncols
)
{
static
int32_t
mnodeAddSuperTableColumn
(
SMnodeMsg
*
pMsg
,
SSchema
schema
[],
int32_t
ncols
)
{
SDbObj
*
pDb
=
pMsg
->
pDb
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
SS
uperTableObj
*
pStable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pStable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
if
(
ncols
<=
0
)
{
if
(
ncols
<=
0
)
{
mError
(
"app:%p:%p, stable:%s, add column, ncols:%d <= 0"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
ncols
);
mError
(
"app:%p:%p, stable:%s, add column, ncols:%d <= 0"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
ncols
);
return
TSDB_CODE_MND_APP_ERROR
;
return
TSDB_CODE_MND_APP_ERROR
;
...
@@ -1170,7 +1170,7 @@ static int32_t mnodeAddSuperTableColumn(SMnodeMsg *pMsg, SSchema schema[], int32
...
@@ -1170,7 +1170,7 @@ static int32_t mnodeAddSuperTableColumn(SMnodeMsg *pMsg, SSchema schema[], int32
}
}
static
int32_t
mnodeDropSuperTableColumnCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
static
int32_t
mnodeDropSuperTableColumnCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
SS
uperTableObj
*
pStable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pStable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
mLInfo
(
"app:%p:%p, stable %s, delete column result:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
mLInfo
(
"app:%p:%p, stable %s, delete column result:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
tstrerror
(
code
));
tstrerror
(
code
));
return
code
;
return
code
;
...
@@ -1178,7 +1178,7 @@ static int32_t mnodeDropSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -1178,7 +1178,7 @@ static int32_t mnodeDropSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
static
int32_t
mnodeDropSuperTableColumn
(
SMnodeMsg
*
pMsg
,
char
*
colName
)
{
static
int32_t
mnodeDropSuperTableColumn
(
SMnodeMsg
*
pMsg
,
char
*
colName
)
{
SDbObj
*
pDb
=
pMsg
->
pDb
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
SS
uperTableObj
*
pStable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pStable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
int32_t
col
=
mnodeFindSuperTableColumnIndex
(
pStable
,
colName
);
int32_t
col
=
mnodeFindSuperTableColumnIndex
(
pStable
,
colName
);
if
(
col
<=
0
)
{
if
(
col
<=
0
)
{
mError
(
"app:%p:%p, stable:%s, drop column, column:%s not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
mError
(
"app:%p:%p, stable:%s, drop column, column:%s not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
...
@@ -1215,14 +1215,14 @@ static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, char *colName) {
...
@@ -1215,14 +1215,14 @@ static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, char *colName) {
}
}
static
int32_t
mnodeChangeSuperTableColumnCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
static
int32_t
mnodeChangeSuperTableColumnCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
SS
uperTableObj
*
pStable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pStable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
mLInfo
(
"app:%p:%p, stable %s, change column result:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
mLInfo
(
"app:%p:%p, stable %s, change column result:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
tstrerror
(
code
));
tstrerror
(
code
));
return
code
;
return
code
;
}
}
static
int32_t
mnodeChangeSuperTableColumn
(
SMnodeMsg
*
pMsg
,
char
*
oldName
,
char
*
newName
)
{
static
int32_t
mnodeChangeSuperTableColumn
(
SMnodeMsg
*
pMsg
,
char
*
oldName
,
char
*
newName
)
{
SS
uperTableObj
*
pStable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pStable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
int32_t
col
=
mnodeFindSuperTableColumnIndex
(
pStable
,
oldName
);
int32_t
col
=
mnodeFindSuperTableColumnIndex
(
pStable
,
oldName
);
if
(
col
<
0
)
{
if
(
col
<
0
)
{
mError
(
"app:%p:%p, stable:%s, change column, oldName: %s, newName: %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
mError
(
"app:%p:%p, stable:%s, change column, oldName: %s, newName: %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
...
@@ -1321,7 +1321,7 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows,
...
@@ -1321,7 +1321,7 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows,
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
char
*
pWrite
;
char
*
pWrite
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SS
uper
TableObj
*
pTable
=
NULL
;
SSTableObj
*
pTable
=
NULL
;
char
prefix
[
64
]
=
{
0
};
char
prefix
[
64
]
=
{
0
};
int32_t
prefixLen
;
int32_t
prefixLen
;
...
@@ -1399,7 +1399,7 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows,
...
@@ -1399,7 +1399,7 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows,
void
mnodeDropAllSuperTables
(
SDbObj
*
pDropDb
)
{
void
mnodeDropAllSuperTables
(
SDbObj
*
pDropDb
)
{
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
numOfTables
=
0
;
int32_t
numOfTables
=
0
;
SS
uper
TableObj
*
pTable
=
NULL
;
SSTableObj
*
pTable
=
NULL
;
char
prefix
[
64
]
=
{
0
};
char
prefix
[
64
]
=
{
0
};
tstrncpy
(
prefix
,
pDropDb
->
name
,
64
);
tstrncpy
(
prefix
,
pDropDb
->
name
,
64
);
...
@@ -1430,7 +1430,7 @@ void mnodeDropAllSuperTables(SDbObj *pDropDb) {
...
@@ -1430,7 +1430,7 @@ void mnodeDropAllSuperTables(SDbObj *pDropDb) {
mInfo
(
"db:%s, all super tables:%d is dropped from sdb"
,
pDropDb
->
name
,
numOfTables
);
mInfo
(
"db:%s, all super tables:%d is dropped from sdb"
,
pDropDb
->
name
,
numOfTables
);
}
}
static
int32_t
mnodeSetSchemaFromSuperTable
(
SSchema
*
pSchema
,
SS
uper
TableObj
*
pTable
)
{
static
int32_t
mnodeSetSchemaFromSuperTable
(
SSchema
*
pSchema
,
SSTableObj
*
pTable
)
{
int32_t
numOfCols
=
pTable
->
numOfColumns
+
pTable
->
numOfTags
;
int32_t
numOfCols
=
pTable
->
numOfColumns
+
pTable
->
numOfTags
;
assert
(
numOfCols
<=
TSDB_MAX_COLUMNS
);
assert
(
numOfCols
<=
TSDB_MAX_COLUMNS
);
...
@@ -1446,7 +1446,7 @@ static int32_t mnodeSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pT
...
@@ -1446,7 +1446,7 @@ static int32_t mnodeSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pT
}
}
static
int32_t
mnodeGetSuperTableMeta
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeGetSuperTableMeta
(
SMnodeMsg
*
pMsg
)
{
SS
uperTableObj
*
pTable
=
(
SSuper
TableObj
*
)
pMsg
->
pTable
;
SS
TableObj
*
pTable
=
(
SS
TableObj
*
)
pMsg
->
pTable
;
STableMetaMsg
*
pMeta
=
rpcMallocCont
(
sizeof
(
STableMetaMsg
)
+
sizeof
(
SSchema
)
*
(
TSDB_MAX_TAGS
+
TSDB_MAX_COLUMNS
+
16
));
STableMetaMsg
*
pMeta
=
rpcMallocCont
(
sizeof
(
STableMetaMsg
)
+
sizeof
(
SSchema
)
*
(
TSDB_MAX_TAGS
+
TSDB_MAX_COLUMNS
+
16
));
if
(
pMeta
==
NULL
)
{
if
(
pMeta
==
NULL
)
{
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
...
@@ -1479,7 +1479,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
...
@@ -1479,7 +1479,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
int32_t
contLen
=
sizeof
(
SSTableVgroupRspMsg
)
+
32
*
sizeof
(
SVgroupMsg
)
+
sizeof
(
SVgroupsMsg
);
int32_t
contLen
=
sizeof
(
SSTableVgroupRspMsg
)
+
32
*
sizeof
(
SVgroupMsg
)
+
sizeof
(
SVgroupsMsg
);
for
(
int32_t
i
=
0
;
i
<
numOfTable
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTable
;
++
i
)
{
char
*
stableName
=
(
char
*
)
pInfo
+
sizeof
(
SSTableVgroupMsg
)
+
(
TSDB_TABLE_FNAME_LEN
)
*
i
;
char
*
stableName
=
(
char
*
)
pInfo
+
sizeof
(
SSTableVgroupMsg
)
+
(
TSDB_TABLE_FNAME_LEN
)
*
i
;
SS
uper
TableObj
*
pTable
=
mnodeGetSuperTable
(
stableName
);
SSTableObj
*
pTable
=
mnodeGetSuperTable
(
stableName
);
if
(
pTable
!=
NULL
&&
pTable
->
vgHash
!=
NULL
)
{
if
(
pTable
!=
NULL
&&
pTable
->
vgHash
!=
NULL
)
{
contLen
+=
(
taosHashGetSize
(
pTable
->
vgHash
)
*
sizeof
(
SVgroupMsg
)
+
sizeof
(
SVgroupsMsg
));
contLen
+=
(
taosHashGetSize
(
pTable
->
vgHash
)
*
sizeof
(
SVgroupMsg
)
+
sizeof
(
SVgroupsMsg
));
}
}
...
@@ -1497,7 +1497,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
...
@@ -1497,7 +1497,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
for
(
int32_t
i
=
0
;
i
<
numOfTable
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTable
;
++
i
)
{
char
*
stableName
=
(
char
*
)
pInfo
+
sizeof
(
SSTableVgroupMsg
)
+
(
TSDB_TABLE_FNAME_LEN
)
*
i
;
char
*
stableName
=
(
char
*
)
pInfo
+
sizeof
(
SSTableVgroupMsg
)
+
(
TSDB_TABLE_FNAME_LEN
)
*
i
;
SS
uper
TableObj
*
pTable
=
mnodeGetSuperTable
(
stableName
);
SSTableObj
*
pTable
=
mnodeGetSuperTable
(
stableName
);
if
(
pTable
==
NULL
)
{
if
(
pTable
==
NULL
)
{
mError
(
"app:%p:%p, stable:%s, not exist while get stable vgroup info"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
stableName
);
mError
(
"app:%p:%p, stable:%s, not exist while get stable vgroup info"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
stableName
);
mnodeDecTableRef
(
pTable
);
mnodeDecTableRef
(
pTable
);
...
@@ -1569,7 +1569,7 @@ static void mnodeProcessDropSuperTableRsp(SRpcMsg *rpcMsg) {
...
@@ -1569,7 +1569,7 @@ static void mnodeProcessDropSuperTableRsp(SRpcMsg *rpcMsg) {
mInfo
(
"drop stable rsp received, result:%s"
,
tstrerror
(
rpcMsg
->
code
));
mInfo
(
"drop stable rsp received, result:%s"
,
tstrerror
(
rpcMsg
->
code
));
}
}
static
void
*
mnodeBuildCreateChildTableMsg
(
SCMCreateTableMsg
*
pMsg
,
SC
hild
TableObj
*
pTable
)
{
static
void
*
mnodeBuildCreateChildTableMsg
(
SCMCreateTableMsg
*
pMsg
,
SCTableObj
*
pTable
)
{
STagData
*
pTagData
=
NULL
;
STagData
*
pTagData
=
NULL
;
int32_t
tagDataLen
=
0
;
int32_t
tagDataLen
=
0
;
int32_t
totalCols
=
0
;
int32_t
totalCols
=
0
;
...
@@ -1643,7 +1643,7 @@ static void *mnodeBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableO
...
@@ -1643,7 +1643,7 @@ static void *mnodeBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableO
}
}
static
int32_t
mnodeDoCreateChildTableFp
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeDoCreateChildTableFp
(
SMnodeMsg
*
pMsg
)
{
SC
hildTableObj
*
pTable
=
(
SChild
TableObj
*
)
pMsg
->
pTable
;
SC
TableObj
*
pTable
=
(
SC
TableObj
*
)
pMsg
->
pTable
;
assert
(
pTable
);
assert
(
pTable
);
mDebug
(
"app:%p:%p, table:%s, created in mnode, vgId:%d sid:%d, uid:%"
PRIu64
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
mDebug
(
"app:%p:%p, table:%s, created in mnode, vgId:%d sid:%d, uid:%"
PRIu64
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
...
@@ -1669,7 +1669,7 @@ static int32_t mnodeDoCreateChildTableFp(SMnodeMsg *pMsg) {
...
@@ -1669,7 +1669,7 @@ static int32_t mnodeDoCreateChildTableFp(SMnodeMsg *pMsg) {
}
}
static
int32_t
mnodeDoCreateChildTableCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
static
int32_t
mnodeDoCreateChildTableCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
SC
hildTableObj
*
pTable
=
(
SChild
TableObj
*
)
pMsg
->
pTable
;
SC
TableObj
*
pTable
=
(
SC
TableObj
*
)
pMsg
->
pTable
;
SCMCreateTableMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SCMCreateTableMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
assert
(
pTable
);
assert
(
pTable
);
...
@@ -1679,12 +1679,12 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -1679,12 +1679,12 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
pTable
->
info
.
tableId
,
pMsg
->
rpcMsg
.
handle
);
pTable
->
info
.
tableId
,
pMsg
->
rpcMsg
.
handle
);
pMsg
->
retry
=
0
;
pMsg
->
retry
=
0
;
dnodeReprocessM
node
WriteMsg
(
pMsg
);
dnodeReprocessMWriteMsg
(
pMsg
);
}
else
{
}
else
{
mDebug
(
"app:%p:%p, table:%s, created in dnode, thandle:%p"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
mDebug
(
"app:%p:%p, table:%s, created in dnode, thandle:%p"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
pMsg
->
rpcMsg
.
handle
);
pMsg
->
rpcMsg
.
handle
);
dnodeSendRpcM
node
WriteRsp
(
pMsg
,
TSDB_CODE_SUCCESS
);
dnodeSendRpcMWriteRsp
(
pMsg
,
TSDB_CODE_SUCCESS
);
}
}
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
else
{
}
else
{
...
@@ -1699,7 +1699,7 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -1699,7 +1699,7 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
static
int32_t
mnodeDoCreateChildTable
(
SMnodeMsg
*
pMsg
,
int32_t
tid
)
{
static
int32_t
mnodeDoCreateChildTable
(
SMnodeMsg
*
pMsg
,
int32_t
tid
)
{
SVgObj
*
pVgroup
=
pMsg
->
pVgroup
;
SVgObj
*
pVgroup
=
pMsg
->
pVgroup
;
SCMCreateTableMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SCMCreateTableMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SC
hildTableObj
*
pTable
=
calloc
(
1
,
sizeof
(
SChild
TableObj
));
SC
TableObj
*
pTable
=
calloc
(
1
,
sizeof
(
SC
TableObj
));
if
(
pTable
==
NULL
)
{
if
(
pTable
==
NULL
)
{
mError
(
"app:%p:%p, table:%s, failed to alloc memory"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCreate
->
tableId
);
mError
(
"app:%p:%p, table:%s, failed to alloc memory"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCreate
->
tableId
);
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
...
@@ -1842,7 +1842,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
...
@@ -1842,7 +1842,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
}
}
static
int32_t
mnodeSendDropChildTableMsg
(
SMnodeMsg
*
pMsg
,
bool
needReturn
)
{
static
int32_t
mnodeSendDropChildTableMsg
(
SMnodeMsg
*
pMsg
,
bool
needReturn
)
{
SC
hildTableObj
*
pTable
=
(
SChild
TableObj
*
)
pMsg
->
pTable
;
SC
TableObj
*
pTable
=
(
SC
TableObj
*
)
pMsg
->
pTable
;
mLInfo
(
"app:%p:%p, ctable:%s, is dropped from sdb"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
mLInfo
(
"app:%p:%p, ctable:%s, is dropped from sdb"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
SMDDropTableMsg
*
pDrop
=
rpcMallocCont
(
sizeof
(
SMDDropTableMsg
));
SMDDropTableMsg
*
pDrop
=
rpcMallocCont
(
sizeof
(
SMDDropTableMsg
));
...
@@ -1880,7 +1880,7 @@ static int32_t mnodeSendDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) {
...
@@ -1880,7 +1880,7 @@ static int32_t mnodeSendDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) {
static
int32_t
mnodeDropChildTableCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
static
int32_t
mnodeDropChildTableCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
SC
hildTableObj
*
pTable
=
(
SChild
TableObj
*
)
pMsg
->
pTable
;
SC
TableObj
*
pTable
=
(
SC
TableObj
*
)
pMsg
->
pTable
;
mError
(
"app:%p:%p, ctable:%s, failed to drop, sdb error"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
mError
(
"app:%p:%p, ctable:%s, failed to drop, sdb error"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
return
code
;
return
code
;
}
}
...
@@ -1889,7 +1889,7 @@ static int32_t mnodeDropChildTableCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -1889,7 +1889,7 @@ static int32_t mnodeDropChildTableCb(SMnodeMsg *pMsg, int32_t code) {
}
}
static
int32_t
mnodeProcessDropChildTableMsg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeProcessDropChildTableMsg
(
SMnodeMsg
*
pMsg
)
{
SC
hildTableObj
*
pTable
=
(
SChild
TableObj
*
)
pMsg
->
pTable
;
SC
TableObj
*
pTable
=
(
SC
TableObj
*
)
pMsg
->
pTable
;
if
(
pMsg
->
pVgroup
==
NULL
)
pMsg
->
pVgroup
=
mnodeGetVgroup
(
pTable
->
vgId
);
if
(
pMsg
->
pVgroup
==
NULL
)
pMsg
->
pVgroup
=
mnodeGetVgroup
(
pTable
->
vgId
);
if
(
pMsg
->
pVgroup
==
NULL
)
{
if
(
pMsg
->
pVgroup
==
NULL
)
{
mError
(
"app:%p:%p, table:%s, failed to drop ctable, vgroup not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
mError
(
"app:%p:%p, table:%s, failed to drop ctable, vgroup not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
...
@@ -1914,7 +1914,7 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
...
@@ -1914,7 +1914,7 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
return
code
;
return
code
;
}
}
static
int32_t
mnodeFindNormalTableColumnIndex
(
SC
hild
TableObj
*
pTable
,
char
*
colName
)
{
static
int32_t
mnodeFindNormalTableColumnIndex
(
SCTableObj
*
pTable
,
char
*
colName
)
{
SSchema
*
schema
=
(
SSchema
*
)
pTable
->
schema
;
SSchema
*
schema
=
(
SSchema
*
)
pTable
->
schema
;
for
(
int32_t
col
=
0
;
col
<
pTable
->
numOfColumns
;
col
++
)
{
for
(
int32_t
col
=
0
;
col
<
pTable
->
numOfColumns
;
col
++
)
{
if
(
strcasecmp
(
schema
[
col
].
name
,
colName
)
==
0
)
{
if
(
strcasecmp
(
schema
[
col
].
name
,
colName
)
==
0
)
{
...
@@ -1926,7 +1926,7 @@ static int32_t mnodeFindNormalTableColumnIndex(SChildTableObj *pTable, char *col
...
@@ -1926,7 +1926,7 @@ static int32_t mnodeFindNormalTableColumnIndex(SChildTableObj *pTable, char *col
}
}
static
int32_t
mnodeAlterNormalTableColumnCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
static
int32_t
mnodeAlterNormalTableColumnCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
SC
hildTableObj
*
pTable
=
(
SChild
TableObj
*
)
pMsg
->
pTable
;
SC
TableObj
*
pTable
=
(
SC
TableObj
*
)
pMsg
->
pTable
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"app:%p:%p, ctable %s, failed to alter column, reason:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
mError
(
"app:%p:%p, ctable %s, failed to alter column, reason:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
tstrerror
(
code
));
tstrerror
(
code
));
...
@@ -1965,7 +1965,7 @@ static int32_t mnodeAlterNormalTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -1965,7 +1965,7 @@ static int32_t mnodeAlterNormalTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
}
}
static
int32_t
mnodeAddNormalTableColumn
(
SMnodeMsg
*
pMsg
,
SSchema
schema
[],
int32_t
ncols
)
{
static
int32_t
mnodeAddNormalTableColumn
(
SMnodeMsg
*
pMsg
,
SSchema
schema
[],
int32_t
ncols
)
{
SC
hildTableObj
*
pTable
=
(
SChild
TableObj
*
)
pMsg
->
pTable
;
SC
TableObj
*
pTable
=
(
SC
TableObj
*
)
pMsg
->
pTable
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
if
(
ncols
<=
0
)
{
if
(
ncols
<=
0
)
{
mError
(
"app:%p:%p, ctable:%s, add column, ncols:%d <= 0"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
ncols
);
mError
(
"app:%p:%p, ctable:%s, add column, ncols:%d <= 0"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
ncols
);
...
@@ -2014,7 +2014,7 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3
...
@@ -2014,7 +2014,7 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3
static
int32_t
mnodeDropNormalTableColumn
(
SMnodeMsg
*
pMsg
,
char
*
colName
)
{
static
int32_t
mnodeDropNormalTableColumn
(
SMnodeMsg
*
pMsg
,
char
*
colName
)
{
SDbObj
*
pDb
=
pMsg
->
pDb
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
SC
hildTableObj
*
pTable
=
(
SChild
TableObj
*
)
pMsg
->
pTable
;
SC
TableObj
*
pTable
=
(
SC
TableObj
*
)
pMsg
->
pTable
;
int32_t
col
=
mnodeFindNormalTableColumnIndex
(
pTable
,
colName
);
int32_t
col
=
mnodeFindNormalTableColumnIndex
(
pTable
,
colName
);
if
(
col
<=
0
)
{
if
(
col
<=
0
)
{
mError
(
"app:%p:%p, ctable:%s, drop column, column:%s not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
mError
(
"app:%p:%p, ctable:%s, drop column, column:%s not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
...
@@ -2046,7 +2046,7 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) {
...
@@ -2046,7 +2046,7 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) {
}
}
static
int32_t
mnodeChangeNormalTableColumn
(
SMnodeMsg
*
pMsg
,
char
*
oldName
,
char
*
newName
)
{
static
int32_t
mnodeChangeNormalTableColumn
(
SMnodeMsg
*
pMsg
,
char
*
oldName
,
char
*
newName
)
{
SC
hildTableObj
*
pTable
=
(
SChild
TableObj
*
)
pMsg
->
pTable
;
SC
TableObj
*
pTable
=
(
SC
TableObj
*
)
pMsg
->
pTable
;
int32_t
col
=
mnodeFindNormalTableColumnIndex
(
pTable
,
oldName
);
int32_t
col
=
mnodeFindNormalTableColumnIndex
(
pTable
,
oldName
);
if
(
col
<
0
)
{
if
(
col
<
0
)
{
mError
(
"app:%p:%p, ctable:%s, change column, oldName: %s, newName: %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
mError
(
"app:%p:%p, ctable:%s, change column, oldName: %s, newName: %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
...
@@ -2082,7 +2082,7 @@ static int32_t mnodeChangeNormalTableColumn(SMnodeMsg *pMsg, char *oldName, char
...
@@ -2082,7 +2082,7 @@ static int32_t mnodeChangeNormalTableColumn(SMnodeMsg *pMsg, char *oldName, char
return
sdbUpdateRow
(
&
oper
);
return
sdbUpdateRow
(
&
oper
);
}
}
static
int32_t
mnodeSetSchemaFromNormalTable
(
SSchema
*
pSchema
,
SC
hild
TableObj
*
pTable
)
{
static
int32_t
mnodeSetSchemaFromNormalTable
(
SSchema
*
pSchema
,
SCTableObj
*
pTable
)
{
int32_t
numOfCols
=
pTable
->
numOfColumns
;
int32_t
numOfCols
=
pTable
->
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
strcpy
(
pSchema
->
name
,
pTable
->
schema
[
i
].
name
);
strcpy
(
pSchema
->
name
,
pTable
->
schema
[
i
].
name
);
...
@@ -2097,7 +2097,7 @@ static int32_t mnodeSetSchemaFromNormalTable(SSchema *pSchema, SChildTableObj *p
...
@@ -2097,7 +2097,7 @@ static int32_t mnodeSetSchemaFromNormalTable(SSchema *pSchema, SChildTableObj *p
static
int32_t
mnodeDoGetChildTableMeta
(
SMnodeMsg
*
pMsg
,
STableMetaMsg
*
pMeta
)
{
static
int32_t
mnodeDoGetChildTableMeta
(
SMnodeMsg
*
pMsg
,
STableMetaMsg
*
pMeta
)
{
SDbObj
*
pDb
=
pMsg
->
pDb
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
SC
hildTableObj
*
pTable
=
(
SChild
TableObj
*
)
pMsg
->
pTable
;
SC
TableObj
*
pTable
=
(
SC
TableObj
*
)
pMsg
->
pTable
;
pMeta
->
uid
=
htobe64
(
pTable
->
uid
);
pMeta
->
uid
=
htobe64
(
pTable
->
uid
);
pMeta
->
tid
=
htonl
(
pTable
->
tid
);
pMeta
->
tid
=
htonl
(
pTable
->
tid
);
...
@@ -2156,7 +2156,7 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
...
@@ -2156,7 +2156,7 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
}
}
int32_t
contLen
=
sizeof
(
SCMCreateTableMsg
)
+
offsetof
(
STagData
,
data
)
+
tagLen
;
int32_t
contLen
=
sizeof
(
SCMCreateTableMsg
)
+
offsetof
(
STagData
,
data
)
+
tagLen
;
SCMCreateTableMsg
*
pCreateMsg
=
rpcMallocCont
(
contLen
);
SCMCreateTableMsg
*
pCreateMsg
=
calloc
(
1
,
contLen
);
if
(
pCreateMsg
==
NULL
)
{
if
(
pCreateMsg
==
NULL
)
{
mError
(
"app:%p:%p, table:%s, failed to create table while get meta info, no enough memory"
,
pMsg
->
rpcMsg
.
ahandle
,
mError
(
"app:%p:%p, table:%s, failed to create table while get meta info, no enough memory"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pInfo
->
tableId
);
pMsg
,
pInfo
->
tableId
);
...
@@ -2174,7 +2174,9 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
...
@@ -2174,7 +2174,9 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
mDebug
(
"app:%p:%p, table:%s, start to create on demand, tagLen:%d stable:%s"
,
mDebug
(
"app:%p:%p, table:%s, start to create on demand, tagLen:%d stable:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pInfo
->
tableId
,
tagLen
,
pTags
->
name
);
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pInfo
->
tableId
,
tagLen
,
pTags
->
name
);
rpcFreeCont
(
pMsg
->
rpcMsg
.
pCont
);
if
(
pMsg
->
rpcMsg
.
pCont
!=
pMsg
->
pCont
)
{
tfree
(
pMsg
->
rpcMsg
.
pCont
);
}
pMsg
->
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_CM_CREATE_TABLE
;
pMsg
->
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_CM_CREATE_TABLE
;
pMsg
->
rpcMsg
.
pCont
=
pCreateMsg
;
pMsg
->
rpcMsg
.
pCont
=
pCreateMsg
;
pMsg
->
rpcMsg
.
contLen
=
contLen
;
pMsg
->
rpcMsg
.
contLen
=
contLen
;
...
@@ -2203,7 +2205,7 @@ static int32_t mnodeGetChildTableMeta(SMnodeMsg *pMsg) {
...
@@ -2203,7 +2205,7 @@ static int32_t mnodeGetChildTableMeta(SMnodeMsg *pMsg) {
void
mnodeDropAllChildTablesInVgroups
(
SVgObj
*
pVgroup
)
{
void
mnodeDropAllChildTablesInVgroups
(
SVgObj
*
pVgroup
)
{
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
numOfTables
=
0
;
int32_t
numOfTables
=
0
;
SC
hild
TableObj
*
pTable
=
NULL
;
SCTableObj
*
pTable
=
NULL
;
mInfo
(
"vgId:%d, all child tables will be dropped from sdb"
,
pVgroup
->
vgId
);
mInfo
(
"vgId:%d, all child tables will be dropped from sdb"
,
pVgroup
->
vgId
);
...
@@ -2231,7 +2233,7 @@ void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup) {
...
@@ -2231,7 +2233,7 @@ void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup) {
void
mnodeDropAllChildTables
(
SDbObj
*
pDropDb
)
{
void
mnodeDropAllChildTables
(
SDbObj
*
pDropDb
)
{
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
numOfTables
=
0
;
int32_t
numOfTables
=
0
;
SC
hild
TableObj
*
pTable
=
NULL
;
SCTableObj
*
pTable
=
NULL
;
char
prefix
[
64
]
=
{
0
};
char
prefix
[
64
]
=
{
0
};
tstrncpy
(
prefix
,
pDropDb
->
name
,
64
);
tstrncpy
(
prefix
,
pDropDb
->
name
,
64
);
...
@@ -2261,10 +2263,10 @@ void mnodeDropAllChildTables(SDbObj *pDropDb) {
...
@@ -2261,10 +2263,10 @@ void mnodeDropAllChildTables(SDbObj *pDropDb) {
mInfo
(
"db:%s, all child tables:%d is dropped from sdb"
,
pDropDb
->
name
,
numOfTables
);
mInfo
(
"db:%s, all child tables:%d is dropped from sdb"
,
pDropDb
->
name
,
numOfTables
);
}
}
static
void
mnodeDropAllChildTablesInStable
(
SS
uper
TableObj
*
pStable
)
{
static
void
mnodeDropAllChildTablesInStable
(
SSTableObj
*
pStable
)
{
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
int32_t
numOfTables
=
0
;
int32_t
numOfTables
=
0
;
SC
hild
TableObj
*
pTable
=
NULL
;
SCTableObj
*
pTable
=
NULL
;
mInfo
(
"stable:%s uid:%"
PRIu64
", all child tables:%d will be dropped from sdb"
,
pStable
->
info
.
tableId
,
pStable
->
uid
,
mInfo
(
"stable:%s uid:%"
PRIu64
", all child tables:%d will be dropped from sdb"
,
pStable
->
info
.
tableId
,
pStable
->
uid
,
pStable
->
numOfTables
);
pStable
->
numOfTables
);
...
@@ -2292,11 +2294,11 @@ static void mnodeDropAllChildTablesInStable(SSuperTableObj *pStable) {
...
@@ -2292,11 +2294,11 @@ static void mnodeDropAllChildTablesInStable(SSuperTableObj *pStable) {
}
}
#if 0
#if 0
static SC
hild
TableObj* mnodeGetTableByPos(int32_t vnode, int32_t tid) {
static SCTableObj* mnodeGetTableByPos(int32_t vnode, int32_t tid) {
SVgObj *pVgroup = mnodeGetVgroup(vnode);
SVgObj *pVgroup = mnodeGetVgroup(vnode);
if (pVgroup == NULL) return NULL;
if (pVgroup == NULL) return NULL;
SC
hild
TableObj *pTable = pVgroup->tableList[tid - 1];
SCTableObj *pTable = pVgroup->tableList[tid - 1];
mnodeIncTableRef((STableObj *)pTable);
mnodeIncTableRef((STableObj *)pTable);
mnodeDecVgroupRef(pVgroup);
mnodeDecVgroupRef(pVgroup);
...
@@ -2314,7 +2316,7 @@ static int32_t mnodeProcessTableCfgMsg(SMnodeMsg *pMsg) {
...
@@ -2314,7 +2316,7 @@ static int32_t mnodeProcessTableCfgMsg(SMnodeMsg *pMsg) {
mDebug("app:%p:%p, dnode:%d, vgId:%d sid:%d, receive table config msg", pMsg->rpcMsg.ahandle, pMsg, pCfg->dnodeId,
mDebug("app:%p:%p, dnode:%d, vgId:%d sid:%d, receive table config msg", pMsg->rpcMsg.ahandle, pMsg, pCfg->dnodeId,
pCfg->vgId, pCfg->sid);
pCfg->vgId, pCfg->sid);
SC
hild
TableObj *pTable = mnodeGetTableByPos(pCfg->vgId, pCfg->sid);
SCTableObj *pTable = mnodeGetTableByPos(pCfg->vgId, pCfg->sid);
if (pTable == NULL) {
if (pTable == NULL) {
mError("app:%p:%p, dnode:%d, vgId:%d sid:%d, table not found", pMsg->rpcMsg.ahandle, pMsg, pCfg->dnodeId,
mError("app:%p:%p, dnode:%d, vgId:%d sid:%d, table not found", pMsg->rpcMsg.ahandle, pMsg, pCfg->dnodeId,
pCfg->vgId, pCfg->sid);
pCfg->vgId, pCfg->sid);
...
@@ -2322,7 +2324,7 @@ static int32_t mnodeProcessTableCfgMsg(SMnodeMsg *pMsg) {
...
@@ -2322,7 +2324,7 @@ static int32_t mnodeProcessTableCfgMsg(SMnodeMsg *pMsg) {
}
}
SMDCreateTableMsg *pCreate = NULL;
SMDCreateTableMsg *pCreate = NULL;
pCreate = mnodeBuildCreateChildTableMsg(NULL, (SC
hild
TableObj *)pTable);
pCreate = mnodeBuildCreateChildTableMsg(NULL, (SCTableObj *)pTable);
mnodeDecTableRef(pTable);
mnodeDecTableRef(pTable);
if (pCreate == NULL) return terrno;
if (pCreate == NULL) return terrno;
...
@@ -2340,7 +2342,7 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
...
@@ -2340,7 +2342,7 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
SMnodeMsg
*
mnodeMsg
=
rpcMsg
->
ahandle
;
SMnodeMsg
*
mnodeMsg
=
rpcMsg
->
ahandle
;
mnodeMsg
->
received
++
;
mnodeMsg
->
received
++
;
SC
hildTableObj
*
pTable
=
(
SChild
TableObj
*
)
mnodeMsg
->
pTable
;
SC
TableObj
*
pTable
=
(
SC
TableObj
*
)
mnodeMsg
->
pTable
;
assert
(
pTable
);
assert
(
pTable
);
mInfo
(
"app:%p:%p, table:%s, drop table rsp received, vgId:%d sid:%d uid:%"
PRIu64
", thandle:%p result:%s"
,
mInfo
(
"app:%p:%p, table:%s, drop table rsp received, vgId:%d sid:%d uid:%"
PRIu64
", thandle:%p result:%s"
,
...
@@ -2351,14 +2353,14 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
...
@@ -2351,14 +2353,14 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
mError
(
"app:%p:%p, table:%s, failed to drop in dnode, vgId:%d sid:%d uid:%"
PRIu64
", reason:%s"
,
mError
(
"app:%p:%p, table:%s, failed to drop in dnode, vgId:%d sid:%d uid:%"
PRIu64
", reason:%s"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
pTable
->
vgId
,
pTable
->
tid
,
pTable
->
uid
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
pTable
->
vgId
,
pTable
->
tid
,
pTable
->
uid
,
tstrerror
(
rpcMsg
->
code
));
tstrerror
(
rpcMsg
->
code
));
dnodeSendRpcM
node
WriteRsp
(
mnodeMsg
,
rpcMsg
->
code
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
rpcMsg
->
code
);
return
;
return
;
}
}
if
(
mnodeMsg
->
pVgroup
==
NULL
)
mnodeMsg
->
pVgroup
=
mnodeGetVgroup
(
pTable
->
vgId
);
if
(
mnodeMsg
->
pVgroup
==
NULL
)
mnodeMsg
->
pVgroup
=
mnodeGetVgroup
(
pTable
->
vgId
);
if
(
mnodeMsg
->
pVgroup
==
NULL
)
{
if
(
mnodeMsg
->
pVgroup
==
NULL
)
{
mError
(
"app:%p:%p, table:%s, failed to get vgroup"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
);
mError
(
"app:%p:%p, table:%s, failed to get vgroup"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
);
dnodeSendRpcM
node
WriteRsp
(
mnodeMsg
,
TSDB_CODE_MND_VGROUP_NOT_EXIST
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
TSDB_CODE_MND_VGROUP_NOT_EXIST
);
return
;
return
;
}
}
...
@@ -2368,7 +2370,7 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
...
@@ -2368,7 +2370,7 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
mnodeDropVgroup
(
mnodeMsg
->
pVgroup
,
NULL
);
mnodeDropVgroup
(
mnodeMsg
->
pVgroup
,
NULL
);
}
}
dnodeSendRpcM
node
WriteRsp
(
mnodeMsg
,
TSDB_CODE_SUCCESS
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
TSDB_CODE_SUCCESS
);
}
}
/*
/*
...
@@ -2381,7 +2383,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
...
@@ -2381,7 +2383,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
SMnodeMsg
*
mnodeMsg
=
rpcMsg
->
ahandle
;
SMnodeMsg
*
mnodeMsg
=
rpcMsg
->
ahandle
;
mnodeMsg
->
received
++
;
mnodeMsg
->
received
++
;
SC
hildTableObj
*
pTable
=
(
SChild
TableObj
*
)
mnodeMsg
->
pTable
;
SC
TableObj
*
pTable
=
(
SC
TableObj
*
)
mnodeMsg
->
pTable
;
assert
(
pTable
);
assert
(
pTable
);
// If the table is deleted by another thread during creation, stop creating and send drop msg to vnode
// If the table is deleted by another thread during creation, stop creating and send drop msg to vnode
...
@@ -2399,7 +2401,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
...
@@ -2399,7 +2401,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
mnodeSendDropChildTableMsg
(
mnodeMsg
,
false
);
mnodeSendDropChildTableMsg
(
mnodeMsg
,
false
);
rpcMsg
->
code
=
TSDB_CODE_SUCCESS
;
rpcMsg
->
code
=
TSDB_CODE_SUCCESS
;
dnodeSendRpcM
node
WriteRsp
(
mnodeMsg
,
rpcMsg
->
code
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
rpcMsg
->
code
);
return
;
return
;
}
}
...
@@ -2416,7 +2418,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
...
@@ -2416,7 +2418,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mnodeMsg
->
pTable
=
NULL
;
mnodeMsg
->
pTable
=
NULL
;
mnodeDestroyChildTable
(
pTable
);
mnodeDestroyChildTable
(
pTable
);
dnodeSendRpcM
node
WriteRsp
(
mnodeMsg
,
code
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
code
);
}
}
}
else
{
}
else
{
if
(
mnodeMsg
->
retry
++
<
10
)
{
if
(
mnodeMsg
->
retry
++
<
10
)
{
...
@@ -2425,7 +2427,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
...
@@ -2425,7 +2427,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
mnodeMsg
->
retry
,
pTable
->
vgId
,
pTable
->
tid
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
mnodeMsg
->
retry
,
pTable
->
vgId
,
pTable
->
tid
,
pTable
->
uid
,
tstrerror
(
rpcMsg
->
code
),
mnodeMsg
->
rpcMsg
.
handle
);
pTable
->
uid
,
tstrerror
(
rpcMsg
->
code
),
mnodeMsg
->
rpcMsg
.
handle
);
dnodeDelayReprocessM
node
WriteMsg
(
mnodeMsg
);
dnodeDelayReprocessMWriteMsg
(
mnodeMsg
);
}
else
{
}
else
{
mError
(
"app:%p:%p, table:%s, failed to create in dnode, vgId:%d sid:%d uid:%"
PRIu64
", result:%s thandle:%p"
,
mError
(
"app:%p:%p, table:%s, failed to create in dnode, vgId:%d sid:%d uid:%"
PRIu64
", result:%s thandle:%p"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
pTable
->
vgId
,
pTable
->
tid
,
pTable
->
uid
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
pTable
->
vgId
,
pTable
->
tid
,
pTable
->
uid
,
...
@@ -2434,7 +2436,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
...
@@ -2434,7 +2436,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
SSdbOper
oper
=
{.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsChildTableSdb
,
.
pObj
=
pTable
};
SSdbOper
oper
=
{.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsChildTableSdb
,
.
pObj
=
pTable
};
sdbDeleteRow
(
&
oper
);
sdbDeleteRow
(
&
oper
);
dnodeSendRpcM
node
WriteRsp
(
mnodeMsg
,
rpcMsg
->
code
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
rpcMsg
->
code
);
}
}
}
}
}
}
...
@@ -2445,25 +2447,25 @@ static void mnodeProcessAlterTableRsp(SRpcMsg *rpcMsg) {
...
@@ -2445,25 +2447,25 @@ static void mnodeProcessAlterTableRsp(SRpcMsg *rpcMsg) {
SMnodeMsg
*
mnodeMsg
=
rpcMsg
->
ahandle
;
SMnodeMsg
*
mnodeMsg
=
rpcMsg
->
ahandle
;
mnodeMsg
->
received
++
;
mnodeMsg
->
received
++
;
SC
hildTableObj
*
pTable
=
(
SChild
TableObj
*
)
mnodeMsg
->
pTable
;
SC
TableObj
*
pTable
=
(
SC
TableObj
*
)
mnodeMsg
->
pTable
;
assert
(
pTable
);
assert
(
pTable
);
if
(
rpcMsg
->
code
==
TSDB_CODE_SUCCESS
||
rpcMsg
->
code
==
TSDB_CODE_TDB_TABLE_ALREADY_EXIST
)
{
if
(
rpcMsg
->
code
==
TSDB_CODE_SUCCESS
||
rpcMsg
->
code
==
TSDB_CODE_TDB_TABLE_ALREADY_EXIST
)
{
mDebug
(
"app:%p:%p, ctable:%s, altered in dnode, thandle:%p result:%s"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
mDebug
(
"app:%p:%p, ctable:%s, altered in dnode, thandle:%p result:%s"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
mnodeMsg
->
rpcMsg
.
handle
,
tstrerror
(
rpcMsg
->
code
));
pTable
->
info
.
tableId
,
mnodeMsg
->
rpcMsg
.
handle
,
tstrerror
(
rpcMsg
->
code
));
dnodeSendRpcM
node
WriteRsp
(
mnodeMsg
,
TSDB_CODE_SUCCESS
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
TSDB_CODE_SUCCESS
);
}
else
{
}
else
{
if
(
mnodeMsg
->
retry
++
<
3
)
{
if
(
mnodeMsg
->
retry
++
<
3
)
{
mDebug
(
"app:%p:%p, table:%s, alter table rsp received, need retry, times:%d result:%s thandle:%p"
,
mDebug
(
"app:%p:%p, table:%s, alter table rsp received, need retry, times:%d result:%s thandle:%p"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
mnodeMsg
->
retry
,
tstrerror
(
rpcMsg
->
code
),
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
mnodeMsg
->
retry
,
tstrerror
(
rpcMsg
->
code
),
mnodeMsg
->
rpcMsg
.
handle
);
mnodeMsg
->
rpcMsg
.
handle
);
dnodeDelayReprocessM
node
WriteMsg
(
mnodeMsg
);
dnodeDelayReprocessMWriteMsg
(
mnodeMsg
);
}
else
{
}
else
{
mError
(
"app:%p:%p, table:%s, failed to alter in dnode, result:%s thandle:%p"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
mError
(
"app:%p:%p, table:%s, failed to alter in dnode, result:%s thandle:%p"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
tstrerror
(
rpcMsg
->
code
),
mnodeMsg
->
rpcMsg
.
handle
);
pTable
->
info
.
tableId
,
tstrerror
(
rpcMsg
->
code
),
mnodeMsg
->
rpcMsg
.
handle
);
dnodeSendRpcM
node
WriteRsp
(
mnodeMsg
,
rpcMsg
->
code
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
rpcMsg
->
code
);
}
}
}
}
}
}
...
@@ -2483,7 +2485,7 @@ static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *pMsg) {
...
@@ -2483,7 +2485,7 @@ static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *pMsg) {
for
(
int32_t
t
=
0
;
t
<
pInfo
->
numOfTables
;
++
t
)
{
for
(
int32_t
t
=
0
;
t
<
pInfo
->
numOfTables
;
++
t
)
{
char
*
tableId
=
(
char
*
)(
pInfo
->
tableIds
+
t
*
TSDB_TABLE_FNAME_LEN
);
char
*
tableId
=
(
char
*
)(
pInfo
->
tableIds
+
t
*
TSDB_TABLE_FNAME_LEN
);
SC
hild
TableObj
*
pTable
=
mnodeGetChildTable
(
tableId
);
SCTableObj
*
pTable
=
mnodeGetChildTable
(
tableId
);
if
(
pTable
==
NULL
)
continue
;
if
(
pTable
==
NULL
)
continue
;
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mnodeGetDbByTableId
(
tableId
);
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mnodeGetDbByTableId
(
tableId
);
...
@@ -2607,7 +2609,7 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
...
@@ -2607,7 +2609,7 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
int32_t
cols
=
0
;
int32_t
cols
=
0
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
SC
hild
TableObj
*
pTable
=
NULL
;
SCTableObj
*
pTable
=
NULL
;
SPatternCompareInfo
info
=
PATTERN_COMPARE_INFO_INITIALIZER
;
SPatternCompareInfo
info
=
PATTERN_COMPARE_INFO_INITIALIZER
;
char
prefix
[
64
]
=
{
0
};
char
prefix
[
64
]
=
{
0
};
...
@@ -2843,7 +2845,7 @@ static int32_t mnodeRetrieveStreamTables(SShowObj *pShow, char *data, int32_t ro
...
@@ -2843,7 +2845,7 @@ static int32_t mnodeRetrieveStreamTables(SShowObj *pShow, char *data, int32_t ro
}
}
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
SC
hild
TableObj
*
pTable
=
NULL
;
SCTableObj
*
pTable
=
NULL
;
SPatternCompareInfo
info
=
PATTERN_COMPARE_INFO_INITIALIZER
;
SPatternCompareInfo
info
=
PATTERN_COMPARE_INFO_INITIALIZER
;
char
prefix
[
64
]
=
{
0
};
char
prefix
[
64
]
=
{
0
};
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
83d2acd5
...
@@ -529,7 +529,7 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -529,7 +529,7 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
SSdbOper
desc
=
{.
type
=
SDB_OPER_GLOBAL
,
.
pObj
=
pVgroup
,
.
table
=
tsVgroupSdb
};
SSdbOper
desc
=
{.
type
=
SDB_OPER_GLOBAL
,
.
pObj
=
pVgroup
,
.
table
=
tsVgroupSdb
};
(
void
)
sdbUpdateRow
(
&
desc
);
(
void
)
sdbUpdateRow
(
&
desc
);
dnodeReprocessM
node
WriteMsg
(
pMsg
);
dnodeReprocessMWriteMsg
(
pMsg
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
// if (pVgroup->status == TAOS_VG_STATUS_CREATING || pVgroup->status == TAOS_VG_STATUS_READY) {
// if (pVgroup->status == TAOS_VG_STATUS_CREATING || pVgroup->status == TAOS_VG_STATUS_READY) {
// mInfo("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d", pMsg->rpcMsg.ahandle, pMsg, pVgroup->vgId,
// mInfo("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d", pMsg->rpcMsg.ahandle, pMsg, pVgroup->vgId,
...
@@ -537,7 +537,7 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -537,7 +537,7 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
// pVgroup->status = TAOS_VG_STATUS_READY;
// pVgroup->status = TAOS_VG_STATUS_READY;
// SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .table = tsVgroupSdb};
// SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .table = tsVgroupSdb};
// (void)sdbUpdateRow(&desc);
// (void)sdbUpdateRow(&desc);
// dnodeReprocessM
node
WriteMsg(pMsg);
// dnodeReprocessMWriteMsg(pMsg);
// return TSDB_CODE_MND_ACTION_IN_PROGRESS;
// return TSDB_CODE_MND_ACTION_IN_PROGRESS;
// } else {
// } else {
// mError("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d, but vgroup is dropping", pMsg->rpcMsg.ahandle,
// mError("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d, but vgroup is dropping", pMsg->rpcMsg.ahandle,
...
@@ -694,7 +694,7 @@ static bool mnodeFilterVgroups(SVgObj *pVgroup, STableObj *pTable) {
...
@@ -694,7 +694,7 @@ static bool mnodeFilterVgroups(SVgObj *pVgroup, STableObj *pTable) {
return
true
;
return
true
;
}
}
SC
hildTableObj
*
pCTable
=
(
SChild
TableObj
*
)
pTable
;
SC
TableObj
*
pCTable
=
(
SC
TableObj
*
)
pTable
;
if
(
pVgroup
->
vgId
==
pCTable
->
vgId
)
{
if
(
pVgroup
->
vgId
==
pCTable
->
vgId
)
{
return
true
;
return
true
;
}
else
{
}
else
{
...
@@ -791,7 +791,7 @@ static int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, v
...
@@ -791,7 +791,7 @@ static int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, v
return
numOfRows
;
return
numOfRows
;
}
}
void
mnodeAddTableIntoVgroup
(
SVgObj
*
pVgroup
,
SC
hild
TableObj
*
pTable
)
{
void
mnodeAddTableIntoVgroup
(
SVgObj
*
pVgroup
,
SCTableObj
*
pTable
)
{
int32_t
idPoolSize
=
taosIdPoolMaxSize
(
pVgroup
->
idPool
);
int32_t
idPoolSize
=
taosIdPoolMaxSize
(
pVgroup
->
idPool
);
if
(
pTable
->
tid
>
idPoolSize
)
{
if
(
pTable
->
tid
>
idPoolSize
)
{
mnodeAllocVgroupIdPool
(
pVgroup
);
mnodeAllocVgroupIdPool
(
pVgroup
);
...
@@ -807,7 +807,7 @@ void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable) {
...
@@ -807,7 +807,7 @@ void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable) {
}
}
}
}
void
mnodeRemoveTableFromVgroup
(
SVgObj
*
pVgroup
,
SC
hild
TableObj
*
pTable
)
{
void
mnodeRemoveTableFromVgroup
(
SVgObj
*
pVgroup
,
SCTableObj
*
pTable
)
{
if
(
pTable
->
tid
>=
1
)
{
if
(
pTable
->
tid
>=
1
)
{
taosFreeId
(
pVgroup
->
idPool
,
pTable
->
tid
);
taosFreeId
(
pVgroup
->
idPool
,
pTable
->
tid
);
pVgroup
->
numOfTables
--
;
pVgroup
->
numOfTables
--
;
...
@@ -970,7 +970,7 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
...
@@ -970,7 +970,7 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mnodeMsg
->
pVgroup
=
NULL
;
mnodeMsg
->
pVgroup
=
NULL
;
mnodeDestroyVgroup
(
pVgroup
);
mnodeDestroyVgroup
(
pVgroup
);
dnodeSendRpcM
node
WriteRsp
(
mnodeMsg
,
code
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
code
);
}
}
}
else
{
}
else
{
SSdbOper
oper
=
{
SSdbOper
oper
=
{
...
@@ -979,7 +979,7 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
...
@@ -979,7 +979,7 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
.
pObj
=
pVgroup
.
pObj
=
pVgroup
};
};
sdbDeleteRow
(
&
oper
);
sdbDeleteRow
(
&
oper
);
dnodeSendRpcM
node
WriteRsp
(
mnodeMsg
,
mnodeMsg
->
code
);
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
mnodeMsg
->
code
);
}
}
}
}
...
@@ -1041,7 +1041,7 @@ static void mnodeProcessDropVnodeRsp(SRpcMsg *rpcMsg) {
...
@@ -1041,7 +1041,7 @@ static void mnodeProcessDropVnodeRsp(SRpcMsg *rpcMsg) {
code
=
TSDB_CODE_MND_SDB_ERROR
;
code
=
TSDB_CODE_MND_SDB_ERROR
;
}
}
dnodeReprocessM
node
WriteMsg
(
mnodeMsg
);
dnodeReprocessMWriteMsg
(
mnodeMsg
);
}
}
static
int32_t
mnodeProcessVnodeCfgMsg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeProcessVnodeCfgMsg
(
SMnodeMsg
*
pMsg
)
{
...
...
src/plugins/http/src/httpQueue.c
浏览文件 @
83d2acd5
...
@@ -49,7 +49,7 @@ static taos_queue tsHttpQueue;
...
@@ -49,7 +49,7 @@ static taos_queue tsHttpQueue;
void
httpDispatchToResultQueue
(
void
*
param
,
TAOS_RES
*
result
,
int32_t
numOfRows
,
void
(
*
fp
)(
void
*
param
,
void
*
result
,
int32_t
numOfRows
))
{
void
httpDispatchToResultQueue
(
void
*
param
,
TAOS_RES
*
result
,
int32_t
numOfRows
,
void
(
*
fp
)(
void
*
param
,
void
*
result
,
int32_t
numOfRows
))
{
if
(
tsHttpQueue
!=
NULL
)
{
if
(
tsHttpQueue
!=
NULL
)
{
SHttpResult
*
pMsg
=
(
SHttpResult
*
)
taosAllocateQitem
(
sizeof
(
SHttpResult
));
SHttpResult
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SHttpResult
));
pMsg
->
param
=
param
;
pMsg
->
param
=
param
;
pMsg
->
result
=
result
;
pMsg
->
result
=
result
;
pMsg
->
numOfRows
=
numOfRows
;
pMsg
->
numOfRows
=
numOfRows
;
...
...
src/plugins/monitor/src/monitorMain.c
浏览文件 @
83d2acd5
...
@@ -27,12 +27,12 @@
...
@@ -27,12 +27,12 @@
#include "monitor.h"
#include "monitor.h"
#include "taoserror.h"
#include "taoserror.h"
#define m
onitor
Fatal(...) { if (monitorDebugFlag & DEBUG_FATAL) { taosPrintLog("MON FATAL ", 255, __VA_ARGS__); }}
#define m
n
Fatal(...) { if (monitorDebugFlag & DEBUG_FATAL) { taosPrintLog("MON FATAL ", 255, __VA_ARGS__); }}
#define m
onitor
Error(...) { if (monitorDebugFlag & DEBUG_ERROR) { taosPrintLog("MON ERROR ", 255, __VA_ARGS__); }}
#define m
n
Error(...) { if (monitorDebugFlag & DEBUG_ERROR) { taosPrintLog("MON ERROR ", 255, __VA_ARGS__); }}
#define m
onitor
Warn(...) { if (monitorDebugFlag & DEBUG_WARN) { taosPrintLog("MON WARN ", 255, __VA_ARGS__); }}
#define m
n
Warn(...) { if (monitorDebugFlag & DEBUG_WARN) { taosPrintLog("MON WARN ", 255, __VA_ARGS__); }}
#define m
onitor
Info(...) { if (monitorDebugFlag & DEBUG_INFO) { taosPrintLog("MON ", 255, __VA_ARGS__); }}
#define m
n
Info(...) { if (monitorDebugFlag & DEBUG_INFO) { taosPrintLog("MON ", 255, __VA_ARGS__); }}
#define m
onitor
Debug(...) { if (monitorDebugFlag & DEBUG_DEBUG) { taosPrintLog("MON ", monitorDebugFlag, __VA_ARGS__); }}
#define m
n
Debug(...) { if (monitorDebugFlag & DEBUG_DEBUG) { taosPrintLog("MON ", monitorDebugFlag, __VA_ARGS__); }}
#define m
onitor
Trace(...) { if (monitorDebugFlag & DEBUG_TRACE) { taosPrintLog("MON ", monitorDebugFlag, __VA_ARGS__); }}
#define m
n
Trace(...) { if (monitorDebugFlag & DEBUG_TRACE) { taosPrintLog("MON ", monitorDebugFlag, __VA_ARGS__); }}
#define SQL_LENGTH 1030
#define SQL_LENGTH 1030
#define LOG_LEN_STR 100
#define LOG_LEN_STR 100
...
@@ -91,12 +91,12 @@ int32_t monitorInitSystem() {
...
@@ -91,12 +91,12 @@ int32_t monitorInitSystem() {
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
if
(
pthread_create
(
&
tsMonitor
.
thread
,
&
thAttr
,
monitorThreadFunc
,
NULL
))
{
if
(
pthread_create
(
&
tsMonitor
.
thread
,
&
thAttr
,
monitorThreadFunc
,
NULL
))
{
m
onitor
Error
(
"failed to create thread to for monitor module, reason:%s"
,
strerror
(
errno
));
m
n
Error
(
"failed to create thread to for monitor module, reason:%s"
,
strerror
(
errno
));
return
-
1
;
return
-
1
;
}
}
pthread_attr_destroy
(
&
thAttr
);
pthread_attr_destroy
(
&
thAttr
);
m
onitor
Debug
(
"monitor thread is launched"
);
m
n
Debug
(
"monitor thread is launched"
);
monitorStartSystemFp
=
monitorStartSystem
;
monitorStartSystemFp
=
monitorStartSystem
;
monitorStopSystemFp
=
monitorStopSystem
;
monitorStopSystemFp
=
monitorStopSystem
;
...
@@ -107,12 +107,12 @@ int32_t monitorStartSystem() {
...
@@ -107,12 +107,12 @@ int32_t monitorStartSystem() {
taos_init
();
taos_init
();
tsMonitor
.
start
=
1
;
tsMonitor
.
start
=
1
;
monitorExecuteSQLFp
=
monitorExecuteSQL
;
monitorExecuteSQLFp
=
monitorExecuteSQL
;
m
onitor
Info
(
"monitor module start"
);
m
n
Info
(
"monitor module start"
);
return
0
;
return
0
;
}
}
static
void
*
monitorThreadFunc
(
void
*
param
)
{
static
void
*
monitorThreadFunc
(
void
*
param
)
{
m
onitor
Debug
(
"starting to initialize monitor module ..."
);
m
n
Debug
(
"starting to initialize monitor module ..."
);
while
(
1
)
{
while
(
1
)
{
static
int32_t
accessTimes
=
0
;
static
int32_t
accessTimes
=
0
;
...
@@ -121,7 +121,7 @@ static void *monitorThreadFunc(void *param) {
...
@@ -121,7 +121,7 @@ static void *monitorThreadFunc(void *param) {
if
(
tsMonitor
.
quiting
)
{
if
(
tsMonitor
.
quiting
)
{
tsMonitor
.
state
=
MON_STATE_NOT_INIT
;
tsMonitor
.
state
=
MON_STATE_NOT_INIT
;
m
onitor
Info
(
"monitor thread will quit, for taosd is quiting"
);
m
n
Info
(
"monitor thread will quit, for taosd is quiting"
);
break
;
break
;
}
else
{
}
else
{
taosGetDisk
();
taosGetDisk
();
...
@@ -132,7 +132,7 @@ static void *monitorThreadFunc(void *param) {
...
@@ -132,7 +132,7 @@ static void *monitorThreadFunc(void *param) {
}
}
if
(
dnodeGetDnodeId
()
<=
0
)
{
if
(
dnodeGetDnodeId
()
<=
0
)
{
m
onitor
Debug
(
"dnode not initialized, waiting for 3000 ms to start monitor module"
);
m
n
Debug
(
"dnode not initialized, waiting for 3000 ms to start monitor module"
);
continue
;
continue
;
}
}
...
@@ -140,10 +140,10 @@ static void *monitorThreadFunc(void *param) {
...
@@ -140,10 +140,10 @@ static void *monitorThreadFunc(void *param) {
tsMonitor
.
state
=
MON_STATE_NOT_INIT
;
tsMonitor
.
state
=
MON_STATE_NOT_INIT
;
tsMonitor
.
conn
=
taos_connect
(
NULL
,
"monitor"
,
tsInternalPass
,
""
,
0
);
tsMonitor
.
conn
=
taos_connect
(
NULL
,
"monitor"
,
tsInternalPass
,
""
,
0
);
if
(
tsMonitor
.
conn
==
NULL
)
{
if
(
tsMonitor
.
conn
==
NULL
)
{
m
onitor
Error
(
"failed to connect to database, reason:%s"
,
tstrerror
(
terrno
));
m
n
Error
(
"failed to connect to database, reason:%s"
,
tstrerror
(
terrno
));
continue
;
continue
;
}
else
{
}
else
{
m
onitor
Debug
(
"connect to database success"
);
m
n
Debug
(
"connect to database success"
);
}
}
}
}
...
@@ -155,10 +155,10 @@ static void *monitorThreadFunc(void *param) {
...
@@ -155,10 +155,10 @@ static void *monitorThreadFunc(void *param) {
taos_free_result
(
res
);
taos_free_result
(
res
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
m
onitor
Error
(
"failed to exec sql:%s, reason:%s"
,
tsMonitor
.
sql
,
tstrerror
(
code
));
m
n
Error
(
"failed to exec sql:%s, reason:%s"
,
tsMonitor
.
sql
,
tstrerror
(
code
));
break
;
break
;
}
else
{
}
else
{
m
onitor
Debug
(
"successfully to exec sql:%s"
,
tsMonitor
.
sql
);
m
n
Debug
(
"successfully to exec sql:%s"
,
tsMonitor
.
sql
);
}
}
}
}
...
@@ -174,7 +174,7 @@ static void *monitorThreadFunc(void *param) {
...
@@ -174,7 +174,7 @@ static void *monitorThreadFunc(void *param) {
}
}
}
}
m
onitor
Info
(
"monitor thread is stopped"
);
m
n
Info
(
"monitor thread is stopped"
);
return
NULL
;
return
NULL
;
}
}
...
@@ -238,7 +238,7 @@ void monitorStopSystem() {
...
@@ -238,7 +238,7 @@ void monitorStopSystem() {
tsMonitor
.
start
=
0
;
tsMonitor
.
start
=
0
;
tsMonitor
.
state
=
MON_STATE_NOT_INIT
;
tsMonitor
.
state
=
MON_STATE_NOT_INIT
;
monitorExecuteSQLFp
=
NULL
;
monitorExecuteSQLFp
=
NULL
;
m
onitor
Info
(
"monitor module stopped"
);
m
n
Info
(
"monitor module stopped"
);
}
}
void
monitorCleanUpSystem
()
{
void
monitorCleanUpSystem
()
{
...
@@ -249,7 +249,7 @@ void monitorCleanUpSystem() {
...
@@ -249,7 +249,7 @@ void monitorCleanUpSystem() {
taos_close
(
tsMonitor
.
conn
);
taos_close
(
tsMonitor
.
conn
);
tsMonitor
.
conn
=
NULL
;
tsMonitor
.
conn
=
NULL
;
}
}
m
onitor
Info
(
"monitor module is cleaned up"
);
m
n
Info
(
"monitor module is cleaned up"
);
}
}
// unit is MB
// unit is MB
...
@@ -257,13 +257,13 @@ static int32_t monitorBuildMemorySql(char *sql) {
...
@@ -257,13 +257,13 @@ static int32_t monitorBuildMemorySql(char *sql) {
float
sysMemoryUsedMB
=
0
;
float
sysMemoryUsedMB
=
0
;
bool
suc
=
taosGetSysMemory
(
&
sysMemoryUsedMB
);
bool
suc
=
taosGetSysMemory
(
&
sysMemoryUsedMB
);
if
(
!
suc
)
{
if
(
!
suc
)
{
m
onitor
Debug
(
"failed to get sys memory info"
);
m
n
Debug
(
"failed to get sys memory info"
);
}
}
float
procMemoryUsedMB
=
0
;
float
procMemoryUsedMB
=
0
;
suc
=
taosGetProcMemory
(
&
procMemoryUsedMB
);
suc
=
taosGetProcMemory
(
&
procMemoryUsedMB
);
if
(
!
suc
)
{
if
(
!
suc
)
{
m
onitor
Debug
(
"failed to get proc memory info"
);
m
n
Debug
(
"failed to get proc memory info"
);
}
}
return
sprintf
(
sql
,
", %f, %f, %d"
,
procMemoryUsedMB
,
sysMemoryUsedMB
,
tsTotalMemoryMB
);
return
sprintf
(
sql
,
", %f, %f, %d"
,
procMemoryUsedMB
,
sysMemoryUsedMB
,
tsTotalMemoryMB
);
...
@@ -274,7 +274,7 @@ static int32_t monitorBuildCpuSql(char *sql) {
...
@@ -274,7 +274,7 @@ static int32_t monitorBuildCpuSql(char *sql) {
float
sysCpuUsage
=
0
,
procCpuUsage
=
0
;
float
sysCpuUsage
=
0
,
procCpuUsage
=
0
;
bool
suc
=
taosGetCpuUsage
(
&
sysCpuUsage
,
&
procCpuUsage
);
bool
suc
=
taosGetCpuUsage
(
&
sysCpuUsage
,
&
procCpuUsage
);
if
(
!
suc
)
{
if
(
!
suc
)
{
m
onitor
Debug
(
"failed to get cpu usage"
);
m
n
Debug
(
"failed to get cpu usage"
);
}
}
if
(
sysCpuUsage
<=
procCpuUsage
)
{
if
(
sysCpuUsage
<=
procCpuUsage
)
{
...
@@ -294,14 +294,14 @@ static int32_t monitorBuildBandSql(char *sql) {
...
@@ -294,14 +294,14 @@ static int32_t monitorBuildBandSql(char *sql) {
float
bandSpeedKb
=
0
;
float
bandSpeedKb
=
0
;
bool
suc
=
taosGetBandSpeed
(
&
bandSpeedKb
);
bool
suc
=
taosGetBandSpeed
(
&
bandSpeedKb
);
if
(
!
suc
)
{
if
(
!
suc
)
{
m
onitor
Debug
(
"failed to get bandwidth speed"
);
m
n
Debug
(
"failed to get bandwidth speed"
);
}
}
return
sprintf
(
sql
,
", %f"
,
bandSpeedKb
);
return
sprintf
(
sql
,
", %f"
,
bandSpeedKb
);
}
}
static
int32_t
monitorBuildReqSql
(
char
*
sql
)
{
static
int32_t
monitorBuildReqSql
(
char
*
sql
)
{
S
Dnode
StatisInfo
info
=
dnodeGetStatisInfo
();
SStatisInfo
info
=
dnodeGetStatisInfo
();
return
sprintf
(
sql
,
", %d, %d, %d)"
,
info
.
httpReqNum
,
info
.
queryReqNum
,
info
.
submitReqNum
);
return
sprintf
(
sql
,
", %d, %d, %d)"
,
info
.
httpReqNum
,
info
.
queryReqNum
,
info
.
submitReqNum
);
}
}
...
@@ -309,7 +309,7 @@ static int32_t monitorBuildIoSql(char *sql) {
...
@@ -309,7 +309,7 @@ static int32_t monitorBuildIoSql(char *sql) {
float
readKB
=
0
,
writeKB
=
0
;
float
readKB
=
0
,
writeKB
=
0
;
bool
suc
=
taosGetProcIO
(
&
readKB
,
&
writeKB
);
bool
suc
=
taosGetProcIO
(
&
readKB
,
&
writeKB
);
if
(
!
suc
)
{
if
(
!
suc
)
{
m
onitor
Debug
(
"failed to get io info"
);
m
n
Debug
(
"failed to get io info"
);
}
}
return
sprintf
(
sql
,
", %f, %f"
,
readKB
,
writeKB
);
return
sprintf
(
sql
,
", %f, %f"
,
readKB
,
writeKB
);
...
@@ -332,19 +332,19 @@ static void monitorSaveSystemInfo() {
...
@@ -332,19 +332,19 @@ static void monitorSaveSystemInfo() {
taos_free_result
(
res
);
taos_free_result
(
res
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
m
onitor
Error
(
"failed to save system info, reason:%s, sql:%s"
,
tstrerror
(
code
),
tsMonitor
.
sql
);
m
n
Error
(
"failed to save system info, reason:%s, sql:%s"
,
tstrerror
(
code
),
tsMonitor
.
sql
);
}
else
{
}
else
{
m
onitor
Debug
(
"successfully to save system info, sql:%s"
,
tsMonitor
.
sql
);
m
n
Debug
(
"successfully to save system info, sql:%s"
,
tsMonitor
.
sql
);
}
}
}
}
static
void
montiorExecSqlCb
(
void
*
param
,
TAOS_RES
*
result
,
int32_t
code
)
{
static
void
montiorExecSqlCb
(
void
*
param
,
TAOS_RES
*
result
,
int32_t
code
)
{
int32_t
c
=
taos_errno
(
result
);
int32_t
c
=
taos_errno
(
result
);
if
(
c
!=
TSDB_CODE_SUCCESS
)
{
if
(
c
!=
TSDB_CODE_SUCCESS
)
{
m
onitor
Error
(
"save %s failed, reason:%s"
,
(
char
*
)
param
,
tstrerror
(
c
));
m
n
Error
(
"save %s failed, reason:%s"
,
(
char
*
)
param
,
tstrerror
(
c
));
}
else
{
}
else
{
int32_t
rows
=
taos_affected_rows
(
result
);
int32_t
rows
=
taos_affected_rows
(
result
);
m
onitor
Debug
(
"save %s succ, rows:%d"
,
(
char
*
)
param
,
rows
);
m
n
Debug
(
"save %s succ, rows:%d"
,
(
char
*
)
param
,
rows
);
}
}
taos_free_result
(
result
);
taos_free_result
(
result
);
...
@@ -380,7 +380,7 @@ void monitorSaveAcctLog(SAcctMonitorObj *pMon) {
...
@@ -380,7 +380,7 @@ void monitorSaveAcctLog(SAcctMonitorObj *pMon) {
pMon
->
totalConns
,
pMon
->
maxConns
,
pMon
->
totalConns
,
pMon
->
maxConns
,
pMon
->
accessState
);
pMon
->
accessState
);
m
onitor
Debug
(
"save account info, sql:%s"
,
sql
);
m
n
Debug
(
"save account info, sql:%s"
,
sql
);
taos_query_a
(
tsMonitor
.
conn
,
sql
,
montiorExecSqlCb
,
"account info"
);
taos_query_a
(
tsMonitor
.
conn
,
sql
,
montiorExecSqlCb
,
"account info"
);
}
}
...
@@ -401,13 +401,13 @@ void monitorSaveLog(int32_t level, const char *const format, ...) {
...
@@ -401,13 +401,13 @@ void monitorSaveLog(int32_t level, const char *const format, ...) {
len
+=
sprintf
(
sql
+
len
,
"', '%s')"
,
tsLocalEp
);
len
+=
sprintf
(
sql
+
len
,
"', '%s')"
,
tsLocalEp
);
sql
[
len
++
]
=
0
;
sql
[
len
++
]
=
0
;
m
onitor
Debug
(
"save log, sql: %s"
,
sql
);
m
n
Debug
(
"save log, sql: %s"
,
sql
);
taos_query_a
(
tsMonitor
.
conn
,
sql
,
montiorExecSqlCb
,
"log"
);
taos_query_a
(
tsMonitor
.
conn
,
sql
,
montiorExecSqlCb
,
"log"
);
}
}
void
monitorExecuteSQL
(
char
*
sql
)
{
void
monitorExecuteSQL
(
char
*
sql
)
{
if
(
tsMonitor
.
state
!=
MON_STATE_INITED
)
return
;
if
(
tsMonitor
.
state
!=
MON_STATE_INITED
)
return
;
m
onitor
Debug
(
"execute sql:%s"
,
sql
);
m
n
Debug
(
"execute sql:%s"
,
sql
);
taos_query_a
(
tsMonitor
.
conn
,
sql
,
montiorExecSqlCb
,
"sql"
);
taos_query_a
(
tsMonitor
.
conn
,
sql
,
montiorExecSqlCb
,
"sql"
);
}
}
src/vnode/src/vnodeCfg.c
浏览文件 @
83d2acd5
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
#include "tsdb.h"
#include "tsdb.h"
#include "dnode.h"
#include "dnode.h"
#include "vnodeInt.h"
#include "vnodeInt.h"
#include "vnodeVersion.h"
#include "vnodeCfg.h"
#include "vnodeCfg.h"
static
void
vnodeLoadCfg
(
SVnodeObj
*
pVnode
,
SCreateVnodeMsg
*
vnodeMsg
)
{
static
void
vnodeLoadCfg
(
SVnodeObj
*
pVnode
,
SCreateVnodeMsg
*
vnodeMsg
)
{
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
83d2acd5
...
@@ -15,17 +15,11 @@
...
@@ -15,17 +15,11 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "tcache.h"
#include "cJSON.h"
#include "dnode.h"
#include "hash.h"
#include "taoserror.h"
#include "taoserror.h"
#include "taosmsg.h"
#include "taosmsg.h"
#include "tglobal.h"
#include "tglobal.h"
#include "trpc.h"
#include "trpc.h"
#include "tsdb.h"
#include "tsdb.h"
#include "ttimer.h"
#include "tutil.h"
#include "tutil.h"
#include "vnode.h"
#include "vnode.h"
#include "vnodeInt.h"
#include "vnodeInt.h"
...
@@ -34,7 +28,7 @@
...
@@ -34,7 +28,7 @@
#include "vnodeCfg.h"
#include "vnodeCfg.h"
#include "vnodeVersion.h"
#include "vnodeVersion.h"
static
SHashObj
*
ts
Dnode
VnodesHash
;
static
SHashObj
*
tsVnodesHash
;
static
void
vnodeCleanUp
(
SVnodeObj
*
pVnode
);
static
void
vnodeCleanUp
(
SVnodeObj
*
pVnode
);
static
int
vnodeProcessTsdbStatus
(
void
*
arg
,
int
status
);
static
int
vnodeProcessTsdbStatus
(
void
*
arg
,
int
status
);
static
uint32_t
vnodeGetFileInfo
(
void
*
ahandle
,
char
*
name
,
uint32_t
*
index
,
uint32_t
eindex
,
int64_t
*
size
,
uint64_t
*
fversion
);
static
uint32_t
vnodeGetFileInfo
(
void
*
ahandle
,
char
*
name
,
uint32_t
*
index
,
uint32_t
eindex
,
int64_t
*
size
,
uint64_t
*
fversion
);
...
@@ -67,8 +61,8 @@ int32_t vnodeInitResources() {
...
@@ -67,8 +61,8 @@ int32_t vnodeInitResources() {
vnodeInitWriteFp
();
vnodeInitWriteFp
();
vnodeInitReadFp
();
vnodeInitReadFp
();
ts
Dnode
VnodesHash
=
taosHashInit
(
TSDB_MIN_VNODES
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
true
);
tsVnodesHash
=
taosHashInit
(
TSDB_MIN_VNODES
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
true
);
if
(
ts
Dnode
VnodesHash
==
NULL
)
{
if
(
tsVnodesHash
==
NULL
)
{
vError
(
"failed to init vnode list"
);
vError
(
"failed to init vnode list"
);
return
TSDB_CODE_VND_OUT_OF_MEMORY
;
return
TSDB_CODE_VND_OUT_OF_MEMORY
;
}
}
...
@@ -77,10 +71,10 @@ int32_t vnodeInitResources() {
...
@@ -77,10 +71,10 @@ int32_t vnodeInitResources() {
}
}
void
vnodeCleanupResources
()
{
void
vnodeCleanupResources
()
{
if
(
ts
Dnode
VnodesHash
!=
NULL
)
{
if
(
tsVnodesHash
!=
NULL
)
{
vDebug
(
"vnode list is cleanup"
);
vDebug
(
"vnode list is cleanup"
);
taosHashCleanup
(
ts
Dnode
VnodesHash
);
taosHashCleanup
(
tsVnodesHash
);
ts
Dnode
VnodesHash
=
NULL
;
tsVnodesHash
=
NULL
;
}
}
syncCleanUp
();
syncCleanUp
();
...
@@ -349,7 +343,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
...
@@ -349,7 +343,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
pVnode
->
status
=
TAOS_VN_STATUS_READY
;
pVnode
->
status
=
TAOS_VN_STATUS_READY
;
vDebug
(
"vgId:%d, vnode is opened in %s, pVnode:%p"
,
pVnode
->
vgId
,
rootDir
,
pVnode
);
vDebug
(
"vgId:%d, vnode is opened in %s, pVnode:%p"
,
pVnode
->
vgId
,
rootDir
,
pVnode
);
taosHashPut
(
ts
Dnode
VnodesHash
,
(
const
char
*
)
&
pVnode
->
vgId
,
sizeof
(
int32_t
),
(
char
*
)(
&
pVnode
),
sizeof
(
SVnodeObj
*
));
taosHashPut
(
tsVnodesHash
,
(
const
char
*
)
&
pVnode
->
vgId
,
sizeof
(
int32_t
),
(
char
*
)(
&
pVnode
),
sizeof
(
SVnodeObj
*
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -441,7 +435,7 @@ void vnodeRelease(void *pVnodeRaw) {
...
@@ -441,7 +435,7 @@ void vnodeRelease(void *pVnodeRaw) {
tsem_destroy
(
&
pVnode
->
sem
);
tsem_destroy
(
&
pVnode
->
sem
);
free
(
pVnode
);
free
(
pVnode
);
int32_t
count
=
taosHashGetSize
(
ts
Dnode
VnodesHash
);
int32_t
count
=
taosHashGetSize
(
tsVnodesHash
);
vDebug
(
"vgId:%d, vnode is destroyed, vnodes:%d"
,
vgId
,
count
);
vDebug
(
"vgId:%d, vnode is destroyed, vnodes:%d"
,
vgId
,
count
);
}
}
...
@@ -458,7 +452,7 @@ static void vnodeIncRef(void *ptNode) {
...
@@ -458,7 +452,7 @@ static void vnodeIncRef(void *ptNode) {
}
}
void
*
vnodeAcquire
(
int32_t
vgId
)
{
void
*
vnodeAcquire
(
int32_t
vgId
)
{
SVnodeObj
**
ppVnode
=
taosHashGetCB
(
ts
Dnode
VnodesHash
,
&
vgId
,
sizeof
(
int32_t
),
vnodeIncRef
,
NULL
,
sizeof
(
void
*
));
SVnodeObj
**
ppVnode
=
taosHashGetCB
(
tsVnodesHash
,
&
vgId
,
sizeof
(
int32_t
),
vnodeIncRef
,
NULL
,
sizeof
(
void
*
));
if
(
ppVnode
==
NULL
||
*
ppVnode
==
NULL
)
{
if
(
ppVnode
==
NULL
||
*
ppVnode
==
NULL
)
{
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
...
@@ -497,7 +491,7 @@ static void vnodeBuildVloadMsg(SVnodeObj *pVnode, SStatusMsg *pStatus) {
...
@@ -497,7 +491,7 @@ static void vnodeBuildVloadMsg(SVnodeObj *pVnode, SStatusMsg *pStatus) {
}
}
int32_t
vnodeGetVnodeList
(
int32_t
vnodeList
[],
int32_t
*
numOfVnodes
)
{
int32_t
vnodeGetVnodeList
(
int32_t
vnodeList
[],
int32_t
*
numOfVnodes
)
{
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
ts
Dnode
VnodesHash
);
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
tsVnodesHash
);
while
(
taosHashIterNext
(
pIter
))
{
while
(
taosHashIterNext
(
pIter
))
{
SVnodeObj
**
pVnode
=
taosHashIterGet
(
pIter
);
SVnodeObj
**
pVnode
=
taosHashIterGet
(
pIter
);
if
(
pVnode
==
NULL
)
continue
;
if
(
pVnode
==
NULL
)
continue
;
...
@@ -518,7 +512,7 @@ int32_t vnodeGetVnodeList(int32_t vnodeList[], int32_t *numOfVnodes) {
...
@@ -518,7 +512,7 @@ int32_t vnodeGetVnodeList(int32_t vnodeList[], int32_t *numOfVnodes) {
void
vnodeBuildStatusMsg
(
void
*
param
)
{
void
vnodeBuildStatusMsg
(
void
*
param
)
{
SStatusMsg
*
pStatus
=
param
;
SStatusMsg
*
pStatus
=
param
;
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
ts
Dnode
VnodesHash
);
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
tsVnodesHash
);
while
(
taosHashIterNext
(
pIter
))
{
while
(
taosHashIterNext
(
pIter
))
{
SVnodeObj
**
pVnode
=
taosHashIterGet
(
pIter
);
SVnodeObj
**
pVnode
=
taosHashIterGet
(
pIter
);
...
@@ -547,7 +541,7 @@ void vnodeSetAccess(SVgroupAccess *pAccess, int32_t numOfVnodes) {
...
@@ -547,7 +541,7 @@ void vnodeSetAccess(SVgroupAccess *pAccess, int32_t numOfVnodes) {
static
void
vnodeCleanUp
(
SVnodeObj
*
pVnode
)
{
static
void
vnodeCleanUp
(
SVnodeObj
*
pVnode
)
{
// remove from hash, so new messages wont be consumed
// remove from hash, so new messages wont be consumed
taosHashRemove
(
ts
Dnode
VnodesHash
,
(
const
char
*
)
&
pVnode
->
vgId
,
sizeof
(
int32_t
));
taosHashRemove
(
tsVnodesHash
,
(
const
char
*
)
&
pVnode
->
vgId
,
sizeof
(
int32_t
));
if
(
pVnode
->
status
!=
TAOS_VN_STATUS_INIT
)
{
if
(
pVnode
->
status
!=
TAOS_VN_STATUS_INIT
)
{
// it may be in updateing or reset state, then it shall wait
// it may be in updateing or reset state, then it shall wait
...
...
src/vnode/src/vnodeRead.c
浏览文件 @
83d2acd5
...
@@ -15,13 +15,10 @@
...
@@ -15,13 +15,10 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#define _NON_BLOCKING_RETRIEVE 0
#define _NON_BLOCKING_RETRIEVE 0
#include "os.h"
#include "os.h"
#include "tglobal.h"
#include "tglobal.h"
#include "taoserror.h"
#include "taoserror.h"
#include "taosmsg.h"
#include "taosmsg.h"
#include "tcache.h"
#include "query.h"
#include "query.h"
#include "trpc.h"
#include "trpc.h"
#include "tsdb.h"
#include "tsdb.h"
...
@@ -29,9 +26,9 @@
...
@@ -29,9 +26,9 @@
#include "vnodeInt.h"
#include "vnodeInt.h"
#include "tqueue.h"
#include "tqueue.h"
static
int32_t
(
*
vnodeProcessReadMsgFp
[
TSDB_MSG_TYPE_MAX
])(
SVnodeObj
*
pVnode
,
SVReadMsg
*
pRead
Msg
);
static
int32_t
(
*
vnodeProcessReadMsgFp
[
TSDB_MSG_TYPE_MAX
])(
SVnodeObj
*
pVnode
,
SVReadMsg
*
pRead
);
static
int32_t
vnodeProcessQueryMsg
(
SVnodeObj
*
pVnode
,
SVReadMsg
*
pRead
Msg
);
static
int32_t
vnodeProcessQueryMsg
(
SVnodeObj
*
pVnode
,
SVReadMsg
*
pRead
);
static
int32_t
vnodeProcessFetchMsg
(
SVnodeObj
*
pVnode
,
SVReadMsg
*
pRead
Msg
);
static
int32_t
vnodeProcessFetchMsg
(
SVnodeObj
*
pVnode
,
SVReadMsg
*
pRead
);
static
int32_t
vnodeNotifyCurrentQhandle
(
void
*
handle
,
void
*
qhandle
,
int32_t
vgId
);
static
int32_t
vnodeNotifyCurrentQhandle
(
void
*
handle
,
void
*
qhandle
,
int32_t
vgId
);
void
vnodeInitReadFp
(
void
)
{
void
vnodeInitReadFp
(
void
)
{
...
@@ -44,16 +41,16 @@ void vnodeInitReadFp(void) {
...
@@ -44,16 +41,16 @@ void vnodeInitReadFp(void) {
// still required, or there will be a deadlock, so we don’t do any check here, but put the check codes before the
// still required, or there will be a deadlock, so we don’t do any check here, but put the check codes before the
// request enters the queue
// request enters the queue
//
//
int32_t
vnodeProcessRead
(
void
*
param
,
SVReadMsg
*
pRead
Msg
)
{
int32_t
vnodeProcessRead
(
void
*
param
,
SVReadMsg
*
pRead
)
{
SVnodeObj
*
pVnode
=
(
SVnodeObj
*
)
param
;
SVnodeObj
*
pVnode
=
(
SVnodeObj
*
)
param
;
int32_t
msgType
=
pRead
Msg
->
msgType
;
int32_t
msgType
=
pRead
->
msgType
;
if
(
vnodeProcessReadMsgFp
[
msgType
]
==
NULL
)
{
if
(
vnodeProcessReadMsgFp
[
msgType
]
==
NULL
)
{
vDebug
(
"vgId:%d, msgType:%s not processed, no handle"
,
pVnode
->
vgId
,
taosMsg
[
msgType
]);
vDebug
(
"vgId:%d, msgType:%s not processed, no handle"
,
pVnode
->
vgId
,
taosMsg
[
msgType
]);
return
TSDB_CODE_VND_MSG_NOT_PROCESSED
;
return
TSDB_CODE_VND_MSG_NOT_PROCESSED
;
}
}
return
(
*
vnodeProcessReadMsgFp
[
msgType
])(
pVnode
,
pRead
Msg
);
return
(
*
vnodeProcessReadMsgFp
[
msgType
])(
pVnode
,
pRead
);
}
}
static
int32_t
vnodeCheckRead
(
void
*
param
)
{
static
int32_t
vnodeCheckRead
(
void
*
param
)
{
...
@@ -180,27 +177,27 @@ static void vnodeBuildNoResultQueryRsp(SRspRet *pRet) {
...
@@ -180,27 +177,27 @@ static void vnodeBuildNoResultQueryRsp(SRspRet *pRet) {
pRsp
->
completed
=
true
;
pRsp
->
completed
=
true
;
}
}
static
int32_t
vnodeProcessQueryMsg
(
SVnodeObj
*
pVnode
,
SVReadMsg
*
pRead
Msg
)
{
static
int32_t
vnodeProcessQueryMsg
(
SVnodeObj
*
pVnode
,
SVReadMsg
*
pRead
)
{
void
*
pCont
=
pRead
Msg
->
pCont
;
void
*
pCont
=
pRead
->
pCont
;
int32_t
contLen
=
pRead
Msg
->
contLen
;
int32_t
contLen
=
pRead
->
contLen
;
SRspRet
*
pRet
=
&
pRead
Msg
->
rspRet
;
SRspRet
*
pRet
=
&
pRead
->
rspRet
;
SQueryTableMsg
*
pQueryTableMsg
=
(
SQueryTableMsg
*
)
pCont
;
SQueryTableMsg
*
pQueryTableMsg
=
(
SQueryTableMsg
*
)
pCont
;
memset
(
pRet
,
0
,
sizeof
(
SRspRet
));
memset
(
pRet
,
0
,
sizeof
(
SRspRet
));
// qHandle needs to be freed correctly
// qHandle needs to be freed correctly
if
(
pRead
Msg
->
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
)
{
if
(
pRead
->
code
==
TSDB_CODE_RPC_NETWORK_UNAVAIL
)
{
SRetrieveTableMsg
*
killQueryMsg
=
(
SRetrieveTableMsg
*
)
pRead
Msg
->
pCont
;
SRetrieveTableMsg
*
killQueryMsg
=
(
SRetrieveTableMsg
*
)
pRead
->
pCont
;
killQueryMsg
->
free
=
htons
(
killQueryMsg
->
free
);
killQueryMsg
->
free
=
htons
(
killQueryMsg
->
free
);
killQueryMsg
->
qhandle
=
htobe64
(
killQueryMsg
->
qhandle
);
killQueryMsg
->
qhandle
=
htobe64
(
killQueryMsg
->
qhandle
);
vWarn
(
"QInfo:%p connection %p broken, kill query"
,
(
void
*
)
killQueryMsg
->
qhandle
,
pRead
Msg
->
rpcHandle
);
vWarn
(
"QInfo:%p connection %p broken, kill query"
,
(
void
*
)
killQueryMsg
->
qhandle
,
pRead
->
rpcHandle
);
assert
(
pRead
Msg
->
contLen
>
0
&&
killQueryMsg
->
free
==
1
);
assert
(
pRead
->
contLen
>
0
&&
killQueryMsg
->
free
==
1
);
void
**
qhandle
=
qAcquireQInfo
(
pVnode
->
qMgmt
,
(
uint64_t
)
killQueryMsg
->
qhandle
);
void
**
qhandle
=
qAcquireQInfo
(
pVnode
->
qMgmt
,
(
uint64_t
)
killQueryMsg
->
qhandle
);
if
(
qhandle
==
NULL
||
*
qhandle
==
NULL
)
{
if
(
qhandle
==
NULL
||
*
qhandle
==
NULL
)
{
vWarn
(
"QInfo:%p invalid qhandle, no matched query handle, conn:%p"
,
(
void
*
)
killQueryMsg
->
qhandle
,
vWarn
(
"QInfo:%p invalid qhandle, no matched query handle, conn:%p"
,
(
void
*
)
killQueryMsg
->
qhandle
,
pRead
Msg
->
rpcHandle
);
pRead
->
rpcHandle
);
}
else
{
}
else
{
assert
(
*
qhandle
==
(
void
*
)
killQueryMsg
->
qhandle
);
assert
(
*
qhandle
==
(
void
*
)
killQueryMsg
->
qhandle
);
...
@@ -242,9 +239,9 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
...
@@ -242,9 +239,9 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
}
}
if
(
handle
!=
NULL
&&
if
(
handle
!=
NULL
&&
vnodeNotifyCurrentQhandle
(
pRead
Msg
->
rpcHandle
,
*
handle
,
pVnode
->
vgId
)
!=
TSDB_CODE_SUCCESS
)
{
vnodeNotifyCurrentQhandle
(
pRead
->
rpcHandle
,
*
handle
,
pVnode
->
vgId
)
!=
TSDB_CODE_SUCCESS
)
{
vError
(
"vgId:%d, QInfo:%p, query discarded since link is broken, %p"
,
pVnode
->
vgId
,
*
handle
,
vError
(
"vgId:%d, QInfo:%p, query discarded since link is broken, %p"
,
pVnode
->
vgId
,
*
handle
,
pRead
Msg
->
rpcHandle
);
pRead
->
rpcHandle
);
pRsp
->
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
pRsp
->
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
return
pRsp
->
code
;
return
pRsp
->
code
;
...
@@ -255,7 +252,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
...
@@ -255,7 +252,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
if
(
handle
!=
NULL
)
{
if
(
handle
!=
NULL
)
{
vDebug
(
"vgId:%d, QInfo:%p, dnode query msg disposed, create qhandle and returns to app"
,
vgId
,
*
handle
);
vDebug
(
"vgId:%d, QInfo:%p, dnode query msg disposed, create qhandle and returns to app"
,
vgId
,
*
handle
);
code
=
vnodePutItemIntoReadQueue
(
pVnode
,
handle
,
pRead
Msg
->
rpcHandle
);
code
=
vnodePutItemIntoReadQueue
(
pVnode
,
handle
,
pRead
->
rpcHandle
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pRsp
->
code
=
code
;
pRsp
->
code
=
code
;
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
...
@@ -264,7 +261,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
...
@@ -264,7 +261,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
}
}
}
else
{
}
else
{
assert
(
pCont
!=
NULL
);
assert
(
pCont
!=
NULL
);
void
**
qhandle
=
(
void
**
)
pRead
Msg
->
qhandle
;
void
**
qhandle
=
(
void
**
)
pRead
->
qhandle
;
vDebug
(
"vgId:%d, QInfo:%p, dnode continues to exec query"
,
pVnode
->
vgId
,
*
qhandle
);
vDebug
(
"vgId:%d, QInfo:%p, dnode continues to exec query"
,
pVnode
->
vgId
,
*
qhandle
);
...
@@ -276,14 +273,14 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
...
@@ -276,14 +273,14 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
// build query rsp, the retrieve request has reached here already
// build query rsp, the retrieve request has reached here already
if
(
buildRes
)
{
if
(
buildRes
)
{
// update the connection info according to the retrieve connection
// update the connection info according to the retrieve connection
pRead
Msg
->
rpcHandle
=
qGetResultRetrieveMsg
(
*
qhandle
);
pRead
->
rpcHandle
=
qGetResultRetrieveMsg
(
*
qhandle
);
assert
(
pRead
Msg
->
rpcHandle
!=
NULL
);
assert
(
pRead
->
rpcHandle
!=
NULL
);
vDebug
(
"vgId:%d, QInfo:%p, start to build retrieval rsp after query paused, %p"
,
pVnode
->
vgId
,
*
qhandle
,
vDebug
(
"vgId:%d, QInfo:%p, start to build retrieval rsp after query paused, %p"
,
pVnode
->
vgId
,
*
qhandle
,
pRead
Msg
->
rpcHandle
);
pRead
->
rpcHandle
);
// set the real rsp error code
// set the real rsp error code
pRead
Msg
->
code
=
vnodeDumpQueryResult
(
&
pRead
->
rspRet
,
pVnode
,
qhandle
,
&
freehandle
,
pReadMsg
->
rpcHandle
);
pRead
->
code
=
vnodeDumpQueryResult
(
&
pRead
->
rspRet
,
pVnode
,
qhandle
,
&
freehandle
,
pRead
->
rpcHandle
);
// NOTE: set return code to be TSDB_CODE_QRY_HAS_RSP to notify dnode to return msg to client
// NOTE: set return code to be TSDB_CODE_QRY_HAS_RSP to notify dnode to return msg to client
code
=
TSDB_CODE_QRY_HAS_RSP
;
code
=
TSDB_CODE_QRY_HAS_RSP
;
...
@@ -308,16 +305,16 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
...
@@ -308,16 +305,16 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
return
code
;
return
code
;
}
}
static
int32_t
vnodeProcessFetchMsg
(
SVnodeObj
*
pVnode
,
SVReadMsg
*
pRead
Msg
)
{
static
int32_t
vnodeProcessFetchMsg
(
SVnodeObj
*
pVnode
,
SVReadMsg
*
pRead
)
{
void
*
pCont
=
pRead
Msg
->
pCont
;
void
*
pCont
=
pRead
->
pCont
;
SRspRet
*
pRet
=
&
pRead
Msg
->
rspRet
;
SRspRet
*
pRet
=
&
pRead
->
rspRet
;
SRetrieveTableMsg
*
pRetrieve
=
pCont
;
SRetrieveTableMsg
*
pRetrieve
=
pCont
;
pRetrieve
->
free
=
htons
(
pRetrieve
->
free
);
pRetrieve
->
free
=
htons
(
pRetrieve
->
free
);
pRetrieve
->
qhandle
=
htobe64
(
pRetrieve
->
qhandle
);
pRetrieve
->
qhandle
=
htobe64
(
pRetrieve
->
qhandle
);
vDebug
(
"vgId:%d, QInfo:%p, retrieve msg is disposed, free:%d, conn:%p"
,
pVnode
->
vgId
,
(
void
*
)
pRetrieve
->
qhandle
,
vDebug
(
"vgId:%d, QInfo:%p, retrieve msg is disposed, free:%d, conn:%p"
,
pVnode
->
vgId
,
(
void
*
)
pRetrieve
->
qhandle
,
pRetrieve
->
free
,
pRead
Msg
->
rpcHandle
);
pRetrieve
->
free
,
pRead
->
rpcHandle
);
memset
(
pRet
,
0
,
sizeof
(
SRspRet
));
memset
(
pRet
,
0
,
sizeof
(
SRspRet
));
...
@@ -348,8 +345,8 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
...
@@ -348,8 +345,8 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
}
}
// register the qhandle to connect to quit query immediate if connection is broken
// register the qhandle to connect to quit query immediate if connection is broken
if
(
vnodeNotifyCurrentQhandle
(
pRead
Msg
->
rpcHandle
,
*
handle
,
pVnode
->
vgId
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
vnodeNotifyCurrentQhandle
(
pRead
->
rpcHandle
,
*
handle
,
pVnode
->
vgId
)
!=
TSDB_CODE_SUCCESS
)
{
vError
(
"vgId:%d, QInfo:%p, retrieve discarded since link is broken, %p"
,
pVnode
->
vgId
,
*
handle
,
pRead
Msg
->
rpcHandle
);
vError
(
"vgId:%d, QInfo:%p, retrieve discarded since link is broken, %p"
,
pVnode
->
vgId
,
*
handle
,
pRead
->
rpcHandle
);
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
qKillQuery
(
*
handle
);
qKillQuery
(
*
handle
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
...
@@ -359,7 +356,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
...
@@ -359,7 +356,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
bool
freeHandle
=
true
;
bool
freeHandle
=
true
;
bool
buildRes
=
false
;
bool
buildRes
=
false
;
code
=
qRetrieveQueryResultInfo
(
*
handle
,
&
buildRes
,
pRead
Msg
->
rpcHandle
);
code
=
qRetrieveQueryResultInfo
(
*
handle
,
&
buildRes
,
pRead
->
rpcHandle
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// TODO handle malloc failure
// TODO handle malloc failure
pRet
->
rsp
=
(
SRetrieveTableRsp
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableRsp
));
pRet
->
rsp
=
(
SRetrieveTableRsp
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableRsp
));
...
@@ -370,7 +367,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
...
@@ -370,7 +367,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
assert
(
buildRes
==
true
);
assert
(
buildRes
==
true
);
#if _NON_BLOCKING_RETRIEVE
#if _NON_BLOCKING_RETRIEVE
if
(
!
buildRes
)
{
if
(
!
buildRes
)
{
assert
(
pRead
Msg
->
rpcHandle
!=
NULL
);
assert
(
pRead
->
rpcHandle
!=
NULL
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
false
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
false
);
return
TSDB_CODE_QRY_NOT_READY
;
return
TSDB_CODE_QRY_NOT_READY
;
...
@@ -378,7 +375,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
...
@@ -378,7 +375,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pReadMsg) {
#endif
#endif
// ahandle is the sqlObj pointer
// ahandle is the sqlObj pointer
code
=
vnodeDumpQueryResult
(
pRet
,
pVnode
,
handle
,
&
freeHandle
,
pRead
Msg
->
rpcHandle
);
code
=
vnodeDumpQueryResult
(
pRet
,
pVnode
,
handle
,
&
freeHandle
,
pRead
->
rpcHandle
);
}
}
// If qhandle is not added into vread queue, the query should be completed already or paused with error.
// If qhandle is not added into vread queue, the query should be completed already or paused with error.
...
...
src/vnode/src/vnodeWrite.c
浏览文件 @
83d2acd5
...
@@ -19,7 +19,6 @@
...
@@ -19,7 +19,6 @@
#include "taoserror.h"
#include "taoserror.h"
#include "tqueue.h"
#include "tqueue.h"
#include "trpc.h"
#include "trpc.h"
#include "tutil.h"
#include "tsdb.h"
#include "tsdb.h"
#include "twal.h"
#include "twal.h"
#include "tsync.h"
#include "tsync.h"
...
...
tests/script/jenkins/basic.txt
浏览文件 @
83d2acd5
...
@@ -57,8 +57,8 @@ cd ../../../debug; make
...
@@ -57,8 +57,8 @@ cd ../../../debug; make
./test.sh -f general/db/delete_reuse2.sim
./test.sh -f general/db/delete_reuse2.sim
./test.sh -f general/db/delete_reusevnode.sim
./test.sh -f general/db/delete_reusevnode.sim
./test.sh -f general/db/delete_reusevnode2.sim
./test.sh -f general/db/delete_reusevnode2.sim
./test.sh -f general/db/delete_writing1.sim
#
./test.sh -f general/db/delete_writing1.sim
./test.sh -f general/db/delete_writing2.sim
#
./test.sh -f general/db/delete_writing2.sim
./test.sh -f general/db/delete.sim
./test.sh -f general/db/delete.sim
./test.sh -f general/db/len.sim
./test.sh -f general/db/len.sim
./test.sh -f general/db/repeat.sim
./test.sh -f general/db/repeat.sim
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录