Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
91bc2e9c
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
91bc2e9c
编写于
11月 28, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into feature/TD-1413
上级
d66d3119
6a4481f4
变更
57
显示空白变更内容
内联
并排
Showing
57 changed file
with
605 addition
and
528 deletion
+605
-528
src/balance/src/balance.c
src/balance/src/balance.c
+15
-25
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-1
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+14
-6
src/client/src/tscServer.c
src/client/src/tscServer.c
+19
-9
src/client/src/tscSub.c
src/client/src/tscSub.c
+6
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+14
-2
src/common/src/tglobal.c
src/common/src/tglobal.c
+1
-1
src/connector/go
src/connector/go
+1
-1
src/connector/grafanaplugin
src/connector/grafanaplugin
+1
-1
src/inc/taoserror.h
src/inc/taoserror.h
+4
-0
src/inc/tsync.h
src/inc/tsync.h
+4
-0
src/mnode/inc/mnodeAcct.h
src/mnode/inc/mnodeAcct.h
+1
-0
src/mnode/inc/mnodeDb.h
src/mnode/inc/mnodeDb.h
+1
-0
src/mnode/inc/mnodeDnode.h
src/mnode/inc/mnodeDnode.h
+1
-0
src/mnode/inc/mnodeMnode.h
src/mnode/inc/mnodeMnode.h
+1
-0
src/mnode/inc/mnodeSdb.h
src/mnode/inc/mnodeSdb.h
+3
-3
src/mnode/inc/mnodeShow.h
src/mnode/inc/mnodeShow.h
+2
-0
src/mnode/inc/mnodeTable.h
src/mnode/inc/mnodeTable.h
+2
-0
src/mnode/inc/mnodeUser.h
src/mnode/inc/mnodeUser.h
+1
-0
src/mnode/inc/mnodeVgroup.h
src/mnode/inc/mnodeVgroup.h
+1
-0
src/mnode/src/mnodeAcct.c
src/mnode/src/mnodeAcct.c
+4
-2
src/mnode/src/mnodeCluster.c
src/mnode/src/mnodeCluster.c
+7
-1
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+7
-5
src/mnode/src/mnodeDnode.c
src/mnode/src/mnodeDnode.c
+11
-12
src/mnode/src/mnodeMnode.c
src/mnode/src/mnodeMnode.c
+6
-3
src/mnode/src/mnodeProfile.c
src/mnode/src/mnodeProfile.c
+13
-11
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+15
-21
src/mnode/src/mnodeShow.c
src/mnode/src/mnodeShow.c
+8
-1
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+24
-23
src/mnode/src/mnodeUser.c
src/mnode/src/mnodeUser.c
+6
-3
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+6
-9
src/query/inc/qUtil.h
src/query/inc/qUtil.h
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+3
-3
src/query/src/qResultbuf.c
src/query/src/qResultbuf.c
+3
-5
src/query/src/qUtil.c
src/query/src/qUtil.c
+9
-3
src/rpc/src/rpcTcp.c
src/rpc/src/rpcTcp.c
+9
-6
src/sync/inc/syncInt.h
src/sync/inc/syncInt.h
+2
-0
src/sync/src/syncMain.c
src/sync/src/syncMain.c
+3
-3
src/sync/src/syncRestore.c
src/sync/src/syncRestore.c
+6
-6
src/sync/src/syncRetrieve.c
src/sync/src/syncRetrieve.c
+40
-95
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+2
-2
src/util/inc/hash.h
src/util/inc/hash.h
+13
-41
src/util/src/hash.c
src/util/src/hash.c
+161
-168
src/util/src/tkvstore.c
src/util/src/tkvstore.c
+6
-13
src/util/src/tqueue.c
src/util/src/tqueue.c
+0
-3
src/util/src/tskiplist.c
src/util/src/tskiplist.c
+4
-1
src/vnode/inc/vnodeInt.h
src/vnode/inc/vnodeInt.h
+1
-0
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+43
-19
src/vnode/src/vnodeWrite.c
src/vnode/src/vnodeWrite.c
+5
-3
src/wal/src/walWrite.c
src/wal/src/walWrite.c
+2
-2
tests/examples/c/apitest.c
tests/examples/c/apitest.c
+6
-6
tests/examples/c/subscribe.c
tests/examples/c/subscribe.c
+4
-4
tests/script/basicSuite.sim
tests/script/basicSuite.sim
+0
-1
tests/script/general/wal/sync.sim
tests/script/general/wal/sync.sim
+1
-0
tests/script/tmp/mnodes.sim
tests/script/tmp/mnodes.sim
+4
-0
tests/test/c/CMakeLists.txt
tests/test/c/CMakeLists.txt
+5
-2
tests/test/c/hashIterator.c
tests/test/c/hashIterator.c
+72
-0
未找到文件。
src/balance/src/balance.c
浏览文件 @
91bc2e9c
...
@@ -162,7 +162,6 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
...
@@ -162,7 +162,6 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
pDnode
->
openVnodes
,
pDnode
->
diskAvailable
,
pDnode
->
alternativeRole
);
pDnode
->
openVnodes
,
pDnode
->
diskAvailable
,
pDnode
->
alternativeRole
);
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
}
}
sdbFreeIter
(
pIter
);
if
(
mnodeGetOnlineDnodesNum
()
==
0
)
{
if
(
mnodeGetOnlineDnodesNum
()
==
0
)
{
return
TSDB_CODE_MND_NOT_READY
;
return
TSDB_CODE_MND_NOT_READY
;
...
@@ -377,15 +376,13 @@ static bool balanceMonitorBalance() {
...
@@ -377,15 +376,13 @@ static bool balanceMonitorBalance() {
srcScore
,
pDestDnode
->
score
,
destScore
);
srcScore
,
pDestDnode
->
score
,
destScore
);
balanceAddVnode
(
pVgroup
,
pSrcDnode
,
pDestDnode
);
balanceAddVnode
(
pVgroup
,
pSrcDnode
,
pDestDnode
);
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
sdbFreeIter
(
pIter
);
mnodeCancelGetNextVgroup
(
pIter
);
return
true
;
return
true
;
}
}
}
}
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
}
}
sdbFreeIter
(
pIter
);
}
}
return
false
;
return
false
;
...
@@ -413,8 +410,6 @@ void balanceReset() {
...
@@ -413,8 +410,6 @@ void balanceReset() {
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
}
}
sdbFreeIter
(
pIter
);
tsAccessSquence
=
0
;
tsAccessSquence
=
0
;
}
}
...
@@ -443,12 +438,11 @@ static int32_t balanceMonitorVgroups() {
...
@@ -443,12 +438,11 @@ static int32_t balanceMonitorVgroups() {
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mnodeCancelGetNextVgroup
(
pIter
);
break
;
break
;
}
}
}
}
sdbFreeIter
(
pIter
);
return
hasUpdatingVgroup
;
return
hasUpdatingVgroup
;
}
}
...
@@ -465,10 +459,11 @@ static bool balanceMonitorDnodeDropping(SDnodeObj *pDnode) {
...
@@ -465,10 +459,11 @@ static bool balanceMonitorDnodeDropping(SDnodeObj *pDnode) {
hasThisDnode
=
balanceCheckDnodeInVgroup
(
pDnode
,
pVgroup
);
hasThisDnode
=
balanceCheckDnodeInVgroup
(
pDnode
,
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
if
(
hasThisDnode
)
break
;
if
(
hasThisDnode
)
{
mnodeCancelGetNextVgroup
(
pIter
);
break
;
}
}
}
sdbFreeIter
(
pIter
);
if
(
!
hasThisDnode
)
{
if
(
!
hasThisDnode
)
{
mInfo
(
"dnode:%d, dropped for all vnodes are moving to other dnodes"
,
pDnode
->
dnodeId
);
mInfo
(
"dnode:%d, dropped for all vnodes are moving to other dnodes"
,
pDnode
->
dnodeId
);
...
@@ -499,20 +494,18 @@ static bool balanceMontiorDropping() {
...
@@ -499,20 +494,18 @@ static bool balanceMontiorDropping() {
pDnode
->
status
=
TAOS_DN_STATUS_DROPPING
;
pDnode
->
status
=
TAOS_DN_STATUS_DROPPING
;
mnodeUpdateDnode
(
pDnode
);
mnodeUpdateDnode
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
sdbFreeIter
(
pIter
);
mnodeCancelGetNextDnode
(
pIter
);
return
true
;
return
true
;
}
}
if
(
pDnode
->
status
==
TAOS_DN_STATUS_DROPPING
)
{
if
(
pDnode
->
status
==
TAOS_DN_STATUS_DROPPING
)
{
bool
ret
=
balanceMonitorDnodeDropping
(
pDnode
);
bool
ret
=
balanceMonitorDnodeDropping
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
sdbFreeIter
(
pIter
);
mnodeCancelGetNextDnode
(
pIter
);
return
ret
;
return
ret
;
}
}
}
}
sdbFreeIter
(
pIter
);
return
false
;
return
false
;
}
}
...
@@ -556,8 +549,6 @@ static void balanceSetVgroupOffline(SDnodeObj* pDnode) {
...
@@ -556,8 +549,6 @@ static void balanceSetVgroupOffline(SDnodeObj* pDnode) {
}
}
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
}
}
sdbFreeIter
(
pIter
);
}
}
static
void
balanceCheckDnodeAccess
()
{
static
void
balanceCheckDnodeAccess
()
{
...
@@ -578,8 +569,6 @@ static void balanceCheckDnodeAccess() {
...
@@ -578,8 +569,6 @@ static void balanceCheckDnodeAccess() {
}
}
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
}
}
sdbFreeIter
(
pIter
);
}
}
static
void
balanceProcessBalanceTimer
(
void
*
handle
,
void
*
tmrId
)
{
static
void
balanceProcessBalanceTimer
(
void
*
handle
,
void
*
tmrId
)
{
...
@@ -630,6 +619,7 @@ void balanceAsyncNotify() {
...
@@ -630,6 +619,7 @@ void balanceAsyncNotify() {
int32_t
balanceInit
()
{
int32_t
balanceInit
()
{
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_SCORES
,
balanceGetScoresMeta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_SCORES
,
balanceGetScoresMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_SCORES
,
balanceRetrieveScores
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_SCORES
,
balanceRetrieveScores
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_SCORES
,
mnodeCancelGetNextDnode
);
pthread_mutex_init
(
&
tsBalanceMutex
,
NULL
);
pthread_mutex_init
(
&
tsBalanceMutex
,
NULL
);
balanceInitDnodeList
();
balanceInitDnodeList
();
...
@@ -667,8 +657,6 @@ int32_t balanceDropDnode(SDnodeObj *pDnode) {
...
@@ -667,8 +657,6 @@ int32_t balanceDropDnode(SDnodeObj *pDnode) {
mnodeDecDnodeRef
(
pTempDnode
);
mnodeDecDnodeRef
(
pTempDnode
);
}
}
sdbFreeIter
(
pIter
);
if
(
pDnode
->
openVnodes
>
totalFreeVnodes
)
{
if
(
pDnode
->
openVnodes
>
totalFreeVnodes
)
{
mError
(
"dnode:%d, openVnodes:%d totalFreeVnodes:%d no enough dnodes"
,
pDnode
->
dnodeId
,
pDnode
->
openVnodes
,
totalFreeVnodes
);
mError
(
"dnode:%d, openVnodes:%d totalFreeVnodes:%d no enough dnodes"
,
pDnode
->
dnodeId
,
pDnode
->
openVnodes
,
totalFreeVnodes
);
return
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
return
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
...
@@ -781,7 +769,11 @@ void balanceAccquireDnodeList() {
...
@@ -781,7 +769,11 @@ void balanceAccquireDnodeList() {
int32_t
dnodeIndex
=
0
;
int32_t
dnodeIndex
=
0
;
while
(
1
)
{
while
(
1
)
{
if
(
dnodeIndex
>=
dnodesNum
)
break
;
if
(
dnodeIndex
>=
dnodesNum
)
{
mnodeCancelGetNextDnode
(
pIter
);
break
;
}
pIter
=
mnodeGetNextDnode
(
pIter
,
&
pDnode
);
pIter
=
mnodeGetNextDnode
(
pIter
,
&
pDnode
);
if
(
pDnode
==
NULL
)
break
;
if
(
pDnode
==
NULL
)
break
;
if
(
pDnode
->
status
==
TAOS_DN_STATUS_OFFLINE
)
{
if
(
pDnode
->
status
==
TAOS_DN_STATUS_OFFLINE
)
{
...
@@ -802,8 +794,6 @@ void balanceAccquireDnodeList() {
...
@@ -802,8 +794,6 @@ void balanceAccquireDnodeList() {
dnodeIndex
++
;
dnodeIndex
++
;
}
}
sdbFreeIter
(
pIter
);
tsBalanceDnodeListSize
=
dnodeIndex
;
tsBalanceDnodeListSize
=
dnodeIndex
;
}
}
...
...
src/client/inc/tsclient.h
浏览文件 @
91bc2e9c
...
@@ -282,7 +282,7 @@ typedef struct {
...
@@ -282,7 +282,7 @@ typedef struct {
int8_t
dataSourceType
;
// load data from file or not
int8_t
dataSourceType
;
// load data from file or not
int8_t
submitSchema
;
// submit block is built with table schema
int8_t
submitSchema
;
// submit block is built with table schema
STagData
tagData
;
STagData
*
pTagData
;
// NOTE: pTagData->data is used as a variant length array
SHashObj
*
pTableList
;
// referred table involved in sql
SHashObj
*
pTableList
;
// referred table involved in sql
SArray
*
pDataBlocks
;
// SArray<STableDataBlocks*> submit data blocks after parsing sql
SArray
*
pDataBlocks
;
// SArray<STableDataBlocks*> submit data blocks after parsing sql
}
SSqlCmd
;
}
SSqlCmd
;
...
...
src/client/src/tscParseInsert.c
浏览文件 @
91bc2e9c
...
@@ -790,9 +790,6 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -790,9 +790,6 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
sql
+=
index
;
sql
+=
index
;
tscAllocPayload
(
pCmd
,
sizeof
(
STagData
));
tscAllocPayload
(
pCmd
,
sizeof
(
STagData
));
STagData
*
pTag
=
&
pCmd
->
tagData
;
memset
(
pTag
,
0
,
sizeof
(
STagData
));
//the source super table is moved to the secondary position of the pTableMetaInfo list
//the source super table is moved to the secondary position of the pTableMetaInfo list
if
(
pQueryInfo
->
numOfTables
<
2
)
{
if
(
pQueryInfo
->
numOfTables
<
2
)
{
...
@@ -805,7 +802,14 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -805,7 +802,14 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
code
;
return
code
;
}
}
STagData
*
pTag
=
realloc
(
pCmd
->
pTagData
,
offsetof
(
STagData
,
data
));
if
(
pTag
==
NULL
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
memset
(
pTag
,
0
,
offsetof
(
STagData
,
data
));
tstrncpy
(
pTag
->
name
,
pSTableMeterMetaInfo
->
name
,
sizeof
(
pTag
->
name
));
tstrncpy
(
pTag
->
name
,
pSTableMeterMetaInfo
->
name
,
sizeof
(
pTag
->
name
));
pCmd
->
pTagData
=
pTag
;
code
=
tscGetTableMeta
(
pSql
,
pSTableMeterMetaInfo
);
code
=
tscGetTableMeta
(
pSql
,
pSTableMeterMetaInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -934,7 +938,13 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -934,7 +938,13 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
tdSortKVRowByColIdx
(
row
);
tdSortKVRowByColIdx
(
row
);
pTag
->
dataLen
=
kvRowLen
(
row
);
pTag
=
(
STagData
*
)
realloc
(
pCmd
->
pTagData
,
offsetof
(
STagData
,
data
)
+
kvRowLen
(
row
));
if
(
pTag
==
NULL
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
pCmd
->
pTagData
=
pTag
;
pTag
->
dataLen
=
htonl
(
kvRowLen
(
row
));
kvRowCpy
(
pTag
->
data
,
row
);
kvRowCpy
(
pTag
->
data
,
row
);
free
(
row
);
free
(
row
);
...
@@ -945,8 +955,6 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -945,8 +955,6 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
") expected"
,
sToken
.
z
);
return
tscSQLSyntaxErrMsg
(
pCmd
->
payload
,
") expected"
,
sToken
.
z
);
}
}
pTag
->
dataLen
=
htonl
(
pTag
->
dataLen
);
if
(
tscValidateName
(
&
tableToken
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscValidateName
(
&
tableToken
)
!=
TSDB_CODE_SUCCESS
)
{
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"invalid table name"
,
*
sqlstr
);
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"invalid table name"
,
*
sqlstr
);
}
}
...
...
src/client/src/tscServer.c
浏览文件 @
91bc2e9c
...
@@ -1565,11 +1565,11 @@ int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1565,11 +1565,11 @@ int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
char
*
pMsg
=
(
char
*
)
pInfoMsg
+
sizeof
(
STableInfoMsg
);
char
*
pMsg
=
(
char
*
)
pInfoMsg
+
sizeof
(
STableInfoMsg
);
size_t
len
=
htonl
(
pCmd
->
tagData
.
dataLen
);
if
(
pCmd
->
autoCreated
&&
pCmd
->
pTagData
!=
NULL
)
{
if
(
pSql
->
cmd
.
autoCreated
)
{
int
len
=
htonl
(
pCmd
->
pTagData
->
dataLen
);
if
(
len
>
0
)
{
if
(
len
>
0
)
{
len
+=
sizeof
(
pCmd
->
tagData
.
name
)
+
sizeof
(
pCmd
->
tagData
.
dataLen
);
len
+=
sizeof
(
pCmd
->
pTagData
->
name
)
+
sizeof
(
pCmd
->
pTagData
->
dataLen
);
memcpy
(
pInfoMsg
->
tags
,
&
pCmd
->
t
agData
,
len
);
memcpy
(
pInfoMsg
->
tags
,
pCmd
->
pT
agData
,
len
);
pMsg
+=
len
;
pMsg
+=
len
;
}
}
}
}
...
@@ -2239,8 +2239,6 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
...
@@ -2239,8 +2239,6 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
pNew
->
signature
=
pNew
;
pNew
->
signature
=
pNew
;
pNew
->
cmd
.
command
=
TSDB_SQL_META
;
pNew
->
cmd
.
command
=
TSDB_SQL_META
;
registerSqlObj
(
pNew
);
tscAddSubqueryInfo
(
&
pNew
->
cmd
);
tscAddSubqueryInfo
(
&
pNew
->
cmd
);
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetailSafely
(
&
pNew
->
cmd
,
0
);
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetailSafely
(
&
pNew
->
cmd
,
0
);
...
@@ -2248,8 +2246,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
...
@@ -2248,8 +2246,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
pNew
->
cmd
.
autoCreated
=
pSql
->
cmd
.
autoCreated
;
// create table if not exists
pNew
->
cmd
.
autoCreated
=
pSql
->
cmd
.
autoCreated
;
// create table if not exists
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
&
pNew
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
+
pSql
->
cmd
.
payloadLen
))
{
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
&
pNew
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
+
pSql
->
cmd
.
payloadLen
))
{
tscError
(
"%p malloc failed for payload to get table meta"
,
pSql
);
tscError
(
"%p malloc failed for payload to get table meta"
,
pSql
);
free
(
pNew
);
tscFreeSqlObj
(
pNew
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
...
@@ -2257,12 +2254,25 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
...
@@ -2257,12 +2254,25 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
assert
(
pNew
->
cmd
.
numOfClause
==
1
&&
pNewQueryInfo
->
numOfTables
==
1
);
assert
(
pNew
->
cmd
.
numOfClause
==
1
&&
pNewQueryInfo
->
numOfTables
==
1
);
tstrncpy
(
pNewMeterMetaInfo
->
name
,
pTableMetaInfo
->
name
,
sizeof
(
pNewMeterMetaInfo
->
name
));
tstrncpy
(
pNewMeterMetaInfo
->
name
,
pTableMetaInfo
->
name
,
sizeof
(
pNewMeterMetaInfo
->
name
));
memcpy
(
&
pNew
->
cmd
.
tagData
,
&
pSql
->
cmd
.
tagData
,
sizeof
(
pSql
->
cmd
.
tagData
));
if
(
pSql
->
cmd
.
pTagData
!=
NULL
)
{
int
size
=
offsetof
(
STagData
,
data
)
+
htonl
(
pSql
->
cmd
.
pTagData
->
dataLen
);
pNew
->
cmd
.
pTagData
=
calloc
(
1
,
size
);
if
(
pNew
->
cmd
.
pTagData
==
NULL
)
{
tscError
(
"%p malloc failed for new tag data to get table meta"
,
pSql
);
tscFreeSqlObj
(
pNew
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
memcpy
(
pNew
->
cmd
.
pTagData
,
pSql
->
cmd
.
pTagData
,
size
);
}
tscDebug
(
"%p new pSqlObj:%p to get tableMeta, auto create:%d"
,
pSql
,
pNew
,
pNew
->
cmd
.
autoCreated
);
tscDebug
(
"%p new pSqlObj:%p to get tableMeta, auto create:%d"
,
pSql
,
pNew
,
pNew
->
cmd
.
autoCreated
);
pNew
->
fp
=
tscTableMetaCallBack
;
pNew
->
fp
=
tscTableMetaCallBack
;
pNew
->
param
=
pSql
;
pNew
->
param
=
pSql
;
registerSqlObj
(
pNew
);
int32_t
code
=
tscProcessSql
(
pNew
);
int32_t
code
=
tscProcessSql
(
pNew
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
TSDB_CODE_TSC_ACTION_IN_PROGRESS
;
// notify upper application that current process need to be terminated
code
=
TSDB_CODE_TSC_ACTION_IN_PROGRESS
;
// notify upper application that current process need to be terminated
...
...
src/client/src/tscSub.c
浏览文件 @
91bc2e9c
...
@@ -442,7 +442,12 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) {
...
@@ -442,7 +442,12 @@ TAOS_RES *taos_consume(TAOS_SUB *tsub) {
size_t
size
=
taosArrayGetSize
(
pSub
->
progress
)
*
sizeof
(
STableIdInfo
);
size_t
size
=
taosArrayGetSize
(
pSub
->
progress
)
*
sizeof
(
STableIdInfo
);
size
+=
sizeof
(
SQueryTableMsg
)
+
4096
;
size
+=
sizeof
(
SQueryTableMsg
)
+
4096
;
tscAllocPayload
(
&
pSql
->
cmd
,
(
int
)
size
);
int
code
=
tscAllocPayload
(
&
pSql
->
cmd
,
(
int
)
size
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"failed to alloc payload"
);
return
NULL
;
}
for
(
int
retry
=
0
;
retry
<
3
;
retry
++
)
{
for
(
int
retry
=
0
;
retry
<
3
;
retry
++
)
{
tscRemoveFromSqlList
(
pSql
);
tscRemoveFromSqlList
(
pSql
);
...
...
src/client/src/tscUtil.c
浏览文件 @
91bc2e9c
...
@@ -512,6 +512,8 @@ void tscFreeSqlObj(SSqlObj* pSql) {
...
@@ -512,6 +512,8 @@ void tscFreeSqlObj(SSqlObj* pSql) {
tscFreeSqlResult
(
pSql
);
tscFreeSqlResult
(
pSql
);
tscResetSqlCmdObj
(
pCmd
,
false
);
tscResetSqlCmdObj
(
pCmd
,
false
);
tfree
(
pCmd
->
pTagData
);
memset
(
pCmd
->
payload
,
0
,
(
size_t
)
pCmd
->
allocSize
);
memset
(
pCmd
->
payload
,
0
,
(
size_t
)
pCmd
->
allocSize
);
tfree
(
pCmd
->
payload
);
tfree
(
pCmd
->
payload
);
pCmd
->
allocSize
=
0
;
pCmd
->
allocSize
=
0
;
...
@@ -1909,7 +1911,17 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm
...
@@ -1909,7 +1911,17 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm
pCmd
->
command
=
cmd
;
pCmd
->
command
=
cmd
;
pCmd
->
parseFinished
=
1
;
pCmd
->
parseFinished
=
1
;
pCmd
->
autoCreated
=
pSql
->
cmd
.
autoCreated
;
pCmd
->
autoCreated
=
pSql
->
cmd
.
autoCreated
;
memcpy
(
&
pCmd
->
tagData
,
&
pSql
->
cmd
.
tagData
,
sizeof
(
pCmd
->
tagData
));
if
(
pSql
->
cmd
.
pTagData
!=
NULL
)
{
int
size
=
offsetof
(
STagData
,
data
)
+
htonl
(
pSql
->
cmd
.
pTagData
->
dataLen
);
pNew
->
cmd
.
pTagData
=
calloc
(
1
,
size
);
if
(
pNew
->
cmd
.
pTagData
==
NULL
)
{
tscError
(
"%p new subquery failed, unable to malloc tag data, tableIndex:%d"
,
pSql
,
0
);
free
(
pNew
);
return
NULL
;
}
memcpy
(
pNew
->
cmd
.
pTagData
,
pSql
->
cmd
.
pTagData
,
size
);
}
if
(
tscAddSubqueryInfo
(
pCmd
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscAddSubqueryInfo
(
pCmd
)
!=
TSDB_CODE_SUCCESS
)
{
tscFreeSqlObj
(
pNew
);
tscFreeSqlObj
(
pNew
);
...
...
src/common/src/tglobal.c
浏览文件 @
91bc2e9c
...
@@ -206,7 +206,7 @@ int32_t tsNumOfLogLines = 10000000;
...
@@ -206,7 +206,7 @@ int32_t tsNumOfLogLines = 10000000;
int32_t
mDebugFlag
=
135
;
int32_t
mDebugFlag
=
135
;
int32_t
sdbDebugFlag
=
135
;
int32_t
sdbDebugFlag
=
135
;
int32_t
dDebugFlag
=
135
;
int32_t
dDebugFlag
=
135
;
int32_t
vDebugFlag
=
13
1
;
int32_t
vDebugFlag
=
13
5
;
int32_t
cDebugFlag
=
131
;
int32_t
cDebugFlag
=
131
;
int32_t
jniDebugFlag
=
131
;
int32_t
jniDebugFlag
=
131
;
int32_t
odbcDebugFlag
=
131
;
int32_t
odbcDebugFlag
=
131
;
...
...
go
@
8c58c512
比较
050667e5
...
8c58c512
Subproject commit
050667e5b4d0eafa5387e4283e713559b421203f
Subproject commit
8c58c512b6acda8bcdfa48fdc7140227b5221766
grafanaplugin
@
d598db16
比较
ec77d904
...
d598db16
Subproject commit
ec77d9049a719dabfd1a7c1122a209e201861944
Subproject commit
d598db167eb256fe67409b7bb3d0eb7fffc3ff8c
src/inc/taoserror.h
浏览文件 @
91bc2e9c
...
@@ -261,6 +261,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_CONFIG, 0, 0x0900, "Invalid Sy
...
@@ -261,6 +261,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_CONFIG, 0, 0x0900, "Invalid Sy
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_NOT_ENABLED
,
0
,
0x0901
,
"Sync module not enabled"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_NOT_ENABLED
,
0
,
0x0901
,
"Sync module not enabled"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INVALID_VERSION
,
0
,
0x0902
,
"Invalid Sync version"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INVALID_VERSION
,
0
,
0x0902
,
"Invalid Sync version"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_CONFIRM_EXPIRED
,
0
,
0x0903
,
"Sync confirm expired"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_CONFIRM_EXPIRED
,
0
,
0x0903
,
"Sync confirm expired"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_VND_COMMITING
,
0
,
0x0904
,
"Vnode is commiting"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_FILE_CHNAGED
,
0
,
0x0905
,
"Vnode file is changed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_APP_ERROR
,
0
,
0x1000
,
"Unexpected generic error in sync"
)
// wal
// wal
TAOS_DEFINE_ERROR
(
TSDB_CODE_WAL_APP_ERROR
,
0
,
0x1000
,
"Unexpected generic error in wal"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_WAL_APP_ERROR
,
0
,
0x1000
,
"Unexpected generic error in wal"
)
...
@@ -367,6 +370,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_OP_TAG_VALUE_TOO_LONG, 0, 0x11A4, "tag value
...
@@ -367,6 +370,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_OP_TAG_VALUE_TOO_LONG, 0, 0x11A4, "tag value
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_VALUE_NULL
,
0
,
0x11A5
,
"value not find"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_VALUE_NULL
,
0
,
0x11A5
,
"value not find"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_VALUE_TYPE
,
0
,
0x11A6
,
"value type should be boolean, number or string"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_HTTP_OP_VALUE_TYPE
,
0
,
0x11A6
,
"value type should be boolean, number or string"
)
// odbc
TAOS_DEFINE_ERROR
(
TSDB_CODE_ODBC_OOM
,
0
,
0x2100
,
"out of memory"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_ODBC_OOM
,
0
,
0x2100
,
"out of memory"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_ODBC_CONV_CHAR_NOT_NUM
,
0
,
0x2101
,
"convertion not a valid literal input"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_ODBC_CONV_CHAR_NOT_NUM
,
0
,
0x2101
,
"convertion not a valid literal input"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_ODBC_CONV_UNDEF
,
0
,
0x2102
,
"convertion undefined"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_ODBC_CONV_UNDEF
,
0
,
0x2102
,
"convertion undefined"
)
...
...
src/inc/tsync.h
浏览文件 @
91bc2e9c
...
@@ -85,6 +85,9 @@ typedef void (*FNotifyFlowCtrl)(int32_t vgId, int32_t level);
...
@@ -85,6 +85,9 @@ typedef void (*FNotifyFlowCtrl)(int32_t vgId, int32_t level);
// when data file is synced successfully, notity app
// when data file is synced successfully, notity app
typedef
int32_t
(
*
FNotifyFileSynced
)(
int32_t
vgId
,
uint64_t
fversion
);
typedef
int32_t
(
*
FNotifyFileSynced
)(
int32_t
vgId
,
uint64_t
fversion
);
// get file version
typedef
int32_t
(
*
FGetFileVersion
)(
int32_t
vgId
,
uint64_t
*
fver
);
typedef
struct
{
typedef
struct
{
int32_t
vgId
;
// vgroup ID
int32_t
vgId
;
// vgroup ID
uint64_t
version
;
// initial version
uint64_t
version
;
// initial version
...
@@ -97,6 +100,7 @@ typedef struct {
...
@@ -97,6 +100,7 @@ typedef struct {
FNotifyRole
notifyRole
;
FNotifyRole
notifyRole
;
FNotifyFlowCtrl
notifyFlowCtrl
;
FNotifyFlowCtrl
notifyFlowCtrl
;
FNotifyFileSynced
notifyFileSynced
;
FNotifyFileSynced
notifyFileSynced
;
FGetFileVersion
getFileVersion
;
}
SSyncInfo
;
}
SSyncInfo
;
typedef
void
*
tsync_h
;
typedef
void
*
tsync_h
;
...
...
src/mnode/inc/mnodeAcct.h
浏览文件 @
91bc2e9c
...
@@ -27,6 +27,7 @@ void mnodeCleanupAccts();
...
@@ -27,6 +27,7 @@ void mnodeCleanupAccts();
void
mnodeGetStatOfAllAcct
(
SAcctInfo
*
pAcctInfo
);
void
mnodeGetStatOfAllAcct
(
SAcctInfo
*
pAcctInfo
);
void
*
mnodeGetAcct
(
char
*
acctName
);
void
*
mnodeGetAcct
(
char
*
acctName
);
void
*
mnodeGetNextAcct
(
void
*
pIter
,
SAcctObj
**
pAcct
);
void
*
mnodeGetNextAcct
(
void
*
pIter
,
SAcctObj
**
pAcct
);
void
mnodeCancelGetNextAcct
(
void
*
pIter
);
void
mnodeIncAcctRef
(
SAcctObj
*
pAcct
);
void
mnodeIncAcctRef
(
SAcctObj
*
pAcct
);
void
mnodeDecAcctRef
(
SAcctObj
*
pAcct
);
void
mnodeDecAcctRef
(
SAcctObj
*
pAcct
);
void
mnodeAddDbToAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
void
mnodeAddDbToAcct
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
);
...
...
src/mnode/inc/mnodeDb.h
浏览文件 @
91bc2e9c
...
@@ -34,6 +34,7 @@ int64_t mnodeGetDbNum();
...
@@ -34,6 +34,7 @@ int64_t mnodeGetDbNum();
SDbObj
*
mnodeGetDb
(
char
*
db
);
SDbObj
*
mnodeGetDb
(
char
*
db
);
SDbObj
*
mnodeGetDbByTableId
(
char
*
db
);
SDbObj
*
mnodeGetDbByTableId
(
char
*
db
);
void
*
mnodeGetNextDb
(
void
*
pIter
,
SDbObj
**
pDb
);
void
*
mnodeGetNextDb
(
void
*
pIter
,
SDbObj
**
pDb
);
void
mnodeCancelGetNextDb
(
void
*
pIter
);
void
mnodeIncDbRef
(
SDbObj
*
pDb
);
void
mnodeIncDbRef
(
SDbObj
*
pDb
);
void
mnodeDecDbRef
(
SDbObj
*
pDb
);
void
mnodeDecDbRef
(
SDbObj
*
pDb
);
bool
mnodeCheckIsMonitorDB
(
char
*
db
,
char
*
monitordb
);
bool
mnodeCheckIsMonitorDB
(
char
*
db
,
char
*
monitordb
);
...
...
src/mnode/inc/mnodeDnode.h
浏览文件 @
91bc2e9c
...
@@ -65,6 +65,7 @@ int32_t mnodeGetDnodesNum();
...
@@ -65,6 +65,7 @@ int32_t mnodeGetDnodesNum();
int32_t
mnodeGetOnlinDnodesCpuCoreNum
();
int32_t
mnodeGetOnlinDnodesCpuCoreNum
();
int32_t
mnodeGetOnlineDnodesNum
();
int32_t
mnodeGetOnlineDnodesNum
();
void
*
mnodeGetNextDnode
(
void
*
pIter
,
SDnodeObj
**
pDnode
);
void
*
mnodeGetNextDnode
(
void
*
pIter
,
SDnodeObj
**
pDnode
);
void
mnodeCancelGetNextDnode
(
void
*
pIter
);
void
mnodeIncDnodeRef
(
SDnodeObj
*
pDnode
);
void
mnodeIncDnodeRef
(
SDnodeObj
*
pDnode
);
void
mnodeDecDnodeRef
(
SDnodeObj
*
pDnode
);
void
mnodeDecDnodeRef
(
SDnodeObj
*
pDnode
);
void
*
mnodeGetDnode
(
int32_t
dnodeId
);
void
*
mnodeGetDnode
(
int32_t
dnodeId
);
...
...
src/mnode/inc/mnodeMnode.h
浏览文件 @
91bc2e9c
...
@@ -38,6 +38,7 @@ void mnodeDropMnodeLocal(int32_t dnodeId);
...
@@ -38,6 +38,7 @@ void mnodeDropMnodeLocal(int32_t dnodeId);
void
*
mnodeGetMnode
(
int32_t
mnodeId
);
void
*
mnodeGetMnode
(
int32_t
mnodeId
);
int32_t
mnodeGetMnodesNum
();
int32_t
mnodeGetMnodesNum
();
void
*
mnodeGetNextMnode
(
void
*
pIter
,
struct
SMnodeObj
**
pMnode
);
void
*
mnodeGetNextMnode
(
void
*
pIter
,
struct
SMnodeObj
**
pMnode
);
void
mnodeCancelGetNextMnode
(
void
*
pIter
);
void
mnodeIncMnodeRef
(
struct
SMnodeObj
*
pMnode
);
void
mnodeIncMnodeRef
(
struct
SMnodeObj
*
pMnode
);
void
mnodeDecMnodeRef
(
struct
SMnodeObj
*
pMnode
);
void
mnodeDecMnodeRef
(
struct
SMnodeObj
*
pMnode
);
...
...
src/mnode/inc/mnodeSdb.h
浏览文件 @
91bc2e9c
...
@@ -92,9 +92,9 @@ int32_t sdbDeleteRow(SSdbRow *pRow);
...
@@ -92,9 +92,9 @@ int32_t sdbDeleteRow(SSdbRow *pRow);
int32_t
sdbUpdateRow
(
SSdbRow
*
pRow
);
int32_t
sdbUpdateRow
(
SSdbRow
*
pRow
);
int32_t
sdbInsertRowToQueue
(
SSdbRow
*
pRow
);
int32_t
sdbInsertRowToQueue
(
SSdbRow
*
pRow
);
void
*
sdbGetRow
(
void
*
pTable
,
void
*
key
);
void
*
sdbGetRow
(
void
*
pTable
,
void
*
key
);
void
*
sdbFetchRow
(
void
*
pTable
,
void
*
pIter
,
void
**
ppRow
);
void
*
sdbFetchRow
(
void
*
pTable
,
void
*
pIter
,
void
**
ppRow
);
void
sdbFreeIter
(
void
*
pIter
);
void
sdbFreeIter
(
void
*
p
Table
,
void
*
p
Iter
);
void
sdbIncRef
(
void
*
pTable
,
void
*
pRow
);
void
sdbIncRef
(
void
*
pTable
,
void
*
pRow
);
void
sdbDecRef
(
void
*
pTable
,
void
*
pRow
);
void
sdbDecRef
(
void
*
pTable
,
void
*
pRow
);
int64_t
sdbGetNumOfRows
(
void
*
pTable
);
int64_t
sdbGetNumOfRows
(
void
*
pTable
);
...
...
src/mnode/inc/mnodeShow.h
浏览文件 @
91bc2e9c
...
@@ -26,8 +26,10 @@ void mnodeCleanUpShow();
...
@@ -26,8 +26,10 @@ void mnodeCleanUpShow();
typedef
int32_t
(
*
SShowMetaFp
)(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
typedef
int32_t
(
*
SShowMetaFp
)(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
typedef
int32_t
(
*
SShowRetrieveFp
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
typedef
int32_t
(
*
SShowRetrieveFp
)(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
typedef
void
(
*
SShowFreeIterFp
)(
void
*
pIter
);
void
mnodeAddShowMetaHandle
(
uint8_t
showType
,
SShowMetaFp
fp
);
void
mnodeAddShowMetaHandle
(
uint8_t
showType
,
SShowMetaFp
fp
);
void
mnodeAddShowRetrieveHandle
(
uint8_t
showType
,
SShowRetrieveFp
fp
);
void
mnodeAddShowRetrieveHandle
(
uint8_t
showType
,
SShowRetrieveFp
fp
);
void
mnodeAddShowFreeIterHandle
(
uint8_t
msgType
,
SShowFreeIterFp
fp
);
void
mnodeVacuumResult
(
char
*
data
,
int32_t
numOfCols
,
int32_t
rows
,
int32_t
capacity
,
SShowObj
*
pShow
);
void
mnodeVacuumResult
(
char
*
data
,
int32_t
numOfCols
,
int32_t
rows
,
int32_t
capacity
,
SShowObj
*
pShow
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
src/mnode/inc/mnodeTable.h
浏览文件 @
91bc2e9c
...
@@ -31,6 +31,8 @@ void mnodeIncTableRef(void *pTable);
...
@@ -31,6 +31,8 @@ void mnodeIncTableRef(void *pTable);
void
mnodeDecTableRef
(
void
*
pTable
);
void
mnodeDecTableRef
(
void
*
pTable
);
void
*
mnodeGetNextChildTable
(
void
*
pIter
,
SCTableObj
**
pTable
);
void
*
mnodeGetNextChildTable
(
void
*
pIter
,
SCTableObj
**
pTable
);
void
*
mnodeGetNextSuperTable
(
void
*
pIter
,
SSTableObj
**
pTable
);
void
*
mnodeGetNextSuperTable
(
void
*
pIter
,
SSTableObj
**
pTable
);
void
mnodeCancelGetNextChildTable
(
void
*
pIter
);
void
mnodeCancelGetNextSuperTable
(
void
*
pIter
);
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/mnodeUser.h
浏览文件 @
91bc2e9c
...
@@ -25,6 +25,7 @@ int32_t mnodeInitUsers();
...
@@ -25,6 +25,7 @@ int32_t mnodeInitUsers();
void
mnodeCleanupUsers
();
void
mnodeCleanupUsers
();
SUserObj
*
mnodeGetUser
(
char
*
name
);
SUserObj
*
mnodeGetUser
(
char
*
name
);
void
*
mnodeGetNextUser
(
void
*
pIter
,
SUserObj
**
pUser
);
void
*
mnodeGetNextUser
(
void
*
pIter
,
SUserObj
**
pUser
);
void
mnodeCancelGetNextUser
(
void
*
pIter
);
void
mnodeIncUserRef
(
SUserObj
*
pUser
);
void
mnodeIncUserRef
(
SUserObj
*
pUser
);
void
mnodeDecUserRef
(
SUserObj
*
pUser
);
void
mnodeDecUserRef
(
SUserObj
*
pUser
);
SUserObj
*
mnodeGetUserFromConn
(
void
*
pConn
);
SUserObj
*
mnodeGetUserFromConn
(
void
*
pConn
);
...
...
src/mnode/inc/mnodeVgroup.h
浏览文件 @
91bc2e9c
...
@@ -34,6 +34,7 @@ void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode);
...
@@ -34,6 +34,7 @@ void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode);
//void mnodeUpdateAllDbVgroups(SDbObj *pAlterDb);
//void mnodeUpdateAllDbVgroups(SDbObj *pAlterDb);
void
*
mnodeGetNextVgroup
(
void
*
pIter
,
SVgObj
**
pVgroup
);
void
*
mnodeGetNextVgroup
(
void
*
pIter
,
SVgObj
**
pVgroup
);
void
mnodeCancelGetNextVgroup
(
void
*
pIter
);
void
mnodeUpdateVgroup
(
SVgObj
*
pVgroup
);
void
mnodeUpdateVgroup
(
SVgObj
*
pVgroup
);
void
mnodeUpdateVgroupStatus
(
SVgObj
*
pVgroup
,
SDnodeObj
*
pDnode
,
SVnodeLoad
*
pVload
);
void
mnodeUpdateVgroupStatus
(
SVgObj
*
pVgroup
,
SDnodeObj
*
pDnode
,
SVnodeLoad
*
pVload
);
void
mnodeCheckUnCreatedVgroup
(
SDnodeObj
*
pDnode
,
SVnodeLoad
*
pVloads
,
int32_t
openVnodes
);
void
mnodeCheckUnCreatedVgroup
(
SDnodeObj
*
pDnode
,
SVnodeLoad
*
pVloads
,
int32_t
openVnodes
);
...
...
src/mnode/src/mnodeAcct.c
浏览文件 @
91bc2e9c
...
@@ -144,7 +144,6 @@ void mnodeGetStatOfAllAcct(SAcctInfo* pAcctInfo) {
...
@@ -144,7 +144,6 @@ void mnodeGetStatOfAllAcct(SAcctInfo* pAcctInfo) {
pAcctInfo
->
numOfTimeSeries
+=
pAcct
->
acctInfo
.
numOfTimeSeries
;
pAcctInfo
->
numOfTimeSeries
+=
pAcct
->
acctInfo
.
numOfTimeSeries
;
mnodeDecAcctRef
(
pAcct
);
mnodeDecAcctRef
(
pAcct
);
}
}
sdbFreeIter
(
pIter
);
SVgObj
*
pVgroup
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
pIter
=
NULL
;
pIter
=
NULL
;
...
@@ -158,7 +157,6 @@ void mnodeGetStatOfAllAcct(SAcctInfo* pAcctInfo) {
...
@@ -158,7 +157,6 @@ void mnodeGetStatOfAllAcct(SAcctInfo* pAcctInfo) {
pAcctInfo
->
totalPoints
+=
pVgroup
->
pointsWritten
;
pAcctInfo
->
totalPoints
+=
pVgroup
->
pointsWritten
;
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
}
}
sdbFreeIter
(
pIter
);
}
}
void
*
mnodeGetAcct
(
char
*
name
)
{
void
*
mnodeGetAcct
(
char
*
name
)
{
...
@@ -169,6 +167,10 @@ void *mnodeGetNextAcct(void *pIter, SAcctObj **pAcct) {
...
@@ -169,6 +167,10 @@ void *mnodeGetNextAcct(void *pIter, SAcctObj **pAcct) {
return
sdbFetchRow
(
tsAcctSdb
,
pIter
,
(
void
**
)
pAcct
);
return
sdbFetchRow
(
tsAcctSdb
,
pIter
,
(
void
**
)
pAcct
);
}
}
void
mnodeCancelGetNextAcct
(
void
*
pIter
)
{
sdbFreeIter
(
tsAcctSdb
,
pIter
);
}
void
mnodeIncAcctRef
(
SAcctObj
*
pAcct
)
{
void
mnodeIncAcctRef
(
SAcctObj
*
pAcct
)
{
sdbIncRef
(
tsAcctSdb
,
pAcct
);
sdbIncRef
(
tsAcctSdb
,
pAcct
);
}
}
...
...
src/mnode/src/mnodeCluster.c
浏览文件 @
91bc2e9c
...
@@ -31,6 +31,7 @@ static int32_t mnodeCreateCluster();
...
@@ -31,6 +31,7 @@ static int32_t mnodeCreateCluster();
static
int32_t
mnodeGetClusterMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeGetClusterMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeRetrieveClusters
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeRetrieveClusters
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
void
mnodeCancelGetNextCluster
(
void
*
pIter
);
static
int32_t
mnodeClusterActionDestroy
(
SSdbRow
*
pRow
)
{
static
int32_t
mnodeClusterActionDestroy
(
SSdbRow
*
pRow
)
{
tfree
(
pRow
->
pObj
);
tfree
(
pRow
->
pObj
);
...
@@ -108,6 +109,7 @@ int32_t mnodeInitCluster() {
...
@@ -108,6 +109,7 @@ int32_t mnodeInitCluster() {
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_CLUSTER
,
mnodeGetClusterMeta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_CLUSTER
,
mnodeGetClusterMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_CLUSTER
,
mnodeRetrieveClusters
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_CLUSTER
,
mnodeRetrieveClusters
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_CLUSTER
,
mnodeCancelGetNextCluster
);
mDebug
(
"table:%s, hash is created"
,
desc
.
name
);
mDebug
(
"table:%s, hash is created"
,
desc
.
name
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -122,6 +124,10 @@ void *mnodeGetNextCluster(void *pIter, SClusterObj **pCluster) {
...
@@ -122,6 +124,10 @@ void *mnodeGetNextCluster(void *pIter, SClusterObj **pCluster) {
return
sdbFetchRow
(
tsClusterSdb
,
pIter
,
(
void
**
)
pCluster
);
return
sdbFetchRow
(
tsClusterSdb
,
pIter
,
(
void
**
)
pCluster
);
}
}
void
mnodeCancelGetNextCluster
(
void
*
pIter
)
{
sdbFreeIter
(
tsClusterSdb
,
pIter
);
}
void
mnodeIncClusterRef
(
SClusterObj
*
pCluster
)
{
void
mnodeIncClusterRef
(
SClusterObj
*
pCluster
)
{
sdbIncRef
(
tsClusterSdb
,
pCluster
);
sdbIncRef
(
tsClusterSdb
,
pCluster
);
}
}
...
@@ -167,7 +173,7 @@ void mnodeUpdateClusterId() {
...
@@ -167,7 +173,7 @@ void mnodeUpdateClusterId() {
}
}
mnodeDecClusterRef
(
pCluster
);
mnodeDecClusterRef
(
pCluster
);
sdbFreeI
ter
(
pIter
);
mnodeCancelGetNextClus
ter
(
pIter
);
}
}
static
int32_t
mnodeGetClusterMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
static
int32_t
mnodeGetClusterMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
91bc2e9c
...
@@ -171,6 +171,7 @@ int32_t mnodeInitDbs() {
...
@@ -171,6 +171,7 @@ int32_t mnodeInitDbs() {
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_DROP_DB
,
mnodeProcessDropDbMsg
);
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_DROP_DB
,
mnodeProcessDropDbMsg
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeGetDbMeta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeGetDbMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeRetrieveDbs
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeRetrieveDbs
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeCancelGetNextDb
);
mDebug
(
"table:dbs table is created"
);
mDebug
(
"table:dbs table is created"
);
return
0
;
return
0
;
...
@@ -180,6 +181,10 @@ void *mnodeGetNextDb(void *pIter, SDbObj **pDb) {
...
@@ -180,6 +181,10 @@ void *mnodeGetNextDb(void *pIter, SDbObj **pDb) {
return
sdbFetchRow
(
tsDbSdb
,
pIter
,
(
void
**
)
pDb
);
return
sdbFetchRow
(
tsDbSdb
,
pIter
,
(
void
**
)
pDb
);
}
}
void
mnodeCancelGetNextDb
(
void
*
pIter
)
{
sdbFreeIter
(
tsDbSdb
,
pIter
);
}
SDbObj
*
mnodeGetDb
(
char
*
db
)
{
SDbObj
*
mnodeGetDb
(
char
*
db
)
{
return
(
SDbObj
*
)
sdbGetRow
(
tsDbSdb
,
db
);
return
(
SDbObj
*
)
sdbGetRow
(
tsDbSdb
,
db
);
}
}
...
@@ -986,8 +991,8 @@ static int32_t mnodeAlterDbCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -986,8 +991,8 @@ static int32_t mnodeAlterDbCb(SMnodeMsg *pMsg, int32_t code) {
SDbObj
*
pDb
=
pMsg
->
pDb
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
while
(
1
)
{
SVgObj
*
pVgroup
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
while
(
1
)
{
pIter
=
mnodeGetNextVgroup
(
pIter
,
&
pVgroup
);
pIter
=
mnodeGetNextVgroup
(
pIter
,
&
pVgroup
);
if
(
pVgroup
==
NULL
)
break
;
if
(
pVgroup
==
NULL
)
break
;
if
(
pVgroup
->
pDb
==
pDb
)
{
if
(
pVgroup
->
pDb
==
pDb
)
{
...
@@ -995,7 +1000,6 @@ static int32_t mnodeAlterDbCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -995,7 +1000,6 @@ static int32_t mnodeAlterDbCb(SMnodeMsg *pMsg, int32_t code) {
}
}
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
}
}
sdbFreeIter
(
pIter
);
mDebug
(
"db:%s, all vgroups is altered"
,
pDb
->
name
);
mDebug
(
"db:%s, all vgroups is altered"
,
pDb
->
name
);
mLInfo
(
"db:%s, is alterd by %s"
,
pDb
->
name
,
mnodeGetUserFromMsg
(
pMsg
));
mLInfo
(
"db:%s, is alterd by %s"
,
pDb
->
name
,
mnodeGetUserFromMsg
(
pMsg
));
...
@@ -1146,7 +1150,5 @@ void mnodeDropAllDbs(SAcctObj *pAcct) {
...
@@ -1146,7 +1150,5 @@ void mnodeDropAllDbs(SAcctObj *pAcct) {
mnodeDecDbRef
(
pDb
);
mnodeDecDbRef
(
pDb
);
}
}
sdbFreeIter
(
pIter
);
mInfo
(
"acct:%s, all dbs:%d is dropped from sdb"
,
pAcct
->
user
,
numOfDbs
);
mInfo
(
"acct:%s, all dbs:%d is dropped from sdb"
,
pAcct
->
user
,
numOfDbs
);
}
}
src/mnode/src/mnodeDnode.c
浏览文件 @
91bc2e9c
...
@@ -206,6 +206,7 @@ int32_t mnodeInitDnodes() {
...
@@ -206,6 +206,7 @@ int32_t mnodeInitDnodes() {
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_VNODES
,
mnodeRetrieveVnodes
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_VNODES
,
mnodeRetrieveVnodes
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_DNODE
,
mnodeGetDnodeMeta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_DNODE
,
mnodeGetDnodeMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_DNODE
,
mnodeRetrieveDnodes
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_DNODE
,
mnodeRetrieveDnodes
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_DNODE
,
mnodeCancelGetNextDnode
);
mDebug
(
"table:dnodes table is created"
);
mDebug
(
"table:dnodes table is created"
);
return
0
;
return
0
;
...
@@ -223,6 +224,10 @@ void *mnodeGetNextDnode(void *pIter, SDnodeObj **pDnode) {
...
@@ -223,6 +224,10 @@ void *mnodeGetNextDnode(void *pIter, SDnodeObj **pDnode) {
return
sdbFetchRow
(
tsDnodeSdb
,
pIter
,
(
void
**
)
pDnode
);
return
sdbFetchRow
(
tsDnodeSdb
,
pIter
,
(
void
**
)
pDnode
);
}
}
void
mnodeCancelGetNextDnode
(
void
*
pIter
)
{
sdbFreeIter
(
tsDnodeSdb
,
pIter
);
}
int32_t
mnodeGetDnodesNum
()
{
int32_t
mnodeGetDnodesNum
()
{
return
sdbGetNumOfRows
(
tsDnodeSdb
);
return
sdbGetNumOfRows
(
tsDnodeSdb
);
}
}
...
@@ -241,8 +246,6 @@ int32_t mnodeGetOnlinDnodesCpuCoreNum() {
...
@@ -241,8 +246,6 @@ int32_t mnodeGetOnlinDnodesCpuCoreNum() {
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
}
}
sdbFreeIter
(
pIter
);
if
(
cpuCores
<
2
)
cpuCores
=
2
;
if
(
cpuCores
<
2
)
cpuCores
=
2
;
return
cpuCores
;
return
cpuCores
;
}
}
...
@@ -259,8 +262,6 @@ int32_t mnodeGetOnlineDnodesNum() {
...
@@ -259,8 +262,6 @@ int32_t mnodeGetOnlineDnodesNum() {
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
}
}
sdbFreeIter
(
pIter
);
return
onlineDnodes
;
return
onlineDnodes
;
}
}
...
@@ -276,13 +277,12 @@ void *mnodeGetDnodeByEp(char *ep) {
...
@@ -276,13 +277,12 @@ void *mnodeGetDnodeByEp(char *ep) {
pIter
=
mnodeGetNextDnode
(
pIter
,
&
pDnode
);
pIter
=
mnodeGetNextDnode
(
pIter
,
&
pDnode
);
if
(
pDnode
==
NULL
)
break
;
if
(
pDnode
==
NULL
)
break
;
if
(
strcmp
(
ep
,
pDnode
->
dnodeEp
)
==
0
)
{
if
(
strcmp
(
ep
,
pDnode
->
dnodeEp
)
==
0
)
{
sdbFreeIter
(
pIter
);
mnodeCancelGetNextDnode
(
pIter
);
return
pDnode
;
return
pDnode
;
}
}
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
}
}
sdbFreeIter
(
pIter
);
return
NULL
;
return
NULL
;
}
}
...
@@ -464,7 +464,10 @@ static void mnodeUpdateDnodeEps() {
...
@@ -464,7 +464,10 @@ static void mnodeUpdateDnodeEps() {
while
(
1
)
{
while
(
1
)
{
pIter
=
mnodeGetNextDnode
(
pIter
,
&
pDnode
);
pIter
=
mnodeGetNextDnode
(
pIter
,
&
pDnode
);
if
(
pDnode
==
NULL
)
break
;
if
(
pDnode
==
NULL
)
break
;
if
(
dnodesNum
>=
totalDnodes
)
break
;
if
(
dnodesNum
>=
totalDnodes
)
{
mnodeCancelGetNextDnode
(
pIter
);
break
;
}
SDnodeEp
*
pEp
=
&
tsDnodeEps
->
dnodeEps
[
dnodesNum
];
SDnodeEp
*
pEp
=
&
tsDnodeEps
->
dnodeEps
[
dnodesNum
];
dnodesNum
++
;
dnodesNum
++
;
...
@@ -474,7 +477,6 @@ static void mnodeUpdateDnodeEps() {
...
@@ -474,7 +477,6 @@ static void mnodeUpdateDnodeEps() {
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
}
}
sdbFreeIter
(
pIter
);
pthread_mutex_unlock
(
&
tsDnodeEpsMutex
);
pthread_mutex_unlock
(
&
tsDnodeEpsMutex
);
}
}
...
@@ -1100,7 +1102,7 @@ static int32_t mnodeGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
...
@@ -1100,7 +1102,7 @@ static int32_t mnodeGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
pDnode
=
mnodeGetDnodeByEp
(
pShow
->
payload
);
pDnode
=
mnodeGetDnodeByEp
(
pShow
->
payload
);
}
else
{
}
else
{
void
*
pIter
=
mnodeGetNextDnode
(
NULL
,
(
SDnodeObj
**
)
&
pDnode
);
void
*
pIter
=
mnodeGetNextDnode
(
NULL
,
(
SDnodeObj
**
)
&
pDnode
);
sdbFreeIter
(
pIter
);
mnodeCancelGetNextDnode
(
pIter
);
}
}
if
(
pDnode
!=
NULL
)
{
if
(
pDnode
!=
NULL
)
{
...
@@ -1148,7 +1150,6 @@ static int32_t mnodeRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, vo
...
@@ -1148,7 +1150,6 @@ static int32_t mnodeRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, vo
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
}
}
sdbFreeIter
(
pIter
);
}
else
{
}
else
{
numOfRows
=
0
;
numOfRows
=
0
;
}
}
...
@@ -1217,8 +1218,6 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
...
@@ -1217,8 +1218,6 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
}
}
sdbFreeIter
(
pIter
);
if
(
pSelDnode
==
NULL
)
{
if
(
pSelDnode
==
NULL
)
{
mError
(
"failed to alloc vnode to vgroup"
);
mError
(
"failed to alloc vnode to vgroup"
);
return
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
return
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
...
...
src/mnode/src/mnodeMnode.c
浏览文件 @
91bc2e9c
...
@@ -123,7 +123,7 @@ static int32_t mnodeMnodeActionRestored() {
...
@@ -123,7 +123,7 @@ static int32_t mnodeMnodeActionRestored() {
pMnode
->
role
=
TAOS_SYNC_ROLE_MASTER
;
pMnode
->
role
=
TAOS_SYNC_ROLE_MASTER
;
mnodeDecMnodeRef
(
pMnode
);
mnodeDecMnodeRef
(
pMnode
);
}
}
sdbFreeIter
(
pIter
);
mnodeCancelGetNextMnode
(
pIter
);
}
}
mnodeUpdateMnodeEpSet
();
mnodeUpdateMnodeEpSet
();
...
@@ -161,6 +161,7 @@ int32_t mnodeInitMnodes() {
...
@@ -161,6 +161,7 @@ int32_t mnodeInitMnodes() {
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_MNODE
,
mnodeGetMnodeMeta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_MNODE
,
mnodeGetMnodeMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_MNODE
,
mnodeRetrieveMnodes
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_MNODE
,
mnodeRetrieveMnodes
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_MNODE
,
mnodeCancelGetNextMnode
);
mDebug
(
"table:mnodes table is created"
);
mDebug
(
"table:mnodes table is created"
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -192,6 +193,10 @@ void *mnodeGetNextMnode(void *pIter, SMnodeObj **pMnode) {
...
@@ -192,6 +193,10 @@ void *mnodeGetNextMnode(void *pIter, SMnodeObj **pMnode) {
return
sdbFetchRow
(
tsMnodeSdb
,
pIter
,
(
void
**
)
pMnode
);
return
sdbFetchRow
(
tsMnodeSdb
,
pIter
,
(
void
**
)
pMnode
);
}
}
void
mnodeCancelGetNextMnode
(
void
*
pIter
)
{
sdbFreeIter
(
tsMnodeSdb
,
pIter
);
}
void
mnodeUpdateMnodeEpSet
()
{
void
mnodeUpdateMnodeEpSet
()
{
mInfo
(
"update mnodes epSet, numOfEps:%d "
,
mnodeGetMnodesNum
());
mInfo
(
"update mnodes epSet, numOfEps:%d "
,
mnodeGetMnodesNum
());
...
@@ -239,8 +244,6 @@ void mnodeUpdateMnodeEpSet() {
...
@@ -239,8 +244,6 @@ void mnodeUpdateMnodeEpSet() {
tsMnodeEpSetForShell
.
numOfEps
=
index
;
tsMnodeEpSetForShell
.
numOfEps
=
index
;
tsMnodeEpSetForPeer
.
numOfEps
=
index
;
tsMnodeEpSetForPeer
.
numOfEps
=
index
;
sdbFreeIter
(
pIter
);
mnodeMnodeUnLock
();
mnodeMnodeUnLock
();
}
}
...
...
src/mnode/src/mnodeProfile.c
浏览文件 @
91bc2e9c
...
@@ -42,6 +42,7 @@ static int32_t mnodeGetQueryMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
...
@@ -42,6 +42,7 @@ static int32_t mnodeGetQueryMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
static
int32_t
mnodeRetrieveQueries
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeRetrieveQueries
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeGetConnsMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeGetConnsMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeRetrieveConns
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeRetrieveConns
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
void
mnodeCancelGetNextConn
(
void
*
pIter
);
static
int32_t
mnodeGetStreamMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeGetStreamMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeRetrieveStreams
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeRetrieveStreams
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
void
mnodeFreeConn
(
void
*
data
);
static
void
mnodeFreeConn
(
void
*
data
);
...
@@ -52,10 +53,13 @@ static int32_t mnodeProcessKillConnectionMsg(SMnodeMsg *pMsg);
...
@@ -52,10 +53,13 @@ static int32_t mnodeProcessKillConnectionMsg(SMnodeMsg *pMsg);
int32_t
mnodeInitProfile
()
{
int32_t
mnodeInitProfile
()
{
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_QUERIES
,
mnodeGetQueryMeta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_QUERIES
,
mnodeGetQueryMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_QUERIES
,
mnodeRetrieveQueries
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_QUERIES
,
mnodeRetrieveQueries
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_QUERIES
,
mnodeCancelGetNextConn
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_CONNS
,
mnodeGetConnsMeta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_CONNS
,
mnodeGetConnsMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_CONNS
,
mnodeRetrieveConns
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_CONNS
,
mnodeRetrieveConns
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_CONNS
,
mnodeCancelGetNextConn
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_STREAMS
,
mnodeGetStreamMeta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_STREAMS
,
mnodeGetStreamMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_STREAMS
,
mnodeRetrieveStreams
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_STREAMS
,
mnodeRetrieveStreams
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_STREAMS
,
mnodeCancelGetNextConn
);
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_KILL_QUERY
,
mnodeProcessKillQueryMsg
);
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_KILL_QUERY
,
mnodeProcessKillQueryMsg
);
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_KILL_STREAM
,
mnodeProcessKillStreamMsg
);
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_KILL_STREAM
,
mnodeProcessKillStreamMsg
);
...
@@ -137,21 +141,15 @@ static void mnodeFreeConn(void *data) {
...
@@ -137,21 +141,15 @@ static void mnodeFreeConn(void *data) {
mDebug
(
"connId:%d, is destroyed"
,
pConn
->
connId
);
mDebug
(
"connId:%d, is destroyed"
,
pConn
->
connId
);
}
}
static
void
*
mnodeGetNextConn
(
SHashMutableIterator
*
pIter
,
SConnObj
**
pConn
)
{
static
void
*
mnodeGetNextConn
(
void
*
pIter
,
SConnObj
**
pConn
)
{
*
pConn
=
NULL
;
*
pConn
=
NULL
;
if
(
pIter
==
NULL
)
{
pIter
=
taosHashIterate
(
tsMnodeConnCache
->
pHashTable
,
pIter
);
pIter
=
taosHashCreateIter
(
tsMnodeConnCache
->
pHashTable
);
if
(
pIter
==
NULL
)
return
NULL
;
}
if
(
!
taosHashIterNext
(
pIter
))
{
taosHashDestroyIter
(
pIter
);
return
NULL
;
}
SCacheDataNode
**
pNode
=
taosHashIterGet
(
pIter
)
;
SCacheDataNode
**
pNode
=
pIter
;
if
(
pNode
==
NULL
||
*
pNode
==
NULL
)
{
if
(
pNode
==
NULL
||
*
pNode
==
NULL
)
{
taosHash
DestroyIter
(
pIter
);
taosHash
CancelIterate
(
tsMnodeConnCache
->
pHashTable
,
pIter
);
return
NULL
;
return
NULL
;
}
}
...
@@ -159,6 +157,10 @@ static void *mnodeGetNextConn(SHashMutableIterator *pIter, SConnObj **pConn) {
...
@@ -159,6 +157,10 @@ static void *mnodeGetNextConn(SHashMutableIterator *pIter, SConnObj **pConn) {
return
pIter
;
return
pIter
;
}
}
static
void
mnodeCancelGetNextConn
(
void
*
pIter
)
{
taosHashCancelIterate
(
tsMnodeConnCache
->
pHashTable
,
pIter
);
}
static
int32_t
mnodeGetConnsMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
static
int32_t
mnodeGetConnsMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
SUserObj
*
pUser
=
mnodeGetUserFromConn
(
pConn
);
SUserObj
*
pUser
=
mnodeGetUserFromConn
(
pConn
);
if
(
pUser
==
NULL
)
return
0
;
if
(
pUser
==
NULL
)
return
0
;
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
91bc2e9c
...
@@ -325,7 +325,6 @@ void sdbUpdateSync(void *pMnodes) {
...
@@ -325,7 +325,6 @@ void sdbUpdateSync(void *pMnodes) {
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
mnodeDecMnodeRef
(
pMnode
);
mnodeDecMnodeRef
(
pMnode
);
}
}
sdbFreeIter
(
pIter
);
syncCfg
.
replica
=
index
;
syncCfg
.
replica
=
index
;
mDebug
(
"vgId:1, mnodes info not input, use infos in sdb, numOfMnodes:%d"
,
syncCfg
.
replica
);
mDebug
(
"vgId:1, mnodes info not input, use infos in sdb, numOfMnodes:%d"
,
syncCfg
.
replica
);
}
else
{
}
else
{
...
@@ -775,24 +774,17 @@ int32_t sdbUpdateRow(SSdbRow *pRow) {
...
@@ -775,24 +774,17 @@ int32_t sdbUpdateRow(SSdbRow *pRow) {
}
}
}
}
void
*
sdbFetchRow
(
void
*
tparam
,
void
*
p
Node
,
void
**
ppRow
)
{
void
*
sdbFetchRow
(
void
*
tparam
,
void
*
p
Iter
,
void
**
ppRow
)
{
SSdbTable
*
pTable
=
tparam
;
SSdbTable
*
pTable
=
tparam
;
*
ppRow
=
NULL
;
*
ppRow
=
NULL
;
if
(
pTable
==
NULL
)
return
NULL
;
if
(
pTable
==
NULL
)
return
NULL
;
SHashMutableIterator
*
pIter
=
pNode
;
pIter
=
taosHashIterate
(
pTable
->
iHandle
,
pIter
);
if
(
pIter
==
NULL
)
{
if
(
pIter
==
NULL
)
return
NULL
;
pIter
=
taosHashCreateIter
(
pTable
->
iHandle
);
}
if
(
!
taosHashIterNext
(
pIter
))
{
taosHashDestroyIter
(
pIter
);
return
NULL
;
}
void
**
ppMetaRow
=
taosHashIterGet
(
pIter
)
;
void
**
ppMetaRow
=
pIter
;
if
(
ppMetaRow
==
NULL
)
{
if
(
ppMetaRow
==
NULL
)
{
taosHash
DestroyIter
(
pIter
);
taosHash
CancelIterate
(
pTable
->
iHandle
,
pIter
);
return
NULL
;
return
NULL
;
}
}
...
@@ -802,10 +794,11 @@ void *sdbFetchRow(void *tparam, void *pNode, void **ppRow) {
...
@@ -802,10 +794,11 @@ void *sdbFetchRow(void *tparam, void *pNode, void **ppRow) {
return
pIter
;
return
pIter
;
}
}
void
sdbFreeIter
(
void
*
pIter
)
{
void
sdbFreeIter
(
void
*
tparam
,
void
*
pIter
)
{
if
(
pIter
!=
NULL
)
{
SSdbTable
*
pTable
=
tparam
;
taosHashDestroyIter
(
pIter
);
if
(
pTable
==
NULL
||
pIter
==
NULL
)
return
;
}
taosHashCancelIterate
(
pTable
->
iHandle
,
pIter
);
}
}
void
*
sdbOpenTable
(
SSdbTableDesc
*
pDesc
)
{
void
*
sdbOpenTable
(
SSdbTableDesc
*
pDesc
)
{
...
@@ -846,9 +839,10 @@ void sdbCloseTable(void *handle) {
...
@@ -846,9 +839,10 @@ void sdbCloseTable(void *handle) {
tsSdbMgmt
.
numOfTables
--
;
tsSdbMgmt
.
numOfTables
--
;
tsSdbMgmt
.
tableList
[
pTable
->
id
]
=
NULL
;
tsSdbMgmt
.
tableList
[
pTable
->
id
]
=
NULL
;
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
pTable
->
iHandle
);
void
*
pIter
=
taosHashIterate
(
pTable
->
iHandle
,
NULL
);
while
(
taosHashIterNext
(
pIter
))
{
while
(
pIter
)
{
void
**
ppRow
=
taosHashIterGet
(
pIter
);
void
**
ppRow
=
pIter
;
pIter
=
taosHashIterate
(
pTable
->
iHandle
,
pIter
);
if
(
ppRow
==
NULL
)
continue
;
if
(
ppRow
==
NULL
)
continue
;
SSdbRow
row
=
{
SSdbRow
row
=
{
...
@@ -859,7 +853,7 @@ void sdbCloseTable(void *handle) {
...
@@ -859,7 +853,7 @@ void sdbCloseTable(void *handle) {
(
*
pTable
->
fpDestroy
)(
&
row
);
(
*
pTable
->
fpDestroy
)(
&
row
);
}
}
taosHash
DestroyIter
(
pIter
);
taosHash
CancelIterate
(
pTable
->
iHandle
,
pIter
);
taosHashCleanup
(
pTable
->
iHandle
);
taosHashCleanup
(
pTable
->
iHandle
);
pthread_mutex_destroy
(
&
pTable
->
mutex
);
pthread_mutex_destroy
(
&
pTable
->
mutex
);
...
...
src/mnode/src/mnodeShow.c
浏览文件 @
91bc2e9c
...
@@ -57,6 +57,7 @@ static void *tsMnodeShowCache = NULL;
...
@@ -57,6 +57,7 @@ static void *tsMnodeShowCache = NULL;
static
int32_t
tsShowObjIndex
=
0
;
static
int32_t
tsShowObjIndex
=
0
;
static
SShowMetaFp
tsMnodeShowMetaFp
[
TSDB_MGMT_TABLE_MAX
]
=
{
0
};
static
SShowMetaFp
tsMnodeShowMetaFp
[
TSDB_MGMT_TABLE_MAX
]
=
{
0
};
static
SShowRetrieveFp
tsMnodeShowRetrieveFp
[
TSDB_MGMT_TABLE_MAX
]
=
{
0
};
static
SShowRetrieveFp
tsMnodeShowRetrieveFp
[
TSDB_MGMT_TABLE_MAX
]
=
{
0
};
static
SShowFreeIterFp
tsMnodeShowFreeIterFp
[
TSDB_MGMT_TABLE_MAX
]
=
{
0
};
int32_t
mnodeInitShow
()
{
int32_t
mnodeInitShow
()
{
mnodeAddReadMsgHandle
(
TSDB_MSG_TYPE_CM_SHOW
,
mnodeProcessShowMsg
);
mnodeAddReadMsgHandle
(
TSDB_MSG_TYPE_CM_SHOW
,
mnodeProcessShowMsg
);
...
@@ -85,6 +86,10 @@ void mnodeAddShowRetrieveHandle(uint8_t msgType, SShowRetrieveFp fp) {
...
@@ -85,6 +86,10 @@ void mnodeAddShowRetrieveHandle(uint8_t msgType, SShowRetrieveFp fp) {
tsMnodeShowRetrieveFp
[
msgType
]
=
fp
;
tsMnodeShowRetrieveFp
[
msgType
]
=
fp
;
}
}
void
mnodeAddShowFreeIterHandle
(
uint8_t
msgType
,
SShowFreeIterFp
fp
)
{
tsMnodeShowFreeIterFp
[
msgType
]
=
fp
;
}
static
char
*
mnodeGetShowType
(
int32_t
showType
)
{
static
char
*
mnodeGetShowType
(
int32_t
showType
)
{
switch
(
showType
)
{
switch
(
showType
)
{
case
TSDB_MGMT_TABLE_ACCT
:
return
"show accounts"
;
case
TSDB_MGMT_TABLE_ACCT
:
return
"show accounts"
;
...
@@ -412,7 +417,9 @@ static void* mnodePutShowObj(SShowObj *pShow) {
...
@@ -412,7 +417,9 @@ static void* mnodePutShowObj(SShowObj *pShow) {
static
void
mnodeFreeShowObj
(
void
*
data
)
{
static
void
mnodeFreeShowObj
(
void
*
data
)
{
SShowObj
*
pShow
=
*
(
SShowObj
**
)
data
;
SShowObj
*
pShow
=
*
(
SShowObj
**
)
data
;
sdbFreeIter
(
pShow
->
pIter
);
if
(
tsMnodeShowFreeIterFp
[
pShow
->
type
]
!=
NULL
&&
pShow
->
pIter
!=
NULL
)
{
(
*
tsMnodeShowFreeIterFp
[
pShow
->
type
])(
pShow
->
pIter
);
}
mDebug
(
"%p, show is destroyed, data:%p index:%d"
,
pShow
,
data
,
pShow
->
index
);
mDebug
(
"%p, show is destroyed, data:%p index:%d"
,
pShow
,
data
,
pShow
->
index
);
tfree
(
pShow
);
tfree
(
pShow
);
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
91bc2e9c
...
@@ -342,8 +342,7 @@ static int32_t mnodeChildTableActionRestored() {
...
@@ -342,8 +342,7 @@ static int32_t mnodeChildTableActionRestored() {
mnodeDecTableRef
(
pTable
);
mnodeDecTableRef
(
pTable
);
}
}
sdbFreeIter
(
pIter
);
mnodeCancelGetNextChildTable
(
pIter
);
return
0
;
return
0
;
}
}
...
@@ -602,10 +601,13 @@ int32_t mnodeInitTables() {
...
@@ -602,10 +601,13 @@ int32_t mnodeInitTables() {
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_TABLE
,
mnodeGetShowTableMeta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_TABLE
,
mnodeGetShowTableMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_TABLE
,
mnodeRetrieveShowTables
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_TABLE
,
mnodeRetrieveShowTables
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_TABLE
,
mnodeCancelGetNextChildTable
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_METRIC
,
mnodeGetShowSuperTableMeta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_METRIC
,
mnodeGetShowSuperTableMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_METRIC
,
mnodeRetrieveShowSuperTables
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_METRIC
,
mnodeRetrieveShowSuperTables
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_METRIC
,
mnodeCancelGetNextSuperTable
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_STREAMTABLES
,
mnodeGetStreamTableMeta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_STREAMTABLES
,
mnodeGetStreamTableMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_STREAMTABLES
,
mnodeRetrieveStreamTables
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_STREAMTABLES
,
mnodeRetrieveStreamTables
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_STREAMTABLES
,
mnodeCancelGetNextChildTable
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -626,14 +628,12 @@ static void *mnodeGetSuperTableByUid(uint64_t uid) {
...
@@ -626,14 +628,12 @@ static void *mnodeGetSuperTableByUid(uint64_t uid) {
pIter
=
mnodeGetNextSuperTable
(
pIter
,
&
pStable
);
pIter
=
mnodeGetNextSuperTable
(
pIter
,
&
pStable
);
if
(
pStable
==
NULL
)
break
;
if
(
pStable
==
NULL
)
break
;
if
(
pStable
->
uid
==
uid
)
{
if
(
pStable
->
uid
==
uid
)
{
sdbFreeIter
(
pIter
);
mnodeCancelGetNextSuperTable
(
pIter
);
return
pStable
;
return
pStable
;
}
}
mnodeDecTableRef
(
pStable
);
mnodeDecTableRef
(
pStable
);
}
}
sdbFreeIter
(
pIter
);
return
NULL
;
return
NULL
;
}
}
...
@@ -655,10 +655,18 @@ void *mnodeGetNextChildTable(void *pIter, SCTableObj **pTable) {
...
@@ -655,10 +655,18 @@ void *mnodeGetNextChildTable(void *pIter, SCTableObj **pTable) {
return
sdbFetchRow
(
tsChildTableSdb
,
pIter
,
(
void
**
)
pTable
);
return
sdbFetchRow
(
tsChildTableSdb
,
pIter
,
(
void
**
)
pTable
);
}
}
void
mnodeCancelGetNextChildTable
(
void
*
pIter
)
{
sdbFreeIter
(
tsChildTableSdb
,
pIter
);
}
void
*
mnodeGetNextSuperTable
(
void
*
pIter
,
SSTableObj
**
pTable
)
{
void
*
mnodeGetNextSuperTable
(
void
*
pIter
,
SSTableObj
**
pTable
)
{
return
sdbFetchRow
(
tsSuperTableSdb
,
pIter
,
(
void
**
)
pTable
);
return
sdbFetchRow
(
tsSuperTableSdb
,
pIter
,
(
void
**
)
pTable
);
}
}
void
mnodeCancelGetNextSuperTable
(
void
*
pIter
)
{
sdbFreeIter
(
tsSuperTableSdb
,
pIter
);
}
void
mnodeIncTableRef
(
void
*
p1
)
{
void
mnodeIncTableRef
(
void
*
p1
)
{
STableObj
*
pTable
=
(
STableObj
*
)
p1
;
STableObj
*
pTable
=
(
STableObj
*
)
p1
;
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
...
@@ -914,10 +922,10 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
...
@@ -914,10 +922,10 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
SSTableObj
*
pStable
=
(
SSTableObj
*
)
pMsg
->
pTable
;
SSTableObj
*
pStable
=
(
SSTableObj
*
)
pMsg
->
pTable
;
if
(
pStable
->
vgHash
!=
NULL
/*pStable->numOfTables != 0*/
)
{
if
(
pStable
->
vgHash
!=
NULL
/*pStable->numOfTables != 0*/
)
{
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
pStable
->
vgHash
);
int32_t
*
pVgId
=
taosHashIterate
(
pStable
->
vgHash
,
NULL
);
while
(
taosHashIterNext
(
pIter
))
{
while
(
pVgId
)
{
int32_t
*
pVgId
=
taosHashIterGet
(
pIter
);
SVgObj
*
pVgroup
=
mnodeGetVgroup
(
*
pVgId
);
SVgObj
*
pVgroup
=
mnodeGetVgroup
(
*
pVgId
);
pVgId
=
taosHashIterate
(
pStable
->
vgHash
,
pVgId
);
if
(
pVgroup
==
NULL
)
break
;
if
(
pVgroup
==
NULL
)
break
;
SDropSTableMsg
*
pDrop
=
rpcMallocCont
(
sizeof
(
SDropSTableMsg
));
SDropSTableMsg
*
pDrop
=
rpcMallocCont
(
sizeof
(
SDropSTableMsg
));
...
@@ -933,7 +941,8 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
...
@@ -933,7 +941,8 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
dnodeSendMsgToDnode
(
&
epSet
,
&
rpcMsg
);
dnodeSendMsgToDnode
(
&
epSet
,
&
rpcMsg
);
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
}
}
taosHashDestroyIter
(
pIter
);
taosHashCancelIterate
(
pStable
->
vgHash
,
pVgId
);
mnodeDropAllChildTablesInStable
(
pStable
);
mnodeDropAllChildTablesInStable
(
pStable
);
}
}
...
@@ -1430,8 +1439,6 @@ void mnodeDropAllSuperTables(SDbObj *pDropDb) {
...
@@ -1430,8 +1439,6 @@ void mnodeDropAllSuperTables(SDbObj *pDropDb) {
mnodeDecTableRef
(
pTable
);
mnodeDecTableRef
(
pTable
);
}
}
sdbFreeIter
(
pIter
);
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
);
}
}
...
@@ -1523,11 +1530,11 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
...
@@ -1523,11 +1530,11 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
}
else
{
}
else
{
SVgroupsMsg
*
pVgroupMsg
=
(
SVgroupsMsg
*
)
msg
;
SVgroupsMsg
*
pVgroupMsg
=
(
SVgroupsMsg
*
)
msg
;
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
pTable
->
vgHash
);
int32_t
*
pVgId
=
taosHashIterate
(
pTable
->
vgHash
,
NULL
);
int32_t
vgSize
=
0
;
int32_t
vgSize
=
0
;
while
(
taosHashIterNext
(
pIter
)
)
{
while
(
pVgId
)
{
int32_t
*
pVgId
=
taosHashIterGet
(
pIter
);
SVgObj
*
pVgroup
=
mnodeGetVgroup
(
*
pVgId
);
SVgObj
*
pVgroup
=
mnodeGetVgroup
(
*
pVgId
);
pVgId
=
taosHashIterate
(
pTable
->
vgHash
,
pVgId
);
if
(
pVgroup
==
NULL
)
continue
;
if
(
pVgroup
==
NULL
)
continue
;
pVgroupMsg
->
vgroups
[
vgSize
].
vgId
=
htonl
(
pVgroup
->
vgId
);
pVgroupMsg
->
vgroups
[
vgSize
].
vgId
=
htonl
(
pVgroup
->
vgId
);
...
@@ -1547,7 +1554,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
...
@@ -1547,7 +1554,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
}
}
taosHash
DestroyIter
(
pIter
);
taosHash
CancelIterate
(
pTable
->
vgHash
,
pVgId
);
mnodeDecTableRef
(
pTable
);
mnodeDecTableRef
(
pTable
);
pVgroupMsg
->
numOfVgroups
=
htonl
(
vgSize
);
pVgroupMsg
->
numOfVgroups
=
htonl
(
vgSize
);
...
@@ -2230,8 +2237,6 @@ void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup) {
...
@@ -2230,8 +2237,6 @@ void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup) {
mnodeDecTableRef
(
pTable
);
mnodeDecTableRef
(
pTable
);
}
}
sdbFreeIter
(
pIter
);
mInfo
(
"vgId:%d, all child tables is dropped from sdb"
,
pVgroup
->
vgId
);
mInfo
(
"vgId:%d, all child tables is dropped from sdb"
,
pVgroup
->
vgId
);
}
}
...
@@ -2263,8 +2268,6 @@ void mnodeDropAllChildTables(SDbObj *pDropDb) {
...
@@ -2263,8 +2268,6 @@ void mnodeDropAllChildTables(SDbObj *pDropDb) {
mnodeDecTableRef
(
pTable
);
mnodeDecTableRef
(
pTable
);
}
}
sdbFreeIter
(
pIter
);
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
);
}
}
...
@@ -2293,8 +2296,6 @@ static void mnodeDropAllChildTablesInStable(SSTableObj *pStable) {
...
@@ -2293,8 +2296,6 @@ static void mnodeDropAllChildTablesInStable(SSTableObj *pStable) {
mnodeDecTableRef
(
pTable
);
mnodeDecTableRef
(
pTable
);
}
}
sdbFreeIter
(
pIter
);
mInfo
(
"stable:%s, all child tables:%d is dropped from sdb"
,
pStable
->
info
.
tableId
,
numOfTables
);
mInfo
(
"stable:%s, all child tables:%d is dropped from sdb"
,
pStable
->
info
.
tableId
,
numOfTables
);
}
}
...
...
src/mnode/src/mnodeUser.c
浏览文件 @
91bc2e9c
...
@@ -123,7 +123,6 @@ static void mnodePrintUserAuth() {
...
@@ -123,7 +123,6 @@ static void mnodePrintUserAuth() {
}
}
fflush
(
fp
);
fflush
(
fp
);
sdbFreeIter
(
pIter
);
fclose
(
fp
);
fclose
(
fp
);
}
}
...
@@ -177,6 +176,8 @@ int32_t mnodeInitUsers() {
...
@@ -177,6 +176,8 @@ int32_t mnodeInitUsers() {
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_DROP_USER
,
mnodeProcessDropUserMsg
);
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_DROP_USER
,
mnodeProcessDropUserMsg
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_USER
,
mnodeGetUserMeta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_USER
,
mnodeGetUserMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_USER
,
mnodeRetrieveUsers
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_USER
,
mnodeRetrieveUsers
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_USER
,
mnodeCancelGetNextUser
);
mnodeAddPeerMsgHandle
(
TSDB_MSG_TYPE_DM_AUTH
,
mnodeProcessAuthMsg
);
mnodeAddPeerMsgHandle
(
TSDB_MSG_TYPE_DM_AUTH
,
mnodeProcessAuthMsg
);
mDebug
(
"table:%s, hash is created"
,
desc
.
name
);
mDebug
(
"table:%s, hash is created"
,
desc
.
name
);
...
@@ -196,6 +197,10 @@ void *mnodeGetNextUser(void *pIter, SUserObj **pUser) {
...
@@ -196,6 +197,10 @@ void *mnodeGetNextUser(void *pIter, SUserObj **pUser) {
return
sdbFetchRow
(
tsUserSdb
,
pIter
,
(
void
**
)
pUser
);
return
sdbFetchRow
(
tsUserSdb
,
pIter
,
(
void
**
)
pUser
);
}
}
void
mnodeCancelGetNextUser
(
void
*
pIter
)
{
sdbFreeIter
(
tsUserSdb
,
pIter
);
}
void
mnodeIncUserRef
(
SUserObj
*
pUser
)
{
void
mnodeIncUserRef
(
SUserObj
*
pUser
)
{
return
sdbIncRef
(
tsUserSdb
,
pUser
);
return
sdbIncRef
(
tsUserSdb
,
pUser
);
}
}
...
@@ -574,8 +579,6 @@ void mnodeDropAllUsers(SAcctObj *pAcct) {
...
@@ -574,8 +579,6 @@ void mnodeDropAllUsers(SAcctObj *pAcct) {
mnodeDecUserRef
(
pUser
);
mnodeDecUserRef
(
pUser
);
}
}
sdbFreeIter
(
pIter
);
mDebug
(
"acct:%s, all users:%d is dropped from sdb"
,
pAcct
->
user
,
numOfUsers
);
mDebug
(
"acct:%s, all users:%d is dropped from sdb"
,
pAcct
->
user
,
numOfUsers
);
}
}
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
91bc2e9c
...
@@ -230,6 +230,7 @@ int32_t mnodeInitVgroups() {
...
@@ -230,6 +230,7 @@ int32_t mnodeInitVgroups() {
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_VGROUP
,
mnodeGetVgroupMeta
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_VGROUP
,
mnodeGetVgroupMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_VGROUP
,
mnodeRetrieveVgroups
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_VGROUP
,
mnodeRetrieveVgroups
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_VGROUP
,
mnodeCancelGetNextVgroup
);
mnodeAddPeerRspHandle
(
TSDB_MSG_TYPE_MD_CREATE_VNODE_RSP
,
mnodeProcessCreateVnodeRsp
);
mnodeAddPeerRspHandle
(
TSDB_MSG_TYPE_MD_CREATE_VNODE_RSP
,
mnodeProcessCreateVnodeRsp
);
mnodeAddPeerRspHandle
(
TSDB_MSG_TYPE_MD_ALTER_VNODE_RSP
,
mnodeProcessAlterVnodeRsp
);
mnodeAddPeerRspHandle
(
TSDB_MSG_TYPE_MD_ALTER_VNODE_RSP
,
mnodeProcessAlterVnodeRsp
);
mnodeAddPeerRspHandle
(
TSDB_MSG_TYPE_MD_DROP_VNODE_RSP
,
mnodeProcessDropVnodeRsp
);
mnodeAddPeerRspHandle
(
TSDB_MSG_TYPE_MD_DROP_VNODE_RSP
,
mnodeProcessDropVnodeRsp
);
...
@@ -304,7 +305,7 @@ void mnodeCheckUnCreatedVgroup(SDnodeObj *pDnode, SVnodeLoad *pVloads, int32_t o
...
@@ -304,7 +305,7 @@ void mnodeCheckUnCreatedVgroup(SDnodeObj *pDnode, SVnodeLoad *pVloads, int32_t o
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
}
}
sdbFreeIter
(
pIter
);
mnodeCancelGetNextVgroup
(
pIter
);
}
}
void
mnodeUpdateVgroupStatus
(
SVgObj
*
pVgroup
,
SDnodeObj
*
pDnode
,
SVnodeLoad
*
pVload
)
{
void
mnodeUpdateVgroupStatus
(
SVgObj
*
pVgroup
,
SDnodeObj
*
pDnode
,
SVnodeLoad
*
pVload
)
{
...
@@ -491,6 +492,10 @@ void *mnodeGetNextVgroup(void *pIter, SVgObj **pVgroup) {
...
@@ -491,6 +492,10 @@ void *mnodeGetNextVgroup(void *pIter, SVgObj **pVgroup) {
return
sdbFetchRow
(
tsVgroupSdb
,
pIter
,
(
void
**
)
pVgroup
);
return
sdbFetchRow
(
tsVgroupSdb
,
pIter
,
(
void
**
)
pVgroup
);
}
}
void
mnodeCancelGetNextVgroup
(
void
*
pIter
)
{
sdbFreeIter
(
tsVgroupSdb
,
pIter
);
}
static
int32_t
mnodeCreateVgroupFp
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeCreateVgroupFp
(
SMnodeMsg
*
pMsg
)
{
SVgObj
*
pVgroup
=
pMsg
->
pVgroup
;
SVgObj
*
pVgroup
=
pMsg
->
pVgroup
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
...
@@ -1095,8 +1100,6 @@ void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode) {
...
@@ -1095,8 +1100,6 @@ void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode) {
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
}
}
sdbFreeIter
(
pIter
);
mInfo
(
"dnode:%d, all vgroups:%d is dropped from sdb"
,
pDropDnode
->
dnodeId
,
numOfVgroups
);
mInfo
(
"dnode:%d, all vgroups:%d is dropped from sdb"
,
pDropDnode
->
dnodeId
,
numOfVgroups
);
}
}
...
@@ -1118,8 +1121,6 @@ void mnodeUpdateAllDbVgroups(SDbObj *pAlterDb) {
...
@@ -1118,8 +1121,6 @@ void mnodeUpdateAllDbVgroups(SDbObj *pAlterDb) {
mnodeDecVgroupRef(pVgroup);
mnodeDecVgroupRef(pVgroup);
}
}
sdbFreeIter(pIter);
mInfo("db:%s, all vgroups is updated in sdb", pAlterDb->name);
mInfo("db:%s, all vgroups is updated in sdb", pAlterDb->name);
}
}
#endif
#endif
...
@@ -1147,8 +1148,6 @@ void mnodeDropAllDbVgroups(SDbObj *pDropDb) {
...
@@ -1147,8 +1148,6 @@ void mnodeDropAllDbVgroups(SDbObj *pDropDb) {
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
}
}
sdbFreeIter
(
pIter
);
mInfo
(
"db:%s, all vgroups:%d is dropped from sdb"
,
pDropDb
->
name
,
numOfVgroups
);
mInfo
(
"db:%s, all vgroups:%d is dropped from sdb"
,
pDropDb
->
name
,
numOfVgroups
);
}
}
...
@@ -1170,7 +1169,5 @@ void mnodeSendDropAllDbVgroupsMsg(SDbObj *pDropDb) {
...
@@ -1170,7 +1169,5 @@ void mnodeSendDropAllDbVgroupsMsg(SDbObj *pDropDb) {
numOfVgroups
++
;
numOfVgroups
++
;
}
}
sdbFreeIter
(
pIter
);
mInfo
(
"db:%s, all vgroups:%d drop msg is sent to dnode"
,
pDropDb
->
name
,
numOfVgroups
);
mInfo
(
"db:%s, all vgroups:%d drop msg is sent to dnode"
,
pDropDb
->
name
,
numOfVgroups
);
}
}
src/query/inc/qUtil.h
浏览文件 @
91bc2e9c
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
int32_t
getOutputInterResultBufSize
(
SQuery
*
pQuery
);
int32_t
getOutputInterResultBufSize
(
SQuery
*
pQuery
);
void
clearResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pRow
,
int16_t
type
);
void
clearResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pRow
,
int16_t
type
);
void
copyResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
dst
,
const
SResultRow
*
src
);
void
copyResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
dst
,
const
SResultRow
*
src
,
int16_t
type
);
SResultRowCellInfo
*
getResultCell
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
const
SResultRow
*
pRow
,
int32_t
index
);
SResultRowCellInfo
*
getResultCell
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
const
SResultRow
*
pRow
,
int32_t
index
);
int32_t
initWindowResInfo
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
size
,
int32_t
threshold
,
int16_t
type
);
int32_t
initWindowResInfo
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
size
,
int32_t
threshold
,
int16_t
type
);
...
...
src/query/src/qExecutor.c
浏览文件 @
91bc2e9c
...
@@ -5836,9 +5836,9 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
...
@@ -5836,9 +5836,9 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
pQueryMsg
->
interval
.
interval
=
htobe64
(
pQueryMsg
->
interval
.
interval
);
pQueryMsg
->
interval
.
interval
=
htobe64
(
pQueryMsg
->
interval
.
interval
);
pQueryMsg
->
interval
.
sliding
=
htobe64
(
pQueryMsg
->
interval
.
sliding
);
pQueryMsg
->
interval
.
sliding
=
htobe64
(
pQueryMsg
->
interval
.
sliding
);
pQueryMsg
->
interval
.
offset
=
htobe64
(
pQueryMsg
->
interval
.
offset
);
pQueryMsg
->
interval
.
offset
=
htobe64
(
pQueryMsg
->
interval
.
offset
);
pQueryMsg
->
interval
.
intervalUnit
=
pQueryMsg
->
interval
.
intervalUnit
;
//
pQueryMsg->interval.intervalUnit = pQueryMsg->interval.intervalUnit;
pQueryMsg
->
interval
.
slidingUnit
=
pQueryMsg
->
interval
.
slidingUnit
;
//
pQueryMsg->interval.slidingUnit = pQueryMsg->interval.slidingUnit;
pQueryMsg
->
interval
.
offsetUnit
=
pQueryMsg
->
interval
.
offsetUnit
;
//
pQueryMsg->interval.offsetUnit = pQueryMsg->interval.offsetUnit;
pQueryMsg
->
limit
=
htobe64
(
pQueryMsg
->
limit
);
pQueryMsg
->
limit
=
htobe64
(
pQueryMsg
->
limit
);
pQueryMsg
->
offset
=
htobe64
(
pQueryMsg
->
offset
);
pQueryMsg
->
offset
=
htobe64
(
pQueryMsg
->
offset
);
...
...
src/query/src/qResultbuf.c
浏览文件 @
91bc2e9c
...
@@ -423,9 +423,8 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf) {
...
@@ -423,9 +423,8 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf) {
unlink
(
pResultBuf
->
path
);
unlink
(
pResultBuf
->
path
);
tfree
(
pResultBuf
->
path
);
tfree
(
pResultBuf
->
path
);
SHashMutableIterator
*
iter
=
taosHashCreateIter
(
pResultBuf
->
groupSet
);
SArray
**
p
=
taosHashIterate
(
pResultBuf
->
groupSet
,
NULL
);
while
(
taosHashIterNext
(
iter
))
{
while
(
p
)
{
SArray
**
p
=
(
SArray
**
)
taosHashIterGet
(
iter
);
size_t
n
=
taosArrayGetSize
(
*
p
);
size_t
n
=
taosArrayGetSize
(
*
p
);
for
(
int32_t
i
=
0
;
i
<
n
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
n
;
++
i
)
{
SPageInfo
*
pi
=
taosArrayGetP
(
*
p
,
i
);
SPageInfo
*
pi
=
taosArrayGetP
(
*
p
,
i
);
...
@@ -434,10 +433,9 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf) {
...
@@ -434,10 +433,9 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf) {
}
}
taosArrayDestroy
(
*
p
);
taosArrayDestroy
(
*
p
);
p
=
taosHashIterate
(
pResultBuf
->
groupSet
,
p
);
}
}
taosHashDestroyIter
(
iter
);
tdListFree
(
pResultBuf
->
lruList
);
tdListFree
(
pResultBuf
->
lruList
);
taosArrayDestroy
(
pResultBuf
->
emptyDummyIdList
);
taosArrayDestroy
(
pResultBuf
->
emptyDummyIdList
);
taosHashCleanup
(
pResultBuf
->
groupSet
);
taosHashCleanup
(
pResultBuf
->
groupSet
);
...
...
src/query/src/qUtil.c
浏览文件 @
91bc2e9c
...
@@ -133,7 +133,7 @@ void clearFirstNWindowRes(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
...
@@ -133,7 +133,7 @@ void clearFirstNWindowRes(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
// clear all the closed windows from the window list
// clear all the closed windows from the window list
for
(
int32_t
k
=
0
;
k
<
remain
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
remain
;
++
k
)
{
copyResultRow
(
pRuntimeEnv
,
pWindowResInfo
->
pResult
[
k
],
pWindowResInfo
->
pResult
[
num
+
k
]);
copyResultRow
(
pRuntimeEnv
,
pWindowResInfo
->
pResult
[
k
],
pWindowResInfo
->
pResult
[
num
+
k
]
,
type
);
}
}
// move the unclosed window in the front of the window list
// move the unclosed window in the front of the window list
...
@@ -272,9 +272,15 @@ void clearResultRow(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pWindowRes, int16
...
@@ -272,9 +272,15 @@ void clearResultRow(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pWindowRes, int16
* since the attribute of "Pos" is bound to each window result when the window result is created in the
* since the attribute of "Pos" is bound to each window result when the window result is created in the
* disk-based result buffer.
* disk-based result buffer.
*/
*/
void
copyResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
dst
,
const
SResultRow
*
src
)
{
void
copyResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
dst
,
const
SResultRow
*
src
,
int16_t
type
)
{
dst
->
numOfRows
=
src
->
numOfRows
;
dst
->
numOfRows
=
src
->
numOfRows
;
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
dst
->
key
=
realloc
(
dst
->
key
,
varDataTLen
(
src
->
key
));
varDataCopy
(
dst
->
key
,
src
->
key
);
}
else
{
dst
->
win
=
src
->
win
;
dst
->
win
=
src
->
win
;
}
dst
->
closed
=
src
->
closed
;
dst
->
closed
=
src
->
closed
;
int32_t
nOutputCols
=
pRuntimeEnv
->
pQuery
->
numOfOutput
;
int32_t
nOutputCols
=
pRuntimeEnv
->
pQuery
->
numOfOutput
;
...
...
src/rpc/src/rpcTcp.c
浏览文件 @
91bc2e9c
...
@@ -371,10 +371,13 @@ void taosCloseTcpConnection(void *chandle) {
...
@@ -371,10 +371,13 @@ void taosCloseTcpConnection(void *chandle) {
int
taosSendTcpData
(
uint32_t
ip
,
uint16_t
port
,
void
*
data
,
int
len
,
void
*
chandle
)
{
int
taosSendTcpData
(
uint32_t
ip
,
uint16_t
port
,
void
*
data
,
int
len
,
void
*
chandle
)
{
SFdObj
*
pFdObj
=
chandle
;
SFdObj
*
pFdObj
=
chandle
;
if
(
pFdObj
==
NULL
||
pFdObj
->
signature
!=
pFdObj
)
return
-
1
;
if
(
pFdObj
==
NULL
||
pFdObj
->
signature
!=
pFdObj
)
return
-
1
;
SThreadObj
*
pThreadObj
=
pFdObj
->
pThreadObj
;
int
ret
=
taosWriteMsg
(
pFdObj
->
fd
,
data
,
len
);
tTrace
(
"%s %p TCP data is sent, FD:%p fd:%d bytes:%d"
,
pThreadObj
->
label
,
pFdObj
->
thandle
,
pFdObj
,
pFdObj
->
fd
,
ret
);
return
taosWriteMsg
(
pFdObj
->
fd
,
data
,
len
)
;
return
ret
;
}
}
static
void
taosReportBrokenLink
(
SFdObj
*
pFdObj
)
{
static
void
taosReportBrokenLink
(
SFdObj
*
pFdObj
)
{
...
@@ -409,7 +412,7 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) {
...
@@ -409,7 +412,7 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) {
headLen
=
taosReadMsg
(
pFdObj
->
fd
,
&
rpcHead
,
sizeof
(
SRpcHead
));
headLen
=
taosReadMsg
(
pFdObj
->
fd
,
&
rpcHead
,
sizeof
(
SRpcHead
));
if
(
headLen
!=
sizeof
(
SRpcHead
))
{
if
(
headLen
!=
sizeof
(
SRpcHead
))
{
tDebug
(
"%s %p read error,
headLen:%d"
,
pThreadObj
->
label
,
pFdObj
->
thandle
,
headLen
);
tDebug
(
"%s %p read error,
FD:%p headLen:%d"
,
pThreadObj
->
label
,
pFdObj
->
thandle
,
pFdObj
,
headLen
);
return
-
1
;
return
-
1
;
}
}
...
@@ -420,7 +423,7 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) {
...
@@ -420,7 +423,7 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) {
tError
(
"%s %p TCP malloc(size:%d) fail"
,
pThreadObj
->
label
,
pFdObj
->
thandle
,
msgLen
);
tError
(
"%s %p TCP malloc(size:%d) fail"
,
pThreadObj
->
label
,
pFdObj
->
thandle
,
msgLen
);
return
-
1
;
return
-
1
;
}
else
{
}
else
{
tTrace
(
"
TCP malloc mem:%p size:%d"
,
buffer
,
size
);
tTrace
(
"
%s %p read data, FD:%p fd:%d TCP malloc mem:%p"
,
pThreadObj
->
label
,
pFdObj
->
thandle
,
pFdObj
,
pFdObj
->
fd
,
buffer
);
}
}
msg
=
buffer
+
tsRpcOverhead
;
msg
=
buffer
+
tsRpcOverhead
;
...
@@ -583,8 +586,8 @@ static void taosFreeFdObj(SFdObj *pFdObj) {
...
@@ -583,8 +586,8 @@ static void taosFreeFdObj(SFdObj *pFdObj) {
pthread_mutex_unlock
(
&
pThreadObj
->
mutex
);
pthread_mutex_unlock
(
&
pThreadObj
->
mutex
);
tDebug
(
"%s %p TCP connection is closed, FD:%p numOfFds:%d"
,
tDebug
(
"%s %p TCP connection is closed, FD:%p
fd:%d
numOfFds:%d"
,
pThreadObj
->
label
,
pFdObj
->
thandle
,
pFdObj
,
pThreadObj
->
numOfFds
);
pThreadObj
->
label
,
pFdObj
->
thandle
,
pFdObj
,
p
FdObj
->
fd
,
p
ThreadObj
->
numOfFds
);
tfree
(
pFdObj
);
tfree
(
pFdObj
);
}
}
src/sync/inc/syncInt.h
浏览文件 @
91bc2e9c
...
@@ -139,6 +139,7 @@ typedef struct SsyncPeer {
...
@@ -139,6 +139,7 @@ typedef struct SsyncPeer {
char
id
[
TSDB_EP_LEN
+
32
];
// peer vgId + end point
char
id
[
TSDB_EP_LEN
+
32
];
// peer vgId + end point
uint64_t
version
;
uint64_t
version
;
uint64_t
sversion
;
// track the peer version in retrieve process
uint64_t
sversion
;
// track the peer version in retrieve process
uint64_t
lastVer
;
// track the file version while retrieve
int32_t
syncFd
;
int32_t
syncFd
;
int32_t
peerFd
;
// forward FD
int32_t
peerFd
;
// forward FD
int32_t
numOfRetrieves
;
// number of retrieves tried
int32_t
numOfRetrieves
;
// number of retrieves tried
...
@@ -172,6 +173,7 @@ typedef struct SSyncNode {
...
@@ -172,6 +173,7 @@ typedef struct SSyncNode {
FNotifyRole
notifyRole
;
FNotifyRole
notifyRole
;
FNotifyFlowCtrl
notifyFlowCtrl
;
FNotifyFlowCtrl
notifyFlowCtrl
;
FNotifyFileSynced
notifyFileSynced
;
FNotifyFileSynced
notifyFileSynced
;
FGetFileVersion
getFileVersion
;
pthread_mutex_t
mutex
;
pthread_mutex_t
mutex
;
}
SSyncNode
;
}
SSyncNode
;
...
...
src/sync/src/syncMain.c
浏览文件 @
91bc2e9c
...
@@ -196,6 +196,7 @@ int64_t syncStart(const SSyncInfo *pInfo) {
...
@@ -196,6 +196,7 @@ int64_t syncStart(const SSyncInfo *pInfo) {
pNode
->
confirmForward
=
pInfo
->
confirmForward
;
pNode
->
confirmForward
=
pInfo
->
confirmForward
;
pNode
->
notifyFlowCtrl
=
pInfo
->
notifyFlowCtrl
;
pNode
->
notifyFlowCtrl
=
pInfo
->
notifyFlowCtrl
;
pNode
->
notifyFileSynced
=
pInfo
->
notifyFileSynced
;
pNode
->
notifyFileSynced
=
pInfo
->
notifyFileSynced
;
pNode
->
getFileVersion
=
pInfo
->
getFileVersion
;
pNode
->
selfIndex
=
-
1
;
pNode
->
selfIndex
=
-
1
;
pNode
->
vgId
=
pInfo
->
vgId
;
pNode
->
vgId
=
pInfo
->
vgId
;
...
@@ -540,7 +541,7 @@ static SSyncPeer *syncAddPeer(SSyncNode *pNode, const SNodeInfo *pInfo) {
...
@@ -540,7 +541,7 @@ static SSyncPeer *syncAddPeer(SSyncNode *pNode, const SNodeInfo *pInfo) {
pPeer
->
ip
=
ip
;
pPeer
->
ip
=
ip
;
pPeer
->
port
=
pInfo
->
nodePort
;
pPeer
->
port
=
pInfo
->
nodePort
;
pPeer
->
fqdn
[
sizeof
(
pPeer
->
fqdn
)
-
1
]
=
0
;
pPeer
->
fqdn
[
sizeof
(
pPeer
->
fqdn
)
-
1
]
=
0
;
snprintf
(
pPeer
->
id
,
sizeof
(
pPeer
->
id
),
"vgId:%d,
peer:%s:%u"
,
pNode
->
vgId
,
pPeer
->
fqdn
,
pPeer
->
port
);
snprintf
(
pPeer
->
id
,
sizeof
(
pPeer
->
id
),
"vgId:%d,
nodeId:%d"
,
pNode
->
vgId
,
pPeer
->
nodeId
);
pPeer
->
peerFd
=
-
1
;
pPeer
->
peerFd
=
-
1
;
pPeer
->
syncFd
=
-
1
;
pPeer
->
syncFd
=
-
1
;
...
@@ -1143,8 +1144,7 @@ static void syncProcessIncommingConnection(int32_t connFd, uint32_t sourceIp) {
...
@@ -1143,8 +1144,7 @@ static void syncProcessIncommingConnection(int32_t connFd, uint32_t sourceIp) {
pPeer
->
syncFd
=
connFd
;
pPeer
->
syncFd
=
connFd
;
syncCreateRestoreDataThread
(
pPeer
);
syncCreateRestoreDataThread
(
pPeer
);
}
else
{
}
else
{
sDebug
(
"%s, TCP connection is already up(pfd:%d), close one, new pfd:%d sfd:%d"
,
pPeer
->
id
,
pPeer
->
peerFd
,
connFd
,
sDebug
(
"%s, TCP connection is up, pfd:%d sfd:%d, old pfd:%d"
,
pPeer
->
id
,
connFd
,
pPeer
->
syncFd
,
pPeer
->
peerFd
);
pPeer
->
syncFd
);
syncClosePeerConn
(
pPeer
);
syncClosePeerConn
(
pPeer
);
pPeer
->
peerFd
=
connFd
;
pPeer
->
peerFd
=
connFd
;
pPeer
->
pConn
=
taosAllocateTcpConn
(
tsTcpPool
,
pPeer
,
connFd
);
pPeer
->
pConn
=
taosAllocateTcpConn
(
tsTcpPool
,
pPeer
,
connFd
);
...
...
src/sync/src/syncRestore.c
浏览文件 @
91bc2e9c
...
@@ -52,9 +52,9 @@ static void syncRemoveExtraFile(SSyncPeer *pPeer, int32_t sindex, int32_t eindex
...
@@ -52,9 +52,9 @@ static void syncRemoveExtraFile(SSyncPeer *pPeer, int32_t sindex, int32_t eindex
static
int32_t
syncRestoreFile
(
SSyncPeer
*
pPeer
,
uint64_t
*
fversion
)
{
static
int32_t
syncRestoreFile
(
SSyncPeer
*
pPeer
,
uint64_t
*
fversion
)
{
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
SFileInfo
minfo
;
memset
(
&
minfo
,
0
,
sizeof
(
minfo
));
/* = {0}; */
// master file info
SFileInfo
minfo
;
memset
(
&
minfo
,
0
,
sizeof
(
SFileInfo
));
/* = {0}; */
SFileInfo
sinfo
;
memset
(
&
sinfo
,
0
,
sizeof
(
sinfo
));
/* = {0}; */
// slave file info
SFileInfo
sinfo
;
memset
(
&
sinfo
,
0
,
sizeof
(
SFileInfo
));
/* = {0}; */
SFileAck
fileAck
;
SFileAck
fileAck
=
{
0
};
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
char
name
[
TSDB_FILENAME_LEN
*
2
]
=
{
0
};
char
name
[
TSDB_FILENAME_LEN
*
2
]
=
{
0
};
uint32_t
pindex
=
0
;
// index in last restore
uint32_t
pindex
=
0
;
// index in last restore
...
@@ -134,7 +134,7 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
...
@@ -134,7 +134,7 @@ static int32_t syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
// data file is changed, code shall be set to 1
// data file is changed, code shall be set to 1
*
fversion
=
minfo
.
fversion
;
*
fversion
=
minfo
.
fversion
;
code
=
1
;
code
=
1
;
sDebug
(
"%s, file changed
while restore file"
,
pPeer
->
id
);
sDebug
(
"%s, file changed
after restore file, fver:%"
PRIu64
,
pPeer
->
id
,
*
fversion
);
}
}
if
(
code
<
0
)
{
if
(
code
<
0
)
{
...
@@ -160,7 +160,7 @@ static int32_t syncRestoreWal(SSyncPeer *pPeer) {
...
@@ -160,7 +160,7 @@ static int32_t syncRestoreWal(SSyncPeer *pPeer) {
}
}
if
(
pHead
->
len
==
0
)
{
if
(
pHead
->
len
==
0
)
{
sDebug
(
"%s, wal is synced over
"
,
pPeer
->
id
);
sDebug
(
"%s, wal is synced over
, last wver:%"
PRIu64
,
pPeer
->
id
,
lastVer
);
code
=
0
;
code
=
0
;
break
;
break
;
}
// wal sync over
}
// wal sync over
...
...
src/sync/src/syncRetrieve.c
浏览文件 @
91bc2e9c
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include <sys/inotify.h>
#include <sys/inotify.h>
#include "os.h"
#include "os.h"
#include "taoserror.h"
#include "tlog.h"
#include "tlog.h"
#include "tutil.h"
#include "tutil.h"
#include "tglobal.h"
#include "tglobal.h"
...
@@ -25,85 +26,35 @@
...
@@ -25,85 +26,35 @@
#include "tsync.h"
#include "tsync.h"
#include "syncInt.h"
#include "syncInt.h"
static
int32_t
syncA
ddIntoWatchList
(
SSyncPeer
*
pPeer
,
char
*
name
)
{
static
int32_t
syncA
reFilesModified
(
SSyncNode
*
pNode
,
SSyncPeer
*
pPeer
)
{
sDebug
(
"%s, start to monitor:%s"
,
pPeer
->
id
,
name
)
;
if
(
pNode
->
getFileVersion
==
NULL
)
return
TSDB_CODE_SUCCESS
;
if
(
pPeer
->
notifyFd
<=
0
)
{
uint64_t
fver
=
0
;
pPeer
->
watchNum
=
0
;
int32_t
code
=
(
*
pNode
->
getFileVersion
)(
pNode
->
vgId
,
&
fver
);
pPeer
->
notifyFd
=
inotify_init1
(
IN_NONBLOCK
);
if
(
code
!=
0
)
{
if
(
pPeer
->
notifyFd
<
0
)
{
sInfo
(
"%s, vnode is commiting while retrieve, last fver:%"
PRIu64
,
pPeer
->
id
,
pPeer
->
lastVer
);
sError
(
"%s, failed to init inotify since %s"
,
pPeer
->
id
,
strerror
(
errno
));
pPeer
->
fileChanged
=
1
;
return
-
1
;
return
TSDB_CODE_SYN_VND_COMMITING
;
}
if
(
pPeer
->
watchFd
==
NULL
)
pPeer
->
watchFd
=
malloc
(
sizeof
(
int32_t
)
*
tsMaxWatchFiles
);
if
(
pPeer
->
watchFd
==
NULL
)
{
sError
(
"%s, failed to allocate watchFd"
,
pPeer
->
id
);
return
-
1
;
}
memset
(
pPeer
->
watchFd
,
-
1
,
sizeof
(
int32_t
)
*
tsMaxWatchFiles
);
}
int32_t
*
wd
=
pPeer
->
watchFd
+
pPeer
->
watchNum
;
if
(
*
wd
>=
0
)
{
if
(
inotify_rm_watch
(
pPeer
->
notifyFd
,
*
wd
)
<
0
)
{
sError
(
"%s, failed to remove wd:%d since %s"
,
pPeer
->
id
,
*
wd
,
strerror
(
errno
));
return
-
1
;
}
}
*
wd
=
inotify_add_watch
(
pPeer
->
notifyFd
,
name
,
IN_MODIFY
|
IN_DELETE
);
if
(
*
wd
==
-
1
)
{
sError
(
"%s, failed to add %s since %s"
,
pPeer
->
id
,
name
,
strerror
(
errno
));
return
-
1
;
}
else
{
sDebug
(
"%s, monitor %s, wd:%d watchNum:%d"
,
pPeer
->
id
,
name
,
*
wd
,
pPeer
->
watchNum
);
}
pPeer
->
watchNum
=
(
pPeer
->
watchNum
+
1
)
%
tsMaxWatchFiles
;
return
0
;
}
static
int32_t
syncAreFilesModified
(
SSyncPeer
*
pPeer
)
{
if
(
pPeer
->
notifyFd
<=
0
)
return
0
;
char
buf
[
2048
];
int32_t
len
=
read
(
pPeer
->
notifyFd
,
buf
,
sizeof
(
buf
));
if
(
len
<
0
&&
errno
!=
EAGAIN
)
{
sError
(
"%s, failed to read notify FD since %s"
,
pPeer
->
id
,
strerror
(
errno
));
return
-
1
;
}
}
int32_t
code
=
0
;
if
(
fver
!=
pPeer
->
lastVer
)
{
if
(
len
>
0
)
{
sInfo
(
"%s, files are modified while retrieve, fver:%"
PRIu64
", last fver:%"
PRIu64
,
pPeer
->
id
,
fver
,
pPeer
->
lastVer
);
const
struct
inotify_event
*
event
;
char
*
ptr
;
for
(
ptr
=
buf
;
ptr
<
buf
+
len
;
ptr
+=
sizeof
(
struct
inotify_event
)
+
event
->
len
)
{
event
=
(
const
struct
inotify_event
*
)
ptr
;
if
((
event
->
mask
&
IN_MODIFY
)
||
(
event
->
mask
&
IN_DELETE
))
{
sDebug
(
"%s, processed file is changed"
,
pPeer
->
id
);
pPeer
->
fileChanged
=
1
;
pPeer
->
fileChanged
=
1
;
code
=
1
;
return
TSDB_CODE_SYN_FILE_CHNAGED
;
break
;
}
}
}
}
return
code
;
pPeer
->
fileChanged
=
0
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
syncRetrieveFile
(
SSyncPeer
*
pPeer
)
{
static
int32_t
syncRetrieveFile
(
SSyncPeer
*
pPeer
)
{
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
SFileInfo
fileInfo
;
SFileInfo
fileInfo
;
memset
(
&
fileInfo
,
0
,
sizeof
(
SFileInfo
));
SFileAck
fileAck
;
SFileAck
fileAck
=
{
0
}
;
int32_t
code
=
-
1
;
int32_t
code
=
TSDB_CODE_SYN_APP_ERROR
;
char
name
[
TSDB_FILENAME_LEN
*
2
]
=
{
0
};
char
name
[
TSDB_FILENAME_LEN
*
2
]
=
{
0
};
memset
(
&
fileInfo
,
0
,
sizeof
(
fileInfo
));
if
(
pNode
->
getFileVersion
)
(
*
pNode
->
getFileVersion
)(
pNode
->
vgId
,
&
pPeer
->
lastVer
);
memset
(
&
fileAck
,
0
,
sizeof
(
fileAck
));
while
(
1
)
{
while
(
1
)
{
// retrieve file info
// retrieve file info
...
@@ -111,24 +62,27 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
...
@@ -111,24 +62,27 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
fileInfo
.
magic
=
(
*
pNode
->
getFileInfo
)(
pNode
->
vgId
,
fileInfo
.
name
,
&
fileInfo
.
index
,
TAOS_SYNC_MAX_INDEX
,
fileInfo
.
magic
=
(
*
pNode
->
getFileInfo
)(
pNode
->
vgId
,
fileInfo
.
name
,
&
fileInfo
.
index
,
TAOS_SYNC_MAX_INDEX
,
&
fileInfo
.
size
,
&
fileInfo
.
fversion
);
&
fileInfo
.
size
,
&
fileInfo
.
fversion
);
// fileInfo.size = htonl(size);
// fileInfo.size = htonl(size);
sDebug
(
"%s, file:%s info is sent, size:%"
PRId64
,
pPeer
->
id
,
fileInfo
.
name
,
fileInfo
.
size
);
// send the file info
// send the file info
int32_t
ret
=
taosWriteMsg
(
pPeer
->
syncFd
,
&
(
fileInfo
),
sizeof
(
fileInfo
));
int32_t
ret
=
taosWriteMsg
(
pPeer
->
syncFd
,
&
(
fileInfo
),
sizeof
(
fileInfo
));
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
sError
(
"%s, failed to write file:%s info while retrieve file since %s"
,
pPeer
->
id
,
fileInfo
.
name
,
strerror
(
errno
));
sError
(
"%s, failed to write file:%s info while retrieve file since %s"
,
pPeer
->
id
,
fileInfo
.
name
,
strerror
(
errno
));
break
;
break
;
}
}
// if no file anymore, break
// if no file anymore, break
if
(
fileInfo
.
magic
==
0
||
fileInfo
.
name
[
0
]
==
0
)
{
if
(
fileInfo
.
magic
==
0
||
fileInfo
.
name
[
0
]
==
0
)
{
code
=
TSDB_CODE_SUCCESS
;
sDebug
(
"%s, no more files to sync"
,
pPeer
->
id
);
sDebug
(
"%s, no more files to sync"
,
pPeer
->
id
);
code
=
0
;
break
;
break
;
}
}
// wait for the ack from peer
// wait for the ack from peer
ret
=
taosReadMsg
(
pPeer
->
syncFd
,
&
fileAck
,
sizeof
(
fileAck
));
ret
=
taosReadMsg
(
pPeer
->
syncFd
,
&
fileAck
,
sizeof
(
fileAck
));
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
sError
(
"%s, failed to read file:%s ack while retrieve file since %s"
,
pPeer
->
id
,
fileInfo
.
name
,
strerror
(
errno
));
sError
(
"%s, failed to read file:%s ack while retrieve file since %s"
,
pPeer
->
id
,
fileInfo
.
name
,
strerror
(
errno
));
break
;
break
;
}
}
...
@@ -136,15 +90,6 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
...
@@ -136,15 +90,6 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
// set the peer sync version
// set the peer sync version
pPeer
->
sversion
=
fileInfo
.
fversion
;
pPeer
->
sversion
=
fileInfo
.
fversion
;
// get the full path to file
snprintf
(
name
,
sizeof
(
name
),
"%s/%s"
,
pNode
->
path
,
fileInfo
.
name
);
// add the file into watch list
if
(
syncAddIntoWatchList
(
pPeer
,
name
)
<
0
)
{
sError
(
"%s, failed to watch file:%s while retrieve file since %s"
,
pPeer
->
id
,
fileInfo
.
name
,
strerror
(
errno
));
break
;
}
// if sync is not required, continue
// if sync is not required, continue
if
(
fileAck
.
sync
==
0
)
{
if
(
fileAck
.
sync
==
0
)
{
fileInfo
.
index
++
;
fileInfo
.
index
++
;
...
@@ -152,9 +97,13 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
...
@@ -152,9 +97,13 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
continue
;
continue
;
}
}
// get the full path to file
snprintf
(
name
,
sizeof
(
name
),
"%s/%s"
,
pNode
->
path
,
fileInfo
.
name
);
// send the file to peer
// send the file to peer
int32_t
sfd
=
open
(
name
,
O_RDONLY
);
int32_t
sfd
=
open
(
name
,
O_RDONLY
);
if
(
sfd
<
0
)
{
if
(
sfd
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
sError
(
"%s, failed to open file:%s while retrieve file since %s"
,
pPeer
->
id
,
fileInfo
.
name
,
strerror
(
errno
));
sError
(
"%s, failed to open file:%s while retrieve file since %s"
,
pPeer
->
id
,
fileInfo
.
name
,
strerror
(
errno
));
break
;
break
;
}
}
...
@@ -162,22 +111,21 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
...
@@ -162,22 +111,21 @@ static int32_t syncRetrieveFile(SSyncPeer *pPeer) {
ret
=
taosSendFile
(
pPeer
->
syncFd
,
sfd
,
NULL
,
fileInfo
.
size
);
ret
=
taosSendFile
(
pPeer
->
syncFd
,
sfd
,
NULL
,
fileInfo
.
size
);
close
(
sfd
);
close
(
sfd
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
sError
(
"%s, failed to send file:%s while retrieve file since %s"
,
pPeer
->
id
,
fileInfo
.
name
,
strerror
(
errno
));
sError
(
"%s, failed to send file:%s while retrieve file since %s"
,
pPeer
->
id
,
fileInfo
.
name
,
strerror
(
errno
));
break
;
break
;
}
}
sDebug
(
"%s,
%s is sent, size:%"
PRId64
,
pPeer
->
id
,
name
,
fileInfo
.
size
);
sDebug
(
"%s,
file:%s is sent, size:%"
PRId64
,
pPeer
->
id
,
fileInfo
.
name
,
fileInfo
.
size
);
fileInfo
.
index
++
;
fileInfo
.
index
++
;
// check if processed files are modified
// check if processed files are modified
if
(
syncAreFilesModified
(
pPeer
)
!=
0
)
{
code
=
syncAreFilesModified
(
pNode
,
pPeer
);
sInfo
(
"%s, file:%s are modified while retrieve file since %s"
,
pPeer
->
id
,
fileInfo
.
name
,
strerror
(
errno
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
break
;
break
;
}
}
}
if
(
code
<
0
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
sError
(
"%s, failed to retrieve file
"
,
pPeer
->
id
);
sError
(
"%s, failed to retrieve file
since %s"
,
pPeer
->
id
,
tstrerror
(
code
)
);
}
}
return
code
;
return
code
;
...
@@ -308,9 +256,9 @@ static int32_t syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversi
...
@@ -308,9 +256,9 @@ static int32_t syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversi
static
int32_t
syncProcessLastWal
(
SSyncPeer
*
pPeer
,
char
*
wname
,
int64_t
index
)
{
static
int32_t
syncProcessLastWal
(
SSyncPeer
*
pPeer
,
char
*
wname
,
int64_t
index
)
{
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
SSyncNode
*
pNode
=
pPeer
->
pSyncNode
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
char
fname
[
TSDB_FILENAME_LEN
*
2
];
// full path to wal file
char
fname
[
TSDB_FILENAME_LEN
*
2
]
=
{
0
}
;
// full path to wal file
if
(
syncAreFilesModified
(
pPeer
)
!=
0
)
return
-
1
;
if
(
syncAreFilesModified
(
p
Node
,
p
Peer
)
!=
0
)
return
-
1
;
while
(
1
)
{
while
(
1
)
{
int32_t
once
=
0
;
// last WAL has once ever been processed
int32_t
once
=
0
;
// last WAL has once ever been processed
...
@@ -429,9 +377,7 @@ static int32_t syncRetrieveWal(SSyncPeer *pPeer) {
...
@@ -429,9 +377,7 @@ static int32_t syncRetrieveWal(SSyncPeer *pPeer) {
close
(
sfd
);
close
(
sfd
);
if
(
code
<
0
)
break
;
if
(
code
<
0
)
break
;
index
++
;
if
(
syncAreFilesModified
(
pNode
,
pPeer
)
!=
0
)
break
;
if
(
syncAreFilesModified
(
pPeer
)
!=
0
)
break
;
}
}
if
(
code
==
0
)
{
if
(
code
==
0
)
{
...
@@ -481,18 +427,18 @@ static int32_t syncRetrieveDataStepByStep(SSyncPeer *pPeer) {
...
@@ -481,18 +427,18 @@ static int32_t syncRetrieveDataStepByStep(SSyncPeer *pPeer) {
pPeer
->
sversion
=
0
;
pPeer
->
sversion
=
0
;
pPeer
->
sstatus
=
TAOS_SYNC_STATUS_FILE
;
pPeer
->
sstatus
=
TAOS_SYNC_STATUS_FILE
;
sInfo
(
"%s, start to retrieve file, set sstatus:%s"
,
pPeer
->
id
,
syncStatus
[
pPeer
->
sstatus
]);
sInfo
(
"%s, start to retrieve file
s
, set sstatus:%s"
,
pPeer
->
id
,
syncStatus
[
pPeer
->
sstatus
]);
if
(
syncRetrieveFile
(
pPeer
)
<
0
)
{
if
(
syncRetrieveFile
(
pPeer
)
<
0
)
{
sError
(
"%s, failed to retrieve file"
,
pPeer
->
id
);
sError
(
"%s, failed to retrieve file
s
"
,
pPeer
->
id
);
return
-
1
;
return
-
1
;
}
}
// if no files are synced, there must be wal to sync, sversion must be larger than one
// if no files are synced, there must be wal to sync, sversion must be larger than one
if
(
pPeer
->
sversion
==
0
)
pPeer
->
sversion
=
1
;
if
(
pPeer
->
sversion
==
0
)
pPeer
->
sversion
=
1
;
sInfo
(
"%s, start to retrieve wal"
,
pPeer
->
id
);
sInfo
(
"%s, start to retrieve wal
s
"
,
pPeer
->
id
);
if
(
syncRetrieveWal
(
pPeer
)
<
0
)
{
if
(
syncRetrieveWal
(
pPeer
)
<
0
)
{
sError
(
"%s, failed to retrieve wal"
,
pPeer
->
id
);
sError
(
"%s, failed to retrieve wal
s
"
,
pPeer
->
id
);
return
-
1
;
return
-
1
;
}
}
...
@@ -506,7 +452,6 @@ void *syncRetrieveData(void *param) {
...
@@ -506,7 +452,6 @@ void *syncRetrieveData(void *param) {
if
(
pNode
->
notifyFlowCtrl
)
(
*
pNode
->
notifyFlowCtrl
)(
pNode
->
vgId
,
pPeer
->
numOfRetrieves
);
if
(
pNode
->
notifyFlowCtrl
)
(
*
pNode
->
notifyFlowCtrl
)(
pNode
->
vgId
,
pPeer
->
numOfRetrieves
);
pPeer
->
fileChanged
=
0
;
pPeer
->
syncFd
=
taosOpenTcpClientSocket
(
pPeer
->
ip
,
pPeer
->
port
,
0
);
pPeer
->
syncFd
=
taosOpenTcpClientSocket
(
pPeer
->
ip
,
pPeer
->
port
,
0
);
if
(
pPeer
->
syncFd
<
0
)
{
if
(
pPeer
->
syncFd
<
0
)
{
sError
(
"%s, failed to open socket to sync"
,
pPeer
->
id
);
sError
(
"%s, failed to open socket to sync"
,
pPeer
->
id
);
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
91bc2e9c
...
@@ -874,10 +874,10 @@ static void tsdbFreeRows(STsdbRepo *pRepo, void **rows, int rowCounter) {
...
@@ -874,10 +874,10 @@ static void tsdbFreeRows(STsdbRepo *pRepo, void **rows, int rowCounter) {
listNEles
(
pRepo
->
mem
->
bufBlockList
),
pBufBlock
->
offset
,
pBufBlock
->
remain
);
listNEles
(
pRepo
->
mem
->
bufBlockList
),
pBufBlock
->
offset
,
pBufBlock
->
remain
);
if
(
pBufBlock
->
offset
==
0
)
{
// return the block to buffer pool
if
(
pBufBlock
->
offset
==
0
)
{
// return the block to buffer pool
tsdbLockRepo
(
pRepo
)
;
if
(
tsdbLockRepo
(
pRepo
)
<
0
)
return
;
SListNode
*
pNode
=
tdListPopTail
(
pRepo
->
mem
->
bufBlockList
);
SListNode
*
pNode
=
tdListPopTail
(
pRepo
->
mem
->
bufBlockList
);
tdListPrependNode
(
pBufPool
->
bufBlockList
,
pNode
);
tdListPrependNode
(
pBufPool
->
bufBlockList
,
pNode
);
tsdbUnlockRepo
(
pRepo
)
;
if
(
tsdbUnlockRepo
(
pRepo
)
<
0
)
return
;
}
}
}
else
{
}
else
{
ASSERT
(
listNEles
(
pRepo
->
mem
->
extraBuffList
)
>
0
);
ASSERT
(
listNEles
(
pRepo
->
mem
->
extraBuffList
)
>
0
);
...
...
src/util/inc/hash.h
浏览文件 @
91bc2e9c
...
@@ -31,16 +31,18 @@ extern "C" {
...
@@ -31,16 +31,18 @@ extern "C" {
typedef
void
(
*
_hash_free_fn_t
)(
void
*
param
);
typedef
void
(
*
_hash_free_fn_t
)(
void
*
param
);
typedef
struct
SHashNode
{
typedef
struct
SHashNode
{
// char *key;
struct
SHashNode
*
next
;
struct
SHashNode
*
next
;
uint32_t
hashVal
;
// the hash value of key
uint32_t
hashVal
;
// the hash value of key
uint32_t
keyLen
;
// length of the key
uint32_t
keyLen
;
// length of the key
// char *data;
size_t
dataLen
;
// length of data
int8_t
count
;
// reference count
int8_t
removed
;
// flag to indicate removed
char
data
[];
}
SHashNode
;
}
SHashNode
;
#define GET_HASH_NODE_KEY(_n) ((char*)(_n) + sizeof(SHashNode))
#define GET_HASH_NODE_KEY(_n) ((char*)(_n) + sizeof(SHashNode)
+ (_n)->dataLen
)
#define GET_HASH_NODE_DATA(_n) ((char*)(_n) + sizeof(SHashNode)
+ (_n)->keyLen
)
#define GET_HASH_NODE_DATA(_n) ((char*)(_n) + sizeof(SHashNode))
#define GET_HASH_PNODE(_n) ((char*)(_n) - sizeof(SHashNode));
typedef
enum
SHashLockTypeE
{
typedef
enum
SHashLockTypeE
{
HASH_NO_LOCK
=
0
,
HASH_NO_LOCK
=
0
,
HASH_ENTRY_LOCK
=
1
,
HASH_ENTRY_LOCK
=
1
,
...
@@ -65,15 +67,6 @@ typedef struct SHashObj {
...
@@ -65,15 +67,6 @@ typedef struct SHashObj {
SArray
*
pMemBlock
;
// memory block allocated for SHashEntry
SArray
*
pMemBlock
;
// memory block allocated for SHashEntry
}
SHashObj
;
}
SHashObj
;
typedef
struct
SHashMutableIterator
{
SHashObj
*
pHashObj
;
int32_t
entryIndex
;
SHashNode
*
pCur
;
SHashNode
*
pNext
;
// current node can be deleted for mutable iterator, so keep the next one before return current
size_t
numOfChecked
;
// already check number of elements in hash table
size_t
numOfEntries
;
// number of entries while the iterator is created
}
SHashMutableIterator
;
/**
/**
* init the hash table
* init the hash table
*
*
...
@@ -142,33 +135,9 @@ int32_t taosHashCondTraverse(SHashObj *pHashObj, bool (*fp)(void *, void *), voi
...
@@ -142,33 +135,9 @@ int32_t taosHashCondTraverse(SHashObj *pHashObj, bool (*fp)(void *, void *), voi
*/
*/
void
taosHashCleanup
(
SHashObj
*
pHashObj
);
void
taosHashCleanup
(
SHashObj
*
pHashObj
);
/**
/*
*
void *SHashMutableIterator* taosHashCreateIter(SHashObj *pHashObj, void *);
* @param pHashObj
*/
* @return
*/
SHashMutableIterator
*
taosHashCreateIter
(
SHashObj
*
pHashObj
);
/**
*
* @param iter
* @return
*/
bool
taosHashIterNext
(
SHashMutableIterator
*
iter
);
/**
*
* @param iter
* @return
*/
void
*
taosHashIterGet
(
SHashMutableIterator
*
iter
);
/**
*
* @param iter
* @return
*/
void
*
taosHashDestroyIter
(
SHashMutableIterator
*
iter
);
/**
/**
*
*
...
@@ -179,6 +148,9 @@ int32_t taosHashGetMaxOverflowLinkLength(const SHashObj *pHashObj);
...
@@ -179,6 +148,9 @@ int32_t taosHashGetMaxOverflowLinkLength(const SHashObj *pHashObj);
size_t
taosHashGetMemSize
(
const
SHashObj
*
pHashObj
);
size_t
taosHashGetMemSize
(
const
SHashObj
*
pHashObj
);
void
*
taosHashIterate
(
SHashObj
*
pHashObj
,
void
*
p
);
void
taosHashCancelIterate
(
SHashObj
*
pHashObj
,
void
*
p
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/util/src/hash.c
浏览文件 @
91bc2e9c
...
@@ -76,7 +76,7 @@ static FORCE_INLINE int32_t taosHashCapacity(int32_t length) {
...
@@ -76,7 +76,7 @@ static FORCE_INLINE int32_t taosHashCapacity(int32_t length) {
static
FORCE_INLINE
SHashNode
*
doSearchInEntryList
(
SHashEntry
*
pe
,
const
void
*
key
,
size_t
keyLen
,
uint32_t
hashVal
)
{
static
FORCE_INLINE
SHashNode
*
doSearchInEntryList
(
SHashEntry
*
pe
,
const
void
*
key
,
size_t
keyLen
,
uint32_t
hashVal
)
{
SHashNode
*
pNode
=
pe
->
next
;
SHashNode
*
pNode
=
pe
->
next
;
while
(
pNode
)
{
while
(
pNode
)
{
if
((
pNode
->
keyLen
==
keyLen
)
&&
(
memcmp
(
GET_HASH_NODE_KEY
(
pNode
),
key
,
keyLen
)
==
0
))
{
if
((
pNode
->
keyLen
==
keyLen
)
&&
(
memcmp
(
GET_HASH_NODE_KEY
(
pNode
),
key
,
keyLen
)
==
0
)
&&
pNode
->
removed
==
0
)
{
assert
(
pNode
->
hashVal
==
hashVal
);
assert
(
pNode
->
hashVal
==
hashVal
);
break
;
break
;
}
}
...
@@ -114,15 +114,25 @@ static SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *p
...
@@ -114,15 +114,25 @@ static SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *p
* @param dsize size of actual data
* @param dsize size of actual data
* @return hash node
* @return hash node
*/
*/
static
FORCE_INLINE
SHashNode
*
doUpdateHashNode
(
SHashEntry
*
pe
,
SHashNode
*
prev
,
SHashNode
*
pNode
,
SHashNode
*
pNewNode
)
{
static
FORCE_INLINE
SHashNode
*
doUpdateHashNode
(
SHash
Obj
*
pHashObj
,
SHash
Entry
*
pe
,
SHashNode
*
prev
,
SHashNode
*
pNode
,
SHashNode
*
pNewNode
)
{
assert
(
pNode
->
keyLen
==
pNewNode
->
keyLen
);
assert
(
pNode
->
keyLen
==
pNewNode
->
keyLen
);
pNode
->
count
--
;
if
(
prev
!=
NULL
)
{
if
(
prev
!=
NULL
)
{
prev
->
next
=
pNewNode
;
prev
->
next
=
pNewNode
;
}
else
{
}
else
{
pe
->
next
=
pNewNode
;
pe
->
next
=
pNewNode
;
}
}
if
(
pNode
->
count
<=
0
)
{
pNewNode
->
next
=
pNode
->
next
;
pNewNode
->
next
=
pNode
->
next
;
DO_FREE_HASH_NODE
(
pNode
);
}
else
{
pNewNode
->
next
=
pNode
;
pe
->
num
++
;
atomic_add_fetch_64
(
&
pHashObj
->
size
,
1
);
}
return
pNewNode
;
return
pNewNode
;
}
}
...
@@ -139,7 +149,6 @@ static void pushfrontNodeInEntryList(SHashEntry *pEntry, SHashNode *pNode);
...
@@ -139,7 +149,6 @@ static void pushfrontNodeInEntryList(SHashEntry *pEntry, SHashNode *pNode);
* @param pIter
* @param pIter
* @return
* @return
*/
*/
static
SHashNode
*
getNextHashNode
(
SHashMutableIterator
*
pIter
);
SHashObj
*
taosHashInit
(
size_t
capacity
,
_hash_fn_t
fn
,
bool
update
,
SHashLockTypeE
type
)
{
SHashObj
*
taosHashInit
(
size_t
capacity
,
_hash_fn_t
fn
,
bool
update
,
SHashLockTypeE
type
)
{
if
(
capacity
==
0
||
fn
==
NULL
)
{
if
(
capacity
==
0
||
fn
==
NULL
)
{
...
@@ -213,7 +222,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
...
@@ -213,7 +222,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
SHashNode
*
prev
=
NULL
;
SHashNode
*
prev
=
NULL
;
while
(
pNode
)
{
while
(
pNode
)
{
if
((
pNode
->
keyLen
==
keyLen
)
&&
(
memcmp
(
GET_HASH_NODE_KEY
(
pNode
),
key
,
keyLen
)
==
0
))
{
if
((
pNode
->
keyLen
==
keyLen
)
&&
(
memcmp
(
GET_HASH_NODE_KEY
(
pNode
),
key
,
keyLen
)
==
0
)
&&
pNode
->
removed
==
0
)
{
assert
(
pNode
->
hashVal
==
hashVal
);
assert
(
pNode
->
hashVal
==
hashVal
);
break
;
break
;
}
}
...
@@ -244,8 +253,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
...
@@ -244,8 +253,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
}
else
{
}
else
{
// not support the update operation, return error
// not support the update operation, return error
if
(
pHashObj
->
enableUpdate
)
{
if
(
pHashObj
->
enableUpdate
)
{
doUpdateHashNode
(
pe
,
prev
,
pNode
,
pNewNode
);
doUpdateHashNode
(
pHashObj
,
pe
,
prev
,
pNode
,
pNewNode
);
DO_FREE_HASH_NODE
(
pNode
);
}
else
{
}
else
{
DO_FREE_HASH_NODE
(
pNewNode
);
DO_FREE_HASH_NODE
(
pNewNode
);
}
}
...
@@ -335,22 +343,10 @@ int32_t taosHashRemoveWithData(SHashObj *pHashObj, const void *key, size_t keyLe
...
@@ -335,22 +343,10 @@ int32_t taosHashRemoveWithData(SHashObj *pHashObj, const void *key, size_t keyLe
int32_t
slot
=
HASH_INDEX
(
hashVal
,
pHashObj
->
capacity
);
int32_t
slot
=
HASH_INDEX
(
hashVal
,
pHashObj
->
capacity
);
SHashEntry
*
pe
=
pHashObj
->
hashList
[
slot
];
SHashEntry
*
pe
=
pHashObj
->
hashList
[
slot
];
// no data, return directly
if
(
pe
->
num
==
0
)
{
__rd_unlock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
return
-
1
;
}
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
taosWLockLatch
(
&
pe
->
latch
);
taosWLockLatch
(
&
pe
->
latch
);
}
}
if
(
pe
->
num
==
0
)
{
assert
(
pe
->
next
==
NULL
);
}
else
{
assert
(
pe
->
next
!=
NULL
);
}
// double check after locked
// double check after locked
if
(
pe
->
num
==
0
)
{
if
(
pe
->
num
==
0
)
{
assert
(
pe
->
next
==
NULL
);
assert
(
pe
->
next
==
NULL
);
...
@@ -360,36 +356,36 @@ int32_t taosHashRemoveWithData(SHashObj *pHashObj, const void *key, size_t keyLe
...
@@ -360,36 +356,36 @@ int32_t taosHashRemoveWithData(SHashObj *pHashObj, const void *key, size_t keyLe
return
-
1
;
return
-
1
;
}
}
int
code
=
-
1
;
SHashNode
*
pNode
=
pe
->
next
;
SHashNode
*
pNode
=
pe
->
next
;
SHashNode
*
p
Res
=
NULL
;
SHashNode
*
p
revNode
=
NULL
;
// remove it
while
(
pNode
)
{
if
((
pNode
->
keyLen
==
keyLen
)
&&
(
memcmp
(
GET_HASH_NODE_KEY
(
pNode
),
key
,
keyLen
)
==
0
))
{
if
((
pNode
->
keyLen
==
keyLen
)
&&
(
memcmp
(
GET_HASH_NODE_KEY
(
pNode
),
key
,
keyLen
)
==
0
)
&&
pNode
->
removed
==
0
)
pe
->
num
-=
1
;
pRes
=
pNode
;
pe
->
next
=
pNode
->
next
;
}
else
{
while
(
pNode
->
next
!=
NULL
)
{
if
(((
pNode
->
next
)
->
keyLen
==
keyLen
)
&&
(
memcmp
(
GET_HASH_NODE_KEY
((
pNode
->
next
)),
key
,
keyLen
)
==
0
))
{
assert
((
pNode
->
next
)
->
hashVal
==
hashVal
);
break
;
break
;
}
prevNode
=
pNode
;
pNode
=
pNode
->
next
;
pNode
=
pNode
->
next
;
}
}
if
(
pNode
)
{
code
=
0
;
// it is found
if
(
pNode
->
next
!=
NULL
)
{
pNode
->
count
--
;
pe
->
num
-=
1
;
pNode
->
removed
=
1
;
pRes
=
pNode
->
next
;
if
(
pNode
->
count
<=
0
)
{
pNode
->
next
=
pNode
->
next
->
next
;
if
(
prevNode
)
{
}
prevNode
->
next
=
pNode
->
next
;
}
else
{
pe
->
next
=
pNode
->
next
;
}
}
if
(
pe
->
num
==
0
)
{
if
(
data
)
memcpy
(
data
,
GET_HASH_NODE_DATA
(
pNode
),
dsize
);
assert
(
pe
->
next
==
NULL
);
}
else
{
pe
->
num
--
;
assert
(
pe
->
next
!=
NULL
);
atomic_sub_fetch_64
(
&
pHashObj
->
size
,
1
);
FREE_HASH_NODE
(
pHashObj
,
pNode
);
}
}
}
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
...
@@ -398,17 +394,7 @@ int32_t taosHashRemoveWithData(SHashObj *pHashObj, const void *key, size_t keyLe
...
@@ -398,17 +394,7 @@ int32_t taosHashRemoveWithData(SHashObj *pHashObj, const void *key, size_t keyLe
__rd_unlock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
__rd_unlock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
if
(
data
!=
NULL
&&
pRes
!=
NULL
)
{
return
code
;
memcpy
(
data
,
GET_HASH_NODE_DATA
(
pRes
),
dsize
);
}
if
(
pRes
!=
NULL
)
{
atomic_sub_fetch_64
(
&
pHashObj
->
size
,
1
);
FREE_HASH_NODE
(
pHashObj
,
pRes
);
return
0
;
}
else
{
return
-
1
;
}
}
}
int32_t
taosHashCondTraverse
(
SHashObj
*
pHashObj
,
bool
(
*
fp
)(
void
*
,
void
*
),
void
*
param
)
{
int32_t
taosHashCondTraverse
(
SHashObj
*
pHashObj
,
bool
(
*
fp
)(
void
*
,
void
*
),
void
*
param
)
{
...
@@ -531,98 +517,6 @@ void taosHashCleanup(SHashObj *pHashObj) {
...
@@ -531,98 +517,6 @@ void taosHashCleanup(SHashObj *pHashObj) {
free
(
pHashObj
);
free
(
pHashObj
);
}
}
SHashMutableIterator
*
taosHashCreateIter
(
SHashObj
*
pHashObj
)
{
SHashMutableIterator
*
pIter
=
calloc
(
1
,
sizeof
(
SHashMutableIterator
));
if
(
pIter
==
NULL
)
{
return
NULL
;
}
pIter
->
pHashObj
=
pHashObj
;
// keep it in local variable, in case the resize operation expand the size
pIter
->
numOfEntries
=
pHashObj
->
capacity
;
return
pIter
;
}
bool
taosHashIterNext
(
SHashMutableIterator
*
pIter
)
{
if
(
pIter
==
NULL
)
{
return
false
;
}
size_t
size
=
taosHashGetSize
(
pIter
->
pHashObj
);
if
(
size
==
0
)
{
return
false
;
}
// check the first one
if
(
pIter
->
numOfChecked
==
0
)
{
assert
(
pIter
->
pCur
==
NULL
&&
pIter
->
pNext
==
NULL
);
while
(
1
)
{
SHashEntry
*
pEntry
=
pIter
->
pHashObj
->
hashList
[
pIter
->
entryIndex
];
if
(
pEntry
->
num
==
0
)
{
assert
(
pEntry
->
next
==
NULL
);
pIter
->
entryIndex
++
;
continue
;
}
if
(
pIter
->
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
taosRLockLatch
(
&
pEntry
->
latch
);
}
pIter
->
pCur
=
pEntry
->
next
;
if
(
pIter
->
pCur
->
next
)
{
pIter
->
pNext
=
pIter
->
pCur
->
next
;
if
(
pIter
->
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
taosRUnLockLatch
(
&
pEntry
->
latch
);
}
}
else
{
if
(
pIter
->
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
taosRUnLockLatch
(
&
pEntry
->
latch
);
}
pIter
->
pNext
=
getNextHashNode
(
pIter
);
}
break
;
}
pIter
->
numOfChecked
++
;
return
true
;
}
else
{
assert
(
pIter
->
pCur
!=
NULL
);
if
(
pIter
->
pNext
)
{
pIter
->
pCur
=
pIter
->
pNext
;
}
else
{
// no more data in the hash list
return
false
;
}
pIter
->
numOfChecked
++
;
if
(
pIter
->
pCur
->
next
)
{
pIter
->
pNext
=
pIter
->
pCur
->
next
;
}
else
{
pIter
->
pNext
=
getNextHashNode
(
pIter
);
}
return
true
;
}
}
void
*
taosHashIterGet
(
SHashMutableIterator
*
iter
)
{
return
(
iter
==
NULL
)
?
NULL
:
GET_HASH_NODE_DATA
(
iter
->
pCur
);
}
void
*
taosHashDestroyIter
(
SHashMutableIterator
*
iter
)
{
if
(
iter
==
NULL
)
{
return
NULL
;
}
free
(
iter
);
return
NULL
;
}
// for profile only
// for profile only
int32_t
taosHashGetMaxOverflowLinkLength
(
const
SHashObj
*
pHashObj
)
{
int32_t
taosHashGetMaxOverflowLinkLength
(
const
SHashObj
*
pHashObj
)
{
if
(
pHashObj
==
NULL
||
pHashObj
->
size
==
0
)
{
if
(
pHashObj
==
NULL
||
pHashObj
->
size
==
0
)
{
...
@@ -759,6 +653,8 @@ SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, s
...
@@ -759,6 +653,8 @@ SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, s
pNewNode
->
keyLen
=
(
uint32_t
)
keyLen
;
pNewNode
->
keyLen
=
(
uint32_t
)
keyLen
;
pNewNode
->
hashVal
=
hashVal
;
pNewNode
->
hashVal
=
hashVal
;
pNewNode
->
dataLen
=
dsize
;
pNewNode
->
count
=
1
;
memcpy
(
GET_HASH_NODE_DATA
(
pNewNode
),
pData
,
dsize
);
memcpy
(
GET_HASH_NODE_DATA
(
pNewNode
),
pData
,
dsize
);
memcpy
(
GET_HASH_NODE_KEY
(
pNewNode
),
key
,
keyLen
);
memcpy
(
GET_HASH_NODE_KEY
(
pNewNode
),
key
,
keyLen
);
...
@@ -775,39 +671,136 @@ void pushfrontNodeInEntryList(SHashEntry *pEntry, SHashNode *pNode) {
...
@@ -775,39 +671,136 @@ void pushfrontNodeInEntryList(SHashEntry *pEntry, SHashNode *pNode) {
pEntry
->
num
+=
1
;
pEntry
->
num
+=
1
;
}
}
SHashNode
*
getNextHashNode
(
SHashMutableIterator
*
pIter
)
{
size_t
taosHashGetMemSize
(
const
SHashObj
*
pHashObj
)
{
assert
(
pIter
!=
NULL
);
if
(
pHashObj
==
NULL
)
{
return
0
;
}
return
(
pHashObj
->
capacity
*
(
sizeof
(
SHashEntry
)
+
POINTER_BYTES
))
+
sizeof
(
SHashNode
)
*
taosHashGetSize
(
pHashObj
)
+
sizeof
(
SHashObj
);
}
pIter
->
entryIndex
++
;
// release the pNode, return next pNode, and lock the current entry
SHashNode
*
p
=
NULL
;
static
void
*
taosHashReleaseNode
(
SHashObj
*
pHashObj
,
void
*
p
,
int
*
slot
)
{
while
(
pIter
->
entryIndex
<
pIter
->
numOfEntries
)
{
SHashNode
*
pOld
=
(
SHashNode
*
)
GET_HASH_PNODE
(
p
);
SHashEntry
*
pEntry
=
pIter
->
pHashObj
->
hashList
[
pIter
->
entryIndex
];
SHashNode
*
prevNode
=
NULL
;
if
(
pEntry
->
num
==
0
)
{
pIter
->
entryIndex
++
;
*
slot
=
HASH_INDEX
(
pOld
->
hashVal
,
pHashObj
->
capacity
);
continue
;
SHashEntry
*
pe
=
pHashObj
->
hashList
[
*
slot
];
// lock entry
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
taosWLockLatch
(
&
pe
->
latch
);
}
}
if
(
pIter
->
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
SHashNode
*
pNode
=
pe
->
next
;
taosRLockLatch
(
&
pEntry
->
latch
);
while
(
pNode
)
{
if
(
pNode
==
pOld
)
break
;
prevNode
=
pNode
;
pNode
=
pNode
->
next
;
}
}
p
=
pEntry
->
next
;
if
(
pNode
)
{
pNode
=
pNode
->
next
;
while
(
pNode
)
{
if
(
pNode
->
removed
==
0
)
break
;
pNode
=
pNode
->
next
;
}
if
(
pIter
->
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
pOld
->
count
--
;
taosRUnLockLatch
(
&
pEntry
->
latch
);
if
(
pOld
->
count
<=
0
)
{
if
(
prevNode
)
{
prevNode
->
next
=
pOld
->
next
;
}
else
{
pe
->
next
=
pOld
->
next
;
}
}
return
p
;
pe
->
num
--
;
atomic_sub_fetch_64
(
&
pHashObj
->
size
,
1
);
FREE_HASH_NODE
(
pHashObj
,
pOld
);
}
}
else
{
uError
(
"pNode:%p data:%p is not there!!!"
,
pNode
,
p
);
}
}
return
NULL
;
return
pNode
;
}
}
size_t
taosHashGetMemSize
(
const
SHashObj
*
pHashObj
)
{
void
*
taosHashIterate
(
SHashObj
*
pHashObj
,
void
*
p
)
{
if
(
pHashObj
==
NULL
)
{
if
(
pHashObj
==
NULL
)
return
NULL
;
return
0
;
int
slot
=
0
;
char
*
data
=
NULL
;
// only add the read lock to disable the resize process
__rd_lock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
SHashNode
*
pNode
=
NULL
;
if
(
p
)
{
pNode
=
taosHashReleaseNode
(
pHashObj
,
p
,
&
slot
);
if
(
pNode
==
NULL
)
{
SHashEntry
*
pe
=
pHashObj
->
hashList
[
slot
];
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
taosWUnLockLatch
(
&
pe
->
latch
);
}
}
return
(
pHashObj
->
capacity
*
(
sizeof
(
SHashEntry
)
+
POINTER_BYTES
))
+
sizeof
(
SHashNode
)
*
taosHashGetSize
(
pHashObj
)
+
sizeof
(
SHashObj
);
slot
=
slot
+
1
;
}
}
if
(
pNode
==
NULL
)
{
for
(;
slot
<
pHashObj
->
capacity
;
++
slot
)
{
SHashEntry
*
pe
=
pHashObj
->
hashList
[
slot
];
// lock entry
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
taosWLockLatch
(
&
pe
->
latch
);
}
pNode
=
pe
->
next
;
while
(
pNode
)
{
if
(
pNode
->
removed
==
0
)
break
;
pNode
=
pNode
->
next
;
}
if
(
pNode
)
break
;
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
taosWUnLockLatch
(
&
pe
->
latch
);
}
}
}
if
(
pNode
)
{
SHashEntry
*
pe
=
pHashObj
->
hashList
[
slot
];
pNode
->
count
++
;
data
=
GET_HASH_NODE_DATA
(
pNode
);
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
taosWUnLockLatch
(
&
pe
->
latch
);
}
}
__rd_unlock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
return
data
;
}
void
taosHashCancelIterate
(
SHashObj
*
pHashObj
,
void
*
p
)
{
if
(
pHashObj
==
NULL
||
p
==
NULL
)
return
;
// only add the read lock to disable the resize process
__rd_lock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
int
slot
;
taosHashReleaseNode
(
pHashObj
,
p
,
&
slot
);
SHashEntry
*
pe
=
pHashObj
->
hashList
[
slot
];
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
taosWUnLockLatch
(
&
pe
->
latch
);
}
__rd_unlock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
}
}
src/util/src/tkvstore.c
浏览文件 @
91bc2e9c
...
@@ -529,7 +529,7 @@ static int tdRestoreKVStore(SKVStore *pStore) {
...
@@ -529,7 +529,7 @@ static int tdRestoreKVStore(SKVStore *pStore) {
void
*
buf
=
NULL
;
void
*
buf
=
NULL
;
int64_t
maxBufSize
=
0
;
int64_t
maxBufSize
=
0
;
SKVRecord
rInfo
=
{
0
};
SKVRecord
rInfo
=
{
0
};
S
HashMutableIterator
*
pIter
=
NULL
;
S
KVRecord
*
pRecord
=
NULL
;
ASSERT
(
TD_KVSTORE_HEADER_SIZE
==
lseek
(
pStore
->
fd
,
0
,
SEEK_CUR
));
ASSERT
(
TD_KVSTORE_HEADER_SIZE
==
lseek
(
pStore
->
fd
,
0
,
SEEK_CUR
));
ASSERT
(
pStore
->
info
.
size
==
TD_KVSTORE_HEADER_SIZE
);
ASSERT
(
pStore
->
info
.
size
==
TD_KVSTORE_HEADER_SIZE
);
...
@@ -582,16 +582,8 @@ static int tdRestoreKVStore(SKVStore *pStore) {
...
@@ -582,16 +582,8 @@ static int tdRestoreKVStore(SKVStore *pStore) {
goto
_err
;
goto
_err
;
}
}
pIter
=
taosHashCreateIter
(
pStore
->
map
);
pRecord
=
taosHashIterate
(
pStore
->
map
,
NULL
);
if
(
pIter
==
NULL
)
{
while
(
pRecord
)
{
uError
(
"failed to create hash iter while opening KV store %s"
,
pStore
->
fname
);
terrno
=
TSDB_CODE_COM_OUT_OF_MEMORY
;
goto
_err
;
}
while
(
taosHashIterNext
(
pIter
))
{
SKVRecord
*
pRecord
=
taosHashIterGet
(
pIter
);
if
(
lseek
(
pStore
->
fd
,
(
off_t
)(
pRecord
->
offset
+
sizeof
(
SKVRecord
)),
SEEK_SET
)
<
0
)
{
if
(
lseek
(
pStore
->
fd
,
(
off_t
)(
pRecord
->
offset
+
sizeof
(
SKVRecord
)),
SEEK_SET
)
<
0
)
{
uError
(
"failed to lseek file %s since %s, offset %"
PRId64
,
pStore
->
fname
,
strerror
(
errno
),
pRecord
->
offset
);
uError
(
"failed to lseek file %s since %s, offset %"
PRId64
,
pStore
->
fname
,
strerror
(
errno
),
pRecord
->
offset
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
@@ -613,16 +605,17 @@ static int tdRestoreKVStore(SKVStore *pStore) {
...
@@ -613,16 +605,17 @@ static int tdRestoreKVStore(SKVStore *pStore) {
goto
_err
;
goto
_err
;
}
}
}
}
pRecord
=
taosHashIterate
(
pStore
->
map
,
pRecord
);
}
}
if
(
pStore
->
aFunc
)
(
*
pStore
->
aFunc
)(
pStore
->
appH
);
if
(
pStore
->
aFunc
)
(
*
pStore
->
aFunc
)(
pStore
->
appH
);
taosHashDestroyIter
(
pIter
);
tfree
(
buf
);
tfree
(
buf
);
return
0
;
return
0
;
_err:
_err:
taosHash
DestroyIter
(
pIter
);
taosHash
CancelIterate
(
pStore
->
map
,
pRecord
);
tfree
(
buf
);
tfree
(
buf
);
return
-
1
;
return
-
1
;
}
}
src/util/src/tqueue.c
浏览文件 @
91bc2e9c
...
@@ -79,15 +79,12 @@ void taosCloseQueue(taos_queue param) {
...
@@ -79,15 +79,12 @@ void taosCloseQueue(taos_queue param) {
if
(
queue
->
qset
)
taosRemoveFromQset
(
qset
,
queue
);
if
(
queue
->
qset
)
taosRemoveFromQset
(
qset
,
queue
);
pthread_mutex_lock
(
&
queue
->
mutex
);
while
(
pNode
)
{
while
(
pNode
)
{
pTemp
=
pNode
;
pTemp
=
pNode
;
pNode
=
pNode
->
next
;
pNode
=
pNode
->
next
;
free
(
pTemp
);
free
(
pTemp
);
}
}
pthread_mutex_unlock
(
&
queue
->
mutex
);
pthread_mutex_destroy
(
&
queue
->
mutex
);
pthread_mutex_destroy
(
&
queue
->
mutex
);
free
(
queue
);
free
(
queue
);
...
...
src/util/src/tskiplist.c
浏览文件 @
91bc2e9c
...
@@ -291,7 +291,10 @@ bool tSkipListIterNext(SSkipListIterator *iter) {
...
@@ -291,7 +291,10 @@ bool tSkipListIterNext(SSkipListIterator *iter) {
iter
->
next
=
SL_NODE_GET_FORWARD_POINTER
(
iter
->
cur
,
0
);
iter
->
next
=
SL_NODE_GET_FORWARD_POINTER
(
iter
->
cur
,
0
);
iter
->
step
++
;
iter
->
step
++
;
}
else
{
}
else
{
if
(
iter
->
cur
==
pSkipList
->
pHead
)
return
false
;
if
(
iter
->
cur
==
pSkipList
->
pHead
)
{
tSkipListUnlock
(
pSkipList
);
return
false
;
}
iter
->
cur
=
SL_NODE_GET_BACKWARD_POINTER
(
iter
->
cur
,
0
);
iter
->
cur
=
SL_NODE_GET_BACKWARD_POINTER
(
iter
->
cur
,
0
);
// a new node is inserted into between iter->cur and iter->next, ignore it
// a new node is inserted into between iter->cur and iter->next, ignore it
...
...
src/vnode/inc/vnodeInt.h
浏览文件 @
91bc2e9c
...
@@ -44,6 +44,7 @@ typedef struct {
...
@@ -44,6 +44,7 @@ typedef struct {
int8_t
role
;
int8_t
role
;
int8_t
accessState
;
int8_t
accessState
;
int8_t
isFull
;
int8_t
isFull
;
int8_t
isCommiting
;
uint64_t
version
;
// current version
uint64_t
version
;
// current version
uint64_t
fversion
;
// version on saved data file
uint64_t
fversion
;
// version on saved data file
void
*
wqueue
;
void
*
wqueue
;
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
91bc2e9c
...
@@ -41,6 +41,7 @@ static void vnodeCtrlFlow(int32_t vgId, int32_t level);
...
@@ -41,6 +41,7 @@ static void vnodeCtrlFlow(int32_t vgId, int32_t level);
static
int32_t
vnodeNotifyFileSynced
(
int32_t
vgId
,
uint64_t
fversion
);
static
int32_t
vnodeNotifyFileSynced
(
int32_t
vgId
,
uint64_t
fversion
);
static
void
vnodeConfirmForard
(
int32_t
vgId
,
void
*
wparam
,
int32_t
code
);
static
void
vnodeConfirmForard
(
int32_t
vgId
,
void
*
wparam
,
int32_t
code
);
static
int32_t
vnodeWriteToCache
(
int32_t
vgId
,
void
*
wparam
,
int32_t
qtype
,
void
*
rparam
);
static
int32_t
vnodeWriteToCache
(
int32_t
vgId
,
void
*
wparam
,
int32_t
qtype
,
void
*
rparam
);
static
int32_t
vnodeGetFileVersion
(
int32_t
vgId
,
uint64_t
*
fver
);
#ifndef _SYNC
#ifndef _SYNC
int64_t
syncStart
(
const
SSyncInfo
*
info
)
{
return
NULL
;
}
int64_t
syncStart
(
const
SSyncInfo
*
info
)
{
return
NULL
;
}
...
@@ -344,6 +345,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
...
@@ -344,6 +345,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
syncInfo
.
notifyRole
=
vnodeNotifyRole
;
syncInfo
.
notifyRole
=
vnodeNotifyRole
;
syncInfo
.
notifyFlowCtrl
=
vnodeCtrlFlow
;
syncInfo
.
notifyFlowCtrl
=
vnodeCtrlFlow
;
syncInfo
.
notifyFileSynced
=
vnodeNotifyFileSynced
;
syncInfo
.
notifyFileSynced
=
vnodeNotifyFileSynced
;
syncInfo
.
getFileVersion
=
vnodeGetFileVersion
;
pVnode
->
sync
=
syncStart
(
&
syncInfo
);
pVnode
->
sync
=
syncStart
(
&
syncInfo
);
#ifndef _SYNC
#ifndef _SYNC
...
@@ -512,11 +514,10 @@ static void vnodeBuildVloadMsg(SVnodeObj *pVnode, SStatusMsg *pStatus) {
...
@@ -512,11 +514,10 @@ 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
(
tsVnodesHash
);
void
*
pIter
=
taosHashIterate
(
tsVnodesHash
,
NULL
);
while
(
taosHashIterNext
(
pIter
))
{
while
(
pIter
)
{
SVnodeObj
**
pVnode
=
taosHashIterGet
(
pIter
);
SVnodeObj
**
pVnode
=
pIter
;
if
(
pVnode
==
NULL
)
continue
;
if
(
*
pVnode
)
{
if
(
*
pVnode
==
NULL
)
continue
;
(
*
numOfVnodes
)
++
;
(
*
numOfVnodes
)
++
;
if
(
*
numOfVnodes
>=
TSDB_MAX_VNODES
)
{
if
(
*
numOfVnodes
>=
TSDB_MAX_VNODES
)
{
...
@@ -525,25 +526,25 @@ int32_t vnodeGetVnodeList(int32_t vnodeList[], int32_t *numOfVnodes) {
...
@@ -525,25 +526,25 @@ int32_t vnodeGetVnodeList(int32_t vnodeList[], int32_t *numOfVnodes) {
}
else
{
}
else
{
vnodeList
[
*
numOfVnodes
-
1
]
=
(
*
pVnode
)
->
vgId
;
vnodeList
[
*
numOfVnodes
-
1
]
=
(
*
pVnode
)
->
vgId
;
}
}
}
}
taosHashDestroyIter
(
pIter
);
pIter
=
taosHashIterate
(
tsVnodesHash
,
pIter
);
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
void
vnodeBuildStatusMsg
(
void
*
param
)
{
void
vnodeBuildStatusMsg
(
void
*
param
)
{
SStatusMsg
*
pStatus
=
param
;
SStatusMsg
*
pStatus
=
param
;
SHashMutableIterator
*
pIter
=
taosHashCreateIter
(
tsVnodesHash
);
while
(
taosHashIterNext
(
pIter
))
{
SVnodeObj
**
pVnode
=
taosHashIterGet
(
pIter
);
if
(
pVnode
==
NULL
)
continue
;
if
(
*
pVnode
==
NULL
)
continue
;
void
*
pIter
=
taosHashIterate
(
tsVnodesHash
,
NULL
);
while
(
pIter
)
{
SVnodeObj
**
pVnode
=
pIter
;
if
(
*
pVnode
)
{
vnodeBuildVloadMsg
(
*
pVnode
,
pStatus
);
vnodeBuildVloadMsg
(
*
pVnode
,
pStatus
);
}
}
pIter
=
taosHashIterate
(
tsVnodesHash
,
pIter
);
taosHashDestroyIter
(
pIter
);
}
}
}
void
vnodeSetAccess
(
SVgroupAccess
*
pAccess
,
int32_t
numOfVnodes
)
{
void
vnodeSetAccess
(
SVgroupAccess
*
pAccess
,
int32_t
numOfVnodes
)
{
...
@@ -589,18 +590,19 @@ static void vnodeCleanUp(SVnodeObj *pVnode) {
...
@@ -589,18 +590,19 @@ static void vnodeCleanUp(SVnodeObj *pVnode) {
vnodeRelease
(
pVnode
);
vnodeRelease
(
pVnode
);
}
}
// TODO: this is a simple implement
static
int32_t
vnodeProcessTsdbStatus
(
void
*
arg
,
int32_t
status
,
int32_t
eno
)
{
static
int32_t
vnodeProcessTsdbStatus
(
void
*
arg
,
int32_t
status
,
int32_t
eno
)
{
SVnodeObj
*
pVnode
=
arg
;
SVnodeObj
*
pVnode
=
arg
;
if
(
eno
!=
TSDB_CODE_SUCCESS
)
{
if
(
eno
!=
TSDB_CODE_SUCCESS
)
{
vError
(
"vgId:%d, failed to commit since %s, fver:%"
PRIu64
" vver:%"
PRIu64
,
pVnode
->
vgId
,
tstrerror
(
eno
),
vError
(
"vgId:%d, failed to commit since %s, fver:%"
PRIu64
" vver:%"
PRIu64
,
pVnode
->
vgId
,
tstrerror
(
eno
),
pVnode
->
fversion
,
pVnode
->
version
);
pVnode
->
fversion
,
pVnode
->
version
);
pVnode
->
isCommiting
=
0
;
pVnode
->
isFull
=
1
;
pVnode
->
isFull
=
1
;
return
0
;
return
0
;
}
}
if
(
status
==
TSDB_STATUS_COMMIT_START
)
{
if
(
status
==
TSDB_STATUS_COMMIT_START
)
{
pVnode
->
isCommiting
=
1
;
pVnode
->
fversion
=
pVnode
->
version
;
pVnode
->
fversion
=
pVnode
->
version
;
vDebug
(
"vgId:%d, start commit, fver:%"
PRIu64
" vver:%"
PRIu64
,
pVnode
->
vgId
,
pVnode
->
fversion
,
pVnode
->
version
);
vDebug
(
"vgId:%d, start commit, fver:%"
PRIu64
" vver:%"
PRIu64
,
pVnode
->
vgId
,
pVnode
->
fversion
,
pVnode
->
version
);
if
(
pVnode
->
status
!=
TAOS_VN_STATUS_INIT
)
{
if
(
pVnode
->
status
!=
TAOS_VN_STATUS_INIT
)
{
...
@@ -611,6 +613,7 @@ static int32_t vnodeProcessTsdbStatus(void *arg, int32_t status, int32_t eno) {
...
@@ -611,6 +613,7 @@ static int32_t vnodeProcessTsdbStatus(void *arg, int32_t status, int32_t eno) {
if
(
status
==
TSDB_STATUS_COMMIT_OVER
)
{
if
(
status
==
TSDB_STATUS_COMMIT_OVER
)
{
vDebug
(
"vgId:%d, commit over, fver:%"
PRIu64
" vver:%"
PRIu64
,
pVnode
->
vgId
,
pVnode
->
fversion
,
pVnode
->
version
);
vDebug
(
"vgId:%d, commit over, fver:%"
PRIu64
" vver:%"
PRIu64
,
pVnode
->
vgId
,
pVnode
->
fversion
,
pVnode
->
version
);
pVnode
->
isCommiting
=
0
;
pVnode
->
isFull
=
0
;
pVnode
->
isFull
=
0
;
if
(
pVnode
->
status
!=
TAOS_VN_STATUS_INIT
)
{
if
(
pVnode
->
status
!=
TAOS_VN_STATUS_INIT
)
{
walRemoveOneOldFile
(
pVnode
->
wal
);
walRemoveOneOldFile
(
pVnode
->
wal
);
...
@@ -676,8 +679,10 @@ static void vnodeCtrlFlow(int32_t vgId, int32_t level) {
...
@@ -676,8 +679,10 @@ static void vnodeCtrlFlow(int32_t vgId, int32_t level) {
return
;
return
;
}
}
if
(
pVnode
->
flowctrlLevel
!=
level
)
{
vDebug
(
"vgId:%d, set flowctrl level from %d to %d"
,
pVnode
->
vgId
,
pVnode
->
flowctrlLevel
,
level
);
pVnode
->
flowctrlLevel
=
level
;
pVnode
->
flowctrlLevel
=
level
;
vDebug
(
"vgId:%d, set flowctrl level:%d"
,
pVnode
->
vgId
,
level
);
}
vnodeRelease
(
pVnode
);
vnodeRelease
(
pVnode
);
}
}
...
@@ -757,3 +762,22 @@ static int32_t vnodeWriteToCache(int32_t vgId, void *wparam, int32_t qtype, void
...
@@ -757,3 +762,22 @@ static int32_t vnodeWriteToCache(int32_t vgId, void *wparam, int32_t qtype, void
vnodeRelease
(
pVnode
);
vnodeRelease
(
pVnode
);
return
code
;
return
code
;
}
}
static
int32_t
vnodeGetFileVersion
(
int32_t
vgId
,
uint64_t
*
fver
)
{
SVnodeObj
*
pVnode
=
vnodeAcquire
(
vgId
);
if
(
pVnode
==
NULL
)
{
vError
(
"vgId:%d, vnode not found while write to cache"
,
vgId
);
return
-
1
;
}
int32_t
code
=
0
;
if
(
pVnode
->
isCommiting
)
{
vDebug
(
"vgId:%d, vnode is commiting while get file version"
,
vgId
);
code
=
-
1
;
}
else
{
*
fver
=
pVnode
->
fversion
;
}
vnodeRelease
(
pVnode
);
return
code
;
}
src/vnode/src/vnodeWrite.c
浏览文件 @
91bc2e9c
...
@@ -282,13 +282,15 @@ static void vnodeFlowCtrlMsgToWQueue(void *param, void *tmrId) {
...
@@ -282,13 +282,15 @@ static void vnodeFlowCtrlMsgToWQueue(void *param, void *tmrId) {
pWrite
->
processedCount
++
;
pWrite
->
processedCount
++
;
if
(
pWrite
->
processedCount
>
100
)
{
if
(
pWrite
->
processedCount
>
100
)
{
vError
(
"vgId:%d, msg:%p, failed to process since %s"
,
pVnode
->
vgId
,
pWrite
,
tstrerror
(
code
));
vError
(
"vgId:%d, msg:%p, failed to process since %s, retry:%d"
,
pVnode
->
vgId
,
pWrite
,
tstrerror
(
code
),
pWrite
->
processedCount
);
pWrite
->
processedCount
=
1
;
pWrite
->
processedCount
=
1
;
dnodeSendRpcVWriteRsp
(
pWrite
->
pVnode
,
pWrite
,
code
);
dnodeSendRpcVWriteRsp
(
pWrite
->
pVnode
,
pWrite
,
code
);
}
else
{
}
else
{
code
=
vnodePerformFlowCtrl
(
pWrite
);
code
=
vnodePerformFlowCtrl
(
pWrite
);
if
(
code
==
0
)
{
if
(
code
==
0
)
{
vTrace
(
"vgId:%d, write into vwqueue after flowctrl"
,
pVnode
->
vgId
);
vDebug
(
"vgId:%d, msg:%p, write into vwqueue after flowctrl, retry:%d"
,
pVnode
->
vgId
,
pWrite
,
pWrite
->
processedCount
);
pWrite
->
processedCount
=
0
;
pWrite
->
processedCount
=
0
;
taosWriteQitem
(
pVnode
->
wqueue
,
pWrite
->
qtype
,
pWrite
);
taosWriteQitem
(
pVnode
->
wqueue
,
pWrite
->
qtype
,
pWrite
);
}
}
...
@@ -310,7 +312,7 @@ static int32_t vnodePerformFlowCtrl(SVWriteMsg *pWrite) {
...
@@ -310,7 +312,7 @@ static int32_t vnodePerformFlowCtrl(SVWriteMsg *pWrite) {
void
*
unUsed
=
NULL
;
void
*
unUsed
=
NULL
;
taosTmrReset
(
vnodeFlowCtrlMsgToWQueue
,
100
,
pWrite
,
tsDnodeTmr
,
&
unUsed
);
taosTmrReset
(
vnodeFlowCtrlMsgToWQueue
,
100
,
pWrite
,
tsDnodeTmr
,
&
unUsed
);
vTrace
(
"vgId:%d, msg:%p, app:%p, perform flowctrl,
count
:%d"
,
pVnode
->
vgId
,
pWrite
,
pWrite
->
rpcMsg
.
ahandle
,
vTrace
(
"vgId:%d, msg:%p, app:%p, perform flowctrl,
retry
:%d"
,
pVnode
->
vgId
,
pWrite
,
pWrite
->
rpcMsg
.
ahandle
,
pWrite
->
processedCount
);
pWrite
->
processedCount
);
return
TSDB_CODE_VND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_VND_ACTION_IN_PROGRESS
;
}
}
...
...
src/wal/src/walWrite.c
浏览文件 @
91bc2e9c
...
@@ -211,7 +211,7 @@ int32_t walGetWalFile(void *handle, char *fileName, int64_t *fileId) {
...
@@ -211,7 +211,7 @@ int32_t walGetWalFile(void *handle, char *fileName, int64_t *fileId) {
code
=
(
*
fileId
==
pWal
->
fileId
)
?
0
:
1
;
code
=
(
*
fileId
==
pWal
->
fileId
)
?
0
:
1
;
}
}
w
Trace
(
"vgId:%d, get wal file, code:%d curId:%"
PRId64
" outId:%"
PRId64
,
pWal
->
vgId
,
code
,
pWal
->
fileId
,
*
fileId
);
w
Debug
(
"vgId:%d, get wal file, code:%d curId:%"
PRId64
" outId:%"
PRId64
,
pWal
->
vgId
,
code
,
pWal
->
fileId
,
*
fileId
);
pthread_mutex_unlock
(
&
(
pWal
->
mutex
));
pthread_mutex_unlock
(
&
(
pWal
->
mutex
));
return
code
;
return
code
;
...
@@ -325,7 +325,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
...
@@ -325,7 +325,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
offset
=
offset
+
sizeof
(
SWalHead
)
+
pHead
->
len
;
offset
=
offset
+
sizeof
(
SWalHead
)
+
pHead
->
len
;
w
Trace
(
"vgId:%d, restore wal, fileId:%"
PRId64
" hver:%"
PRIu64
" wver:%"
PRIu64
" len:%d"
,
pWal
->
vgId
,
w
Debug
(
"vgId:%d, restore wal, fileId:%"
PRId64
" hver:%"
PRIu64
" wver:%"
PRIu64
" len:%d"
,
pWal
->
vgId
,
fileId
,
pHead
->
version
,
pWal
->
version
,
pHead
->
len
);
fileId
,
pHead
->
version
,
pWal
->
version
,
pHead
->
len
);
pWal
->
version
=
pHead
->
version
;
pWal
->
version
=
pHead
->
version
;
...
...
tests/examples/c/apitest.c
浏览文件 @
91bc2e9c
...
@@ -79,11 +79,11 @@ static int print_result(TAOS_RES* res, int blockFetch) {
...
@@ -79,11 +79,11 @@ static int print_result(TAOS_RES* res, int blockFetch) {
if
(
blockFetch
)
{
if
(
blockFetch
)
{
int
rows
=
0
;
int
rows
=
0
;
while
((
rows
=
taos_fetch_block
(
res
,
&
row
)))
{
while
((
rows
=
taos_fetch_block
(
res
,
&
row
)))
{
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
{
//
for (int i = 0; i < rows; i++) {
char
temp
[
256
];
//
char temp[256];
taos_print_row
(
temp
,
row
+
i
,
fields
,
num_fields
);
//
taos_print_row(temp, row + i, fields, num_fields);
puts
(
temp
);
//
puts(temp);
}
//
}
nRows
+=
rows
;
nRows
+=
rows
;
}
}
}
else
{
}
else
{
...
...
tests/examples/c/subscribe.c
浏览文件 @
91bc2e9c
...
@@ -19,10 +19,10 @@ void print_result(TAOS_RES* res, int blockFetch) {
...
@@ -19,10 +19,10 @@ void print_result(TAOS_RES* res, int blockFetch) {
if
(
blockFetch
)
{
if
(
blockFetch
)
{
nRows
=
taos_fetch_block
(
res
,
&
row
);
nRows
=
taos_fetch_block
(
res
,
&
row
);
for
(
int
i
=
0
;
i
<
nRows
;
i
++
)
{
//
for (int i = 0; i < nRows; i++) {
taos_print_row
(
buf
,
row
+
i
,
fields
,
num_fields
);
//
taos_print_row(buf, row + i, fields, num_fields);
puts
(
buf
);
//
puts(buf);
}
//
}
}
else
{
}
else
{
while
((
row
=
taos_fetch_row
(
res
)))
{
while
((
row
=
taos_fetch_row
(
res
)))
{
taos_print_row
(
buf
,
row
,
fields
,
num_fields
);
taos_print_row
(
buf
,
row
,
fields
,
num_fields
);
...
...
tests/script/basicSuite.sim
浏览文件 @
91bc2e9c
...
@@ -14,7 +14,6 @@ run general/table/vgroup.sim
...
@@ -14,7 +14,6 @@ run general/table/vgroup.sim
run general/user/authority.sim
run general/user/authority.sim
run general/vector/metrics_mix.sim
run general/vector/metrics_mix.sim
run general/vector/table_field.sim
run general/vector/table_field.sim
run general/user/authority.sim
run general/tag/set.sim
run general/tag/set.sim
run general/table/delete_writing.sim
run general/table/delete_writing.sim
run general/stable/disk.sim
run general/stable/disk.sim
tests/script/general/wal/sync.sim
浏览文件 @
91bc2e9c
...
@@ -82,6 +82,7 @@ restful d1 table_rest 1591772800 30000
...
@@ -82,6 +82,7 @@ restful d1 table_rest 1591772800 30000
restful d1 table_rest 1591872800 30000
restful d1 table_rest 1591872800 30000
restful d1 table_rest 1591972800 30000
restful d1 table_rest 1591972800 30000
sleep 1000
sql select * from table_rest;
sql select * from table_rest;
print rows: $rows
print rows: $rows
if $rows != 300000 then
if $rows != 300000 then
...
...
tests/script/tmp/mnodes.sim
浏览文件 @
91bc2e9c
...
@@ -20,6 +20,10 @@ system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20000
...
@@ -20,6 +20,10 @@ system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 20000
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 20000
system sh/cfg.sh -n dnode2 -c maxTablesPerVnode -v 20000
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 20000
system sh/cfg.sh -n dnode3 -c maxTablesPerVnode -v 20000
system sh/cfg.sh -n dnode1 -c minTablesPerVnode -v 1000
system sh/cfg.sh -n dnode2 -c minTablesPerVnode -v 1000
system sh/cfg.sh -n dnode3 -c minTablesPerVnode -v 1000
system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 20
system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 20
system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 20
system sh/cfg.sh -n dnode2 -c maxVgroupsPerDb -v 20
system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 20
system sh/cfg.sh -n dnode3 -c maxVgroupsPerDb -v 20
...
...
tests/test/c/CMakeLists.txt
浏览文件 @
91bc2e9c
...
@@ -31,8 +31,8 @@ IF (TD_LINUX)
...
@@ -31,8 +31,8 @@ IF (TD_LINUX)
#add_executable(createTablePerformance createTablePerformance.c)
#add_executable(createTablePerformance createTablePerformance.c)
#target_link_libraries(createTablePerformance taos_static tutil common pthread)
#target_link_libraries(createTablePerformance taos_static tutil common pthread)
#
add_executable(createNormalTable createNormalTable.c)
add_executable
(
createNormalTable createNormalTable.c
)
#
target_link_libraries(createNormalTable taos_static tutil common pthread)
target_link_libraries
(
createNormalTable taos_static tutil common pthread
)
#add_executable(queryPerformance queryPerformance.c)
#add_executable(queryPerformance queryPerformance.c)
#target_link_libraries(queryPerformance taos_static tutil common pthread)
#target_link_libraries(queryPerformance taos_static tutil common pthread)
...
@@ -45,5 +45,8 @@ IF (TD_LINUX)
...
@@ -45,5 +45,8 @@ IF (TD_LINUX)
#add_executable(invalidTableId invalidTableId.c)
#add_executable(invalidTableId invalidTableId.c)
#target_link_libraries(invalidTableId taos_static tutil common pthread)
#target_link_libraries(invalidTableId taos_static tutil common pthread)
add_executable
(
hashIterator hashIterator.c
)
target_link_libraries
(
hashIterator taos_static tutil common pthread
)
ENDIF
()
ENDIF
()
tests/test/c/hashIterator.c
0 → 100644
浏览文件 @
91bc2e9c
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taos.h"
#include "tulog.h"
#include "tutil.h"
#include "hash.h"
typedef
struct
HashTestRow
{
int32_t
keySize
;
char
key
[
100
];
}
HashTestRow
;
int
main
(
int
argc
,
char
*
argv
[])
{
_hash_fn_t
hashFp
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
void
*
hashHandle
=
taosHashInit
(
100
,
hashFp
,
true
,
HASH_ENTRY_LOCK
);
pPrint
(
"insert 3 rows to hash"
);
for
(
int32_t
t
=
0
;
t
<
3
;
++
t
)
{
HashTestRow
row
=
{
0
};
row
.
keySize
=
sprintf
(
row
.
key
,
"0.db.st%d"
,
t
);
taosHashPut
(
hashHandle
,
row
.
key
,
row
.
keySize
,
&
row
,
sizeof
(
HashTestRow
));
}
pPrint
(
"start iterator"
);
HashTestRow
*
row
=
taosHashIterate
(
hashHandle
,
NULL
);
while
(
row
)
{
pPrint
(
"drop key:%s"
,
row
->
key
);
taosHashRemove
(
hashHandle
,
row
->
key
,
row
->
keySize
);
pPrint
(
"get rows from hash"
);
for
(
int32_t
t
=
0
;
t
<
3
;
++
t
)
{
HashTestRow
r
=
{
0
};
r
.
keySize
=
sprintf
(
r
.
key
,
"0.db.st%d"
,
t
);
void
*
result
=
taosHashGet
(
hashHandle
,
r
.
key
,
r
.
keySize
);
pPrint
(
"get key:%s result:%p"
,
r
.
key
,
result
);
}
//Before getting the next iterator, the object just deleted can be obtained
row
=
taosHashIterate
(
hashHandle
,
row
);
}
pPrint
(
"stop iterator"
);
taosHashCancelIterate
(
hashHandle
,
row
);
pPrint
(
"get rows from hash"
);
for
(
int32_t
t
=
0
;
t
<
3
;
++
t
)
{
HashTestRow
r
=
{
0
};
r
.
keySize
=
sprintf
(
r
.
key
,
"0.db.st%d"
,
t
);
void
*
result
=
taosHashGet
(
hashHandle
,
r
.
key
,
r
.
keySize
);
pPrint
(
"get key:%s result:%p"
,
r
.
key
,
result
);
}
return
0
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录