Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
88c11ce7
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
88c11ce7
编写于
11月 30, 2020
作者:
H
Hui Li
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into hotfix/test
上级
59cbb734
98a86b3c
变更
71
展开全部
隐藏空白更改
内联
并排
Showing
71 changed file
with
1563 addition
and
909 deletion
+1563
-909
src/balance/src/balance.c
src/balance/src/balance.c
+15
-25
src/client/inc/tscLocalMerge.h
src/client/inc/tscLocalMerge.h
+0
-1
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+143
-116
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+9
-11
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+3
-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/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+2
-0
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+2
-2
src/inc/taoserror.h
src/inc/taoserror.h
+4
-1
src/inc/tsync.h
src/inc/tsync.h
+4
-0
src/inc/twal.h
src/inc/twal.h
+2
-3
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
+8
-5
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
+8
-4
src/mnode/src/mnodeCluster.c
src/mnode/src/mnodeCluster.c
+12
-4
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+11
-7
src/mnode/src/mnodeDnode.c
src/mnode/src/mnodeDnode.c
+15
-14
src/mnode/src/mnodeMain.c
src/mnode/src/mnodeMain.c
+1
-0
src/mnode/src/mnodeMnode.c
src/mnode/src/mnodeMnode.c
+28
-5
src/mnode/src/mnodePeer.c
src/mnode/src/mnodePeer.c
+2
-10
src/mnode/src/mnodeProfile.c
src/mnode/src/mnodeProfile.c
+13
-12
src/mnode/src/mnodeRead.c
src/mnode/src/mnodeRead.c
+3
-12
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+50
-30
src/mnode/src/mnodeShow.c
src/mnode/src/mnodeShow.c
+8
-2
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+34
-29
src/mnode/src/mnodeUser.c
src/mnode/src/mnodeUser.c
+10
-5
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+10
-11
src/mnode/src/mnodeWrite.c
src/mnode/src/mnodeWrite.c
+2
-12
src/os/inc/osFile.h
src/os/inc/osFile.h
+7
-12
src/os/src/detail/osFile.c
src/os/src/detail/osFile.c
+1
-1
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+8
-3
src/query/inc/tsqlfunction.h
src/query/inc/tsqlfunction.h
+12
-17
src/query/src/qAst.c
src/query/src/qAst.c
+96
-11
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+290
-40
src/query/src/qResultbuf.c
src/query/src/qResultbuf.c
+3
-5
src/query/src/qUtil.c
src/query/src/qUtil.c
+2
-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/util/inc/hash.h
src/util/inc/hash.h
+13
-41
src/util/inc/tfile.h
src/util/inc/tfile.h
+12
-9
src/util/src/hash.c
src/util/src/hash.c
+161
-168
src/util/src/tfile.c
src/util/src/tfile.c
+55
-13
src/util/src/tkvstore.c
src/util/src/tkvstore.c
+6
-13
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/inc/walInt.h
src/wal/inc/walInt.h
+1
-1
src/wal/src/walMgmt.c
src/wal/src/walMgmt.c
+5
-4
src/wal/src/walWrite.c
src/wal/src/walWrite.c
+30
-29
tests/script/basicSuite.sim
tests/script/basicSuite.sim
+0
-1
tests/script/general/parser/col_arithmetic_operation.sim
tests/script/general/parser/col_arithmetic_operation.sim
+11
-10
tests/script/general/parser/col_arithmetic_query.sim
tests/script/general/parser/col_arithmetic_query.sim
+231
-53
tests/script/general/parser/limit1_tb.sim
tests/script/general/parser/limit1_tb.sim
+5
-4
tests/script/general/parser/limit_tb.sim
tests/script/general/parser/limit_tb.sim
+9
-9
tests/script/general/parser/where.sim
tests/script/general/parser/where.sim
+2
-2
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
浏览文件 @
88c11ce7
...
@@ -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,11 +459,12 @@ static bool balanceMonitorDnodeDropping(SDnodeObj *pDnode) {
...
@@ -465,11 +459,12 @@ 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
);
mnodeDropDnode
(
pDnode
,
NULL
);
mnodeDropDnode
(
pDnode
,
NULL
);
...
@@ -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
;
...
@@ -780,8 +768,12 @@ void balanceAccquireDnodeList() {
...
@@ -780,8 +768,12 @@ void balanceAccquireDnodeList() {
SDnodeObj
*
pDnode
=
NULL
;
SDnodeObj
*
pDnode
=
NULL
;
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/tscLocalMerge.h
浏览文件 @
88c11ce7
...
@@ -56,7 +56,6 @@ typedef struct SLocalReducer {
...
@@ -56,7 +56,6 @@ typedef struct SLocalReducer {
tFilePage
*
pTempBuffer
;
tFilePage
*
pTempBuffer
;
struct
SQLFunctionCtx
*
pCtx
;
struct
SQLFunctionCtx
*
pCtx
;
int32_t
rowSize
;
// size of each intermediate result.
int32_t
rowSize
;
// size of each intermediate result.
int32_t
finalRowSize
;
// final result row size
int32_t
status
;
// denote it is in reduce process, in reduce process, it
int32_t
status
;
// denote it is in reduce process, in reduce process, it
bool
hasPrevRow
;
// cannot be released
bool
hasPrevRow
;
// cannot be released
bool
hasUnprocessedRow
;
bool
hasUnprocessedRow
;
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
88c11ce7
...
@@ -64,13 +64,13 @@
...
@@ -64,13 +64,13 @@
} \
} \
} while (0);
} while (0);
#define DO_UPDATE_TAG_COLUMNS_WITHOUT_TS(ctx) \
#define DO_UPDATE_TAG_COLUMNS_WITHOUT_TS(ctx)
\
do {
\
do {
\
for (int32_t i = 0; i < (ctx)->tagInfo.numOfTagCols; ++i) {
\
for (int32_t i = 0; i < (ctx)->tagInfo.numOfTagCols; ++i) {
\
SQLFunctionCtx *__ctx = (ctx)->tagInfo.pTagCtxList[i];
\
SQLFunctionCtx *__ctx = (ctx)->tagInfo.pTagCtxList[i]; \
aAggs[TSDB_FUNC_TAG].xFunction(__ctx);
\
aAggs[TSDB_FUNC_TAG].xFunction(__ctx); \
} \
}
\
} while
(0);
} while
(0);
void
noop1
(
SQLFunctionCtx
*
UNUSED_PARAM
(
pCtx
))
{}
void
noop1
(
SQLFunctionCtx
*
UNUSED_PARAM
(
pCtx
))
{}
void
noop2
(
SQLFunctionCtx
*
UNUSED_PARAM
(
pCtx
),
int32_t
UNUSED_PARAM
(
index
))
{}
void
noop2
(
SQLFunctionCtx
*
UNUSED_PARAM
(
pCtx
),
int32_t
UNUSED_PARAM
(
index
))
{}
...
@@ -3624,52 +3624,147 @@ static bool twa_function_setup(SQLFunctionCtx *pCtx) {
...
@@ -3624,52 +3624,147 @@ static bool twa_function_setup(SQLFunctionCtx *pCtx) {
return
false
;
return
false
;
}
}
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
//->aOutputBuf + pCtx->outputBytes;
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STwaInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
STwaInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
pInfo
->
lastKey
=
INT64_MIN
;
pInfo
->
lastKey
=
INT64_MIN
;
pInfo
->
type
=
pCtx
->
inputType
;
pInfo
->
win
=
TSWINDOW_INITIALIZER
;
return
true
;
return
true
;
}
}
static
FORCE_INLINE
void
setTWALastVal
(
SQLFunctionCtx
*
pCtx
,
const
char
*
data
,
int32_t
i
,
STwaInfo
*
pInfo
)
{
static
int32_t
twa_function_impl
(
SQLFunctionCtx
*
pCtx
,
int32_t
index
,
int32_t
size
)
{
switch
(
pCtx
->
inputType
)
{
int32_t
notNullElems
=
0
;
case
TSDB_DATA_TYPE_INT
:
TSKEY
*
primaryKey
=
pCtx
->
ptsList
;
pInfo
->
iLastValue
=
GET_INT32_VAL
(
data
+
pCtx
->
inputBytes
*
i
);
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STwaInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
int32_t
i
=
index
;
if
(
pCtx
->
start
.
key
!=
INT64_MIN
)
{
assert
(
pCtx
->
start
.
key
<
primaryKey
[
index
]
&&
pInfo
->
lastKey
==
INT64_MIN
);
pInfo
->
lastKey
=
primaryKey
[
index
];
GET_TYPED_DATA
(
pInfo
->
lastValue
,
double
,
pCtx
->
inputType
,
GET_INPUT_CHAR_INDEX
(
pCtx
,
0
));
pInfo
->
dOutput
+=
((
pInfo
->
lastValue
+
pCtx
->
start
.
val
)
/
2
)
*
(
pInfo
->
lastKey
-
pCtx
->
start
.
key
);
pInfo
->
hasResult
=
DATA_SET_FLAG
;
pInfo
->
win
.
skey
=
pCtx
->
start
.
key
;
notNullElems
++
;
i
+=
1
;
}
else
if
(
pInfo
->
lastKey
==
INT64_MIN
)
{
pInfo
->
lastKey
=
primaryKey
[
index
];
GET_TYPED_DATA
(
pInfo
->
lastValue
,
double
,
pCtx
->
inputType
,
GET_INPUT_CHAR_INDEX
(
pCtx
,
0
));
pInfo
->
hasResult
=
DATA_SET_FLAG
;
pInfo
->
win
.
skey
=
pInfo
->
lastKey
;
notNullElems
++
;
i
+=
1
;
}
// calculate the value of
switch
(
pCtx
->
inputType
)
{
case
TSDB_DATA_TYPE_TINYINT
:
{
int8_t
*
val
=
(
int8_t
*
)
GET_INPUT_CHAR_INDEX
(
pCtx
,
index
);
for
(;
i
<
size
;
i
++
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
val
[
i
],
pCtx
->
inputType
))
{
continue
;
}
pInfo
->
dOutput
+=
((
val
[
i
]
+
pInfo
->
lastValue
)
/
2
)
*
(
primaryKey
[
i
]
-
pInfo
->
lastKey
);
pInfo
->
lastValue
=
val
[
i
];
pInfo
->
lastKey
=
primaryKey
[
i
];
}
break
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
}
pInfo
->
iLastValue
=
GET_INT8_VAL
(
data
+
pCtx
->
inputBytes
*
i
);
case
TSDB_DATA_TYPE_SMALLINT
:
{
int16_t
*
val
=
(
int16_t
*
)
GET_INPUT_CHAR_INDEX
(
pCtx
,
index
);
for
(;
i
<
size
;
i
++
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
val
[
i
],
pCtx
->
inputType
))
{
continue
;
}
pInfo
->
dOutput
+=
((
val
[
i
]
+
pInfo
->
lastValue
)
/
2
)
*
(
primaryKey
[
i
]
-
pInfo
->
lastKey
);
pInfo
->
lastValue
=
val
[
i
];
pInfo
->
lastKey
=
primaryKey
[
i
];
}
break
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
}
pInfo
->
iLastValue
=
GET_INT16_VAL
(
data
+
pCtx
->
inputBytes
*
i
);
case
TSDB_DATA_TYPE_INT
:
{
int32_t
*
val
=
(
int32_t
*
)
GET_INPUT_CHAR_INDEX
(
pCtx
,
index
);
for
(;
i
<
size
;
i
++
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
val
[
i
],
pCtx
->
inputType
))
{
continue
;
}
pInfo
->
dOutput
+=
((
val
[
i
]
+
pInfo
->
lastValue
)
/
2
)
*
(
primaryKey
[
i
]
-
pInfo
->
lastKey
);
pInfo
->
lastValue
=
val
[
i
];
pInfo
->
lastKey
=
primaryKey
[
i
];
}
break
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
}
pInfo
->
iLastValue
=
GET_INT64_VAL
(
data
+
pCtx
->
inputBytes
*
i
);
case
TSDB_DATA_TYPE_BIGINT
:
{
int64_t
*
val
=
(
int64_t
*
)
GET_INPUT_CHAR_INDEX
(
pCtx
,
index
);
for
(;
i
<
size
;
i
++
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
val
[
i
],
pCtx
->
inputType
))
{
continue
;
}
pInfo
->
dOutput
+=
((
val
[
i
]
+
pInfo
->
lastValue
)
/
2
)
*
(
primaryKey
[
i
]
-
pInfo
->
lastKey
);
pInfo
->
lastValue
=
(
double
)
val
[
i
];
pInfo
->
lastKey
=
primaryKey
[
i
];
}
break
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
}
pInfo
->
dLastValue
=
GET_FLOAT_VAL
(
data
+
pCtx
->
inputBytes
*
i
);
case
TSDB_DATA_TYPE_FLOAT
:
{
float
*
val
=
(
float
*
)
GET_INPUT_CHAR_INDEX
(
pCtx
,
index
);
for
(;
i
<
size
;
i
++
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
val
[
i
],
pCtx
->
inputType
))
{
continue
;
}
pInfo
->
dOutput
+=
((
val
[
i
]
+
pInfo
->
lastValue
)
/
2
)
*
(
primaryKey
[
i
]
-
pInfo
->
lastKey
);
pInfo
->
lastValue
=
val
[
i
];
pInfo
->
lastKey
=
primaryKey
[
i
];
}
break
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
}
pInfo
->
dLastValue
=
GET_DOUBLE_VAL
(
data
+
pCtx
->
inputBytes
*
i
);
case
TSDB_DATA_TYPE_DOUBLE
:
{
double
*
val
=
(
double
*
)
GET_INPUT_CHAR_INDEX
(
pCtx
,
index
);
for
(;
i
<
size
;
i
++
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
const
char
*
)
&
val
[
i
],
pCtx
->
inputType
))
{
continue
;
}
pInfo
->
dOutput
+=
((
val
[
i
]
+
pInfo
->
lastValue
)
/
2
)
*
(
primaryKey
[
i
]
-
pInfo
->
lastKey
);
pInfo
->
lastValue
=
val
[
i
];
pInfo
->
lastKey
=
primaryKey
[
i
];
}
break
;
break
;
default:
}
assert
(
0
);
default:
assert
(
0
);
}
// the last interpolated time window value
if
(
pCtx
->
end
.
key
!=
INT64_MIN
)
{
pInfo
->
dOutput
+=
((
pInfo
->
lastValue
+
pCtx
->
end
.
val
)
/
2
)
*
(
pCtx
->
end
.
key
-
pInfo
->
lastKey
);
pInfo
->
lastValue
=
pCtx
->
end
.
val
;
pInfo
->
lastKey
=
pCtx
->
end
.
key
;
}
}
pInfo
->
win
.
ekey
=
pInfo
->
lastKey
;
return
notNullElems
;
}
}
static
void
twa_function
(
SQLFunctionCtx
*
pCtx
)
{
static
void
twa_function
(
SQLFunctionCtx
*
pCtx
)
{
void
*
data
=
GET_INPUT_CHAR
(
pCtx
);
void
*
data
=
GET_INPUT_CHAR
(
pCtx
);
TSKEY
*
primaryKey
=
pCtx
->
ptsList
;
int32_t
notNullElems
=
0
;
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STwaInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
STwaInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
int32_t
i
=
0
;
// skip null value
// skip null value
int32_t
i
=
0
;
while
(
pCtx
->
hasNull
&&
i
<
pCtx
->
size
&&
isNull
((
char
*
)
data
+
pCtx
->
inputBytes
*
i
,
pCtx
->
inputType
))
{
while
(
pCtx
->
hasNull
&&
i
<
pCtx
->
size
&&
isNull
((
char
*
)
data
+
pCtx
->
inputBytes
*
i
,
pCtx
->
inputType
))
{
i
++
;
i
++
;
}
}
...
@@ -3678,40 +3773,7 @@ static void twa_function(SQLFunctionCtx *pCtx) {
...
@@ -3678,40 +3773,7 @@ static void twa_function(SQLFunctionCtx *pCtx) {
return
;
return
;
}
}
if
(
pInfo
->
lastKey
==
INT64_MIN
)
{
int32_t
notNullElems
=
twa_function_impl
(
pCtx
,
pCtx
->
startOffset
,
pCtx
->
size
);
pInfo
->
lastKey
=
pCtx
->
nStartQueryTimestamp
;
setTWALastVal
(
pCtx
,
data
,
i
,
pInfo
);
pInfo
->
hasResult
=
DATA_SET_FLAG
;
}
notNullElems
++
;
if
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_FLOAT
||
pCtx
->
inputType
==
TSDB_DATA_TYPE_DOUBLE
)
{
pInfo
->
dOutput
+=
pInfo
->
dLastValue
*
(
primaryKey
[
i
]
-
pInfo
->
lastKey
);
}
else
{
pInfo
->
iOutput
+=
pInfo
->
iLastValue
*
(
primaryKey
[
i
]
-
pInfo
->
lastKey
);
}
pInfo
->
lastKey
=
primaryKey
[
i
];
setTWALastVal
(
pCtx
,
data
,
i
,
pInfo
);
for
(
++
i
;
i
<
pCtx
->
size
;
i
++
)
{
if
(
pCtx
->
hasNull
&&
isNull
((
char
*
)
data
+
pCtx
->
inputBytes
*
i
,
pCtx
->
inputType
))
{
continue
;
}
notNullElems
++
;
if
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_FLOAT
||
pCtx
->
inputType
==
TSDB_DATA_TYPE_DOUBLE
)
{
pInfo
->
dOutput
+=
pInfo
->
dLastValue
*
(
primaryKey
[
i
]
-
pInfo
->
lastKey
);
}
else
{
pInfo
->
iOutput
+=
pInfo
->
iLastValue
*
(
primaryKey
[
i
]
-
pInfo
->
lastKey
);
}
pInfo
->
lastKey
=
primaryKey
[
i
];
setTWALastVal
(
pCtx
,
data
,
i
,
pInfo
);
}
SET_VAL
(
pCtx
,
notNullElems
,
1
);
SET_VAL
(
pCtx
,
notNullElems
,
1
);
if
(
notNullElems
>
0
)
{
if
(
notNullElems
>
0
)
{
...
@@ -3721,8 +3783,6 @@ static void twa_function(SQLFunctionCtx *pCtx) {
...
@@ -3721,8 +3783,6 @@ static void twa_function(SQLFunctionCtx *pCtx) {
if
(
pCtx
->
stableQuery
)
{
if
(
pCtx
->
stableQuery
)
{
memcpy
(
pCtx
->
aOutputBuf
,
pInfo
,
sizeof
(
STwaInfo
));
memcpy
(
pCtx
->
aOutputBuf
,
pInfo
,
sizeof
(
STwaInfo
));
}
}
// pCtx->numOfIteratedElems += notNullElems;
}
}
static
void
twa_function_f
(
SQLFunctionCtx
*
pCtx
,
int32_t
index
)
{
static
void
twa_function_f
(
SQLFunctionCtx
*
pCtx
,
int32_t
index
)
{
...
@@ -3730,35 +3790,12 @@ static void twa_function_f(SQLFunctionCtx *pCtx, int32_t index) {
...
@@ -3730,35 +3790,12 @@ static void twa_function_f(SQLFunctionCtx *pCtx, int32_t index) {
if
(
pCtx
->
hasNull
&&
isNull
(
pData
,
pCtx
->
inputType
))
{
if
(
pCtx
->
hasNull
&&
isNull
(
pData
,
pCtx
->
inputType
))
{
return
;
return
;
}
}
SET_VAL
(
pCtx
,
1
,
1
);
int32_t
notNullElems
=
twa_function_impl
(
pCtx
,
index
,
1
);
SET_VAL
(
pCtx
,
notNullElems
,
1
);
TSKEY
*
primaryKey
=
pCtx
->
ptsList
;
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STwaInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
if
(
pInfo
->
lastKey
==
INT64_MIN
)
{
pInfo
->
lastKey
=
pCtx
->
nStartQueryTimestamp
;
setTWALastVal
(
pCtx
,
pData
,
0
,
pInfo
);
pInfo
->
hasResult
=
DATA_SET_FLAG
;
}
if
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_FLOAT
||
pCtx
->
inputType
==
TSDB_DATA_TYPE_DOUBLE
)
{
pInfo
->
dOutput
+=
pInfo
->
dLastValue
*
(
primaryKey
[
index
]
-
pInfo
->
lastKey
);
}
else
{
pInfo
->
iOutput
+=
pInfo
->
iLastValue
*
(
primaryKey
[
index
]
-
pInfo
->
lastKey
);
}
// record the last key/value
pInfo
->
lastKey
=
primaryKey
[
index
];
setTWALastVal
(
pCtx
,
pData
,
0
,
pInfo
);
// pCtx->numOfIteratedElems += 1;
pResInfo
->
hasResult
=
DATA_SET_FLAG
;
if
(
pCtx
->
stableQuery
)
{
if
(
pCtx
->
stableQuery
)
{
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
memcpy
(
pCtx
->
aOutputBuf
,
GET_ROWCELL_INTERBUF
(
pResInfo
),
sizeof
(
STwaInfo
));
memcpy
(
pCtx
->
aOutputBuf
,
GET_ROWCELL_INTERBUF
(
pResInfo
),
sizeof
(
STwaInfo
));
}
}
}
}
...
@@ -3778,16 +3815,10 @@ static void twa_func_merge(SQLFunctionCtx *pCtx) {
...
@@ -3778,16 +3815,10 @@ static void twa_func_merge(SQLFunctionCtx *pCtx) {
}
}
numOfNotNull
++
;
numOfNotNull
++
;
if
(
pCtx
->
inputType
>=
TSDB_DATA_TYPE_TINYINT
&&
pCtx
->
inputType
<=
TSDB_DATA_TYPE_BIGINT
)
{
pBuf
->
dOutput
+=
pInput
->
dOutput
;
pBuf
->
iOutput
+=
pInput
->
iOutput
;
}
else
{
pBuf
->
win
=
pInput
->
win
;
pBuf
->
dOutput
+=
pInput
->
dOutput
;
}
pBuf
->
SKey
=
pInput
->
SKey
;
pBuf
->
EKey
=
pInput
->
EKey
;
pBuf
->
lastKey
=
pInput
->
lastKey
;
pBuf
->
lastKey
=
pInput
->
lastKey
;
pBuf
->
iLastValue
=
pInput
->
iLastValue
;
}
}
SET_VAL
(
pCtx
,
numOfNotNull
,
1
);
SET_VAL
(
pCtx
,
numOfNotNull
,
1
);
...
@@ -3814,21 +3845,17 @@ void twa_function_finalizer(SQLFunctionCtx *pCtx) {
...
@@ -3814,21 +3845,17 @@ void twa_function_finalizer(SQLFunctionCtx *pCtx) {
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STwaInfo
*
pInfo
=
(
STwaInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
STwaInfo
*
pInfo
=
(
STwaInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
assert
(
pInfo
->
EKey
>
=
pInfo
->
lastKey
&&
pInfo
->
hasResult
==
pResInfo
->
hasResult
);
assert
(
pInfo
->
win
.
ekey
=
=
pInfo
->
lastKey
&&
pInfo
->
hasResult
==
pResInfo
->
hasResult
);
if
(
pInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
if
(
pInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
setNull
(
pCtx
->
aOutputBuf
,
TSDB_DATA_TYPE_DOUBLE
,
sizeof
(
double
));
setNull
(
pCtx
->
aOutputBuf
,
TSDB_DATA_TYPE_DOUBLE
,
sizeof
(
double
));
return
;
return
;
}
}
if
(
pInfo
->
SKey
==
pInfo
->
EKey
)
{
if
(
pInfo
->
win
.
ekey
==
pInfo
->
win
.
skey
)
{
*
(
double
*
)
pCtx
->
aOutputBuf
=
0
;
*
(
double
*
)
pCtx
->
aOutputBuf
=
pInfo
->
lastValue
;
}
else
if
(
pInfo
->
type
>=
TSDB_DATA_TYPE_TINYINT
&&
pInfo
->
type
<=
TSDB_DATA_TYPE_BIGINT
)
{
pInfo
->
iOutput
+=
pInfo
->
iLastValue
*
(
pInfo
->
EKey
-
pInfo
->
lastKey
);
*
(
double
*
)
pCtx
->
aOutputBuf
=
pInfo
->
iOutput
/
(
double
)(
pInfo
->
EKey
-
pInfo
->
SKey
);
}
else
{
}
else
{
pInfo
->
dOutput
+=
pInfo
->
dLastValue
*
(
pInfo
->
EKey
-
pInfo
->
lastKey
);
*
(
double
*
)
pCtx
->
aOutputBuf
=
pInfo
->
dOutput
/
(
pInfo
->
win
.
ekey
-
pInfo
->
win
.
skey
);
*
(
double
*
)
pCtx
->
aOutputBuf
=
pInfo
->
dOutput
/
(
pInfo
->
EKey
-
pInfo
->
SKey
);
}
}
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
1
;
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
1
;
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
88c11ce7
...
@@ -198,6 +198,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
...
@@ -198,6 +198,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
if
(
numOfFlush
==
0
||
numOfBuffer
==
0
)
{
if
(
numOfFlush
==
0
||
numOfBuffer
==
0
)
{
tscLocalReducerEnvDestroy
(
pMemBuffer
,
pDesc
,
finalmodel
,
pFFModel
,
numOfBuffer
);
tscLocalReducerEnvDestroy
(
pMemBuffer
,
pDesc
,
finalmodel
,
pFFModel
,
numOfBuffer
);
pCmd
->
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
// no result, set the result empty
tscDebug
(
"%p retrieved no data"
,
pSql
);
tscDebug
(
"%p retrieved no data"
,
pSql
);
return
;
return
;
}
}
...
@@ -330,22 +331,19 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
...
@@ -330,22 +331,19 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pReducer
->
nResultBufSize
=
pMemBuffer
[
0
]
->
pageSize
*
16
;
pReducer
->
nResultBufSize
=
pMemBuffer
[
0
]
->
pageSize
*
16
;
pReducer
->
pResultBuf
=
(
tFilePage
*
)
calloc
(
1
,
pReducer
->
nResultBufSize
+
sizeof
(
tFilePage
));
pReducer
->
pResultBuf
=
(
tFilePage
*
)
calloc
(
1
,
pReducer
->
nResultBufSize
+
sizeof
(
tFilePage
));
pReducer
->
finalRowSize
=
tscGetResRowLength
(
pQueryInfo
->
exprList
);
pReducer
->
resColModel
=
finalmodel
;
pReducer
->
resColModel
=
finalmodel
;
pReducer
->
resColModel
->
capacity
=
pReducer
->
nResultBufSize
;
pReducer
->
resColModel
->
capacity
=
pReducer
->
nResultBufSize
;
pReducer
->
finalModel
=
pFFModel
;
pReducer
->
finalModel
=
pFFModel
;
assert
(
pReducer
->
finalRowSize
>
0
);
if
(
finalmodel
->
rowSize
>
0
)
{
if
(
pReducer
->
finalRowSize
>
0
)
{
pReducer
->
resColModel
->
capacity
/=
finalmodel
->
rowSize
;
pReducer
->
resColModel
->
capacity
/=
pReducer
->
finalRowSize
;
}
}
assert
(
pReducer
->
finalRowSize
<=
pReducer
->
rowSize
);
assert
(
finalmodel
->
rowSize
>
0
&&
finalmodel
->
rowSize
<=
pReducer
->
rowSize
);
pReducer
->
pFinalRes
=
calloc
(
1
,
pReducer
->
rowSize
*
pReducer
->
resColModel
->
capacity
);
pReducer
->
pFinalRes
=
calloc
(
1
,
pReducer
->
rowSize
*
pReducer
->
resColModel
->
capacity
);
if
(
pReducer
->
pTempBuffer
==
NULL
||
pReducer
->
discardData
==
NULL
||
pReducer
->
pResultBuf
==
NULL
||
if
(
pReducer
->
pTempBuffer
==
NULL
||
pReducer
->
discardData
==
NULL
||
pReducer
->
pResultBuf
==
NULL
||
/*pReducer->pBufForInterpo == NULL || */
pReducer
->
pFinalRes
==
NULL
||
pReducer
->
prevRowOfInput
==
NULL
)
{
pReducer
->
pFinalRes
==
NULL
||
pReducer
->
prevRowOfInput
==
NULL
)
{
tfree
(
pReducer
->
pTempBuffer
);
tfree
(
pReducer
->
pTempBuffer
);
tfree
(
pReducer
->
discardData
);
tfree
(
pReducer
->
discardData
);
tfree
(
pReducer
->
pResultBuf
);
tfree
(
pReducer
->
pResultBuf
);
...
@@ -920,7 +918,7 @@ static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer,
...
@@ -920,7 +918,7 @@ static void genFinalResWithoutFill(SSqlRes* pRes, SLocalReducer *pLocalReducer,
savePrevRecordAndSetupFillInfo
(
pLocalReducer
,
pQueryInfo
,
pLocalReducer
->
pFillInfo
);
savePrevRecordAndSetupFillInfo
(
pLocalReducer
,
pQueryInfo
,
pLocalReducer
->
pFillInfo
);
}
}
memcpy
(
pRes
->
data
,
pBeforeFillData
->
data
,
(
size_t
)(
pRes
->
numOfRows
*
pLocalReducer
->
final
R
owSize
));
memcpy
(
pRes
->
data
,
pBeforeFillData
->
data
,
(
size_t
)(
pRes
->
numOfRows
*
pLocalReducer
->
final
Model
->
r
owSize
));
pRes
->
numOfClauseTotal
+=
pRes
->
numOfRows
;
pRes
->
numOfClauseTotal
+=
pRes
->
numOfRows
;
pBeforeFillData
->
num
=
0
;
pBeforeFillData
->
num
=
0
;
...
@@ -1256,7 +1254,7 @@ bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCur
...
@@ -1256,7 +1254,7 @@ bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCur
tColModelCompact
(
pModel
,
pResBuf
,
pModel
->
capacity
);
tColModelCompact
(
pModel
,
pResBuf
,
pModel
->
capacity
);
if
(
tscIsSecondStageQuery
(
pQueryInfo
))
{
if
(
tscIsSecondStageQuery
(
pQueryInfo
))
{
pLocalReducer
->
finalRowSize
=
doArithmeticCalculate
(
pQueryInfo
,
pResBuf
,
pModel
->
rowSize
,
pLocalReducer
->
finalR
owSize
);
doArithmeticCalculate
(
pQueryInfo
,
pResBuf
,
pModel
->
rowSize
,
pLocalReducer
->
finalModel
->
r
owSize
);
}
}
#ifdef _DEBUG_VIEW
#ifdef _DEBUG_VIEW
...
@@ -1627,7 +1625,8 @@ void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen)
...
@@ -1627,7 +1625,8 @@ void tscInitResObjForLocalQuery(SSqlObj *pObj, int32_t numOfRes, int32_t rowLen)
}
}
int32_t
doArithmeticCalculate
(
SQueryInfo
*
pQueryInfo
,
tFilePage
*
pOutput
,
int32_t
rowSize
,
int32_t
finalRowSize
)
{
int32_t
doArithmeticCalculate
(
SQueryInfo
*
pQueryInfo
,
tFilePage
*
pOutput
,
int32_t
rowSize
,
int32_t
finalRowSize
)
{
char
*
pbuf
=
calloc
(
1
,
pOutput
->
num
*
rowSize
);
int32_t
maxRowSize
=
MAX
(
rowSize
,
finalRowSize
);
char
*
pbuf
=
calloc
(
1
,
pOutput
->
num
*
maxRowSize
);
size_t
size
=
tscNumOfFields
(
pQueryInfo
);
size_t
size
=
tscNumOfFields
(
pQueryInfo
);
SArithmeticSupport
arithSup
=
{
0
};
SArithmeticSupport
arithSup
=
{
0
};
...
@@ -1660,7 +1659,6 @@ int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_
...
@@ -1660,7 +1659,6 @@ int32_t doArithmeticCalculate(SQueryInfo* pQueryInfo, tFilePage* pOutput, int32_
offset
+=
pSup
->
field
.
bytes
;
offset
+=
pSup
->
field
.
bytes
;
}
}
assert
(
finalRowSize
<=
rowSize
);
memcpy
(
pOutput
->
data
,
pbuf
,
pOutput
->
num
*
offset
);
memcpy
(
pOutput
->
data
,
pbuf
,
pOutput
->
num
*
offset
);
tfree
(
pbuf
);
tfree
(
pbuf
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
88c11ce7
...
@@ -4248,7 +4248,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
...
@@ -4248,7 +4248,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
tExprTreeDestroy
(
&
p
,
NULL
);
tExprTreeDestroy
(
&
p
,
NULL
);
taosArrayDestroy
(
colList
);
taosArrayDestroy
(
colList
);
if
(
taosArrayGetSize
(
pQueryInfo
->
tagCond
.
pCond
)
>
0
&&
!
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
if
(
pQueryInfo
->
tagCond
.
pCond
!=
NULL
&&
taosArrayGetSize
(
pQueryInfo
->
tagCond
.
pCond
)
>
0
&&
!
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"filter on tag not supported for normal table"
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"filter on tag not supported for normal table"
);
}
}
}
}
...
@@ -4256,6 +4256,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
...
@@ -4256,6 +4256,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
pCondExpr
->
pTagCond
=
NULL
;
pCondExpr
->
pTagCond
=
NULL
;
return
ret
;
return
ret
;
}
}
int32_t
parseWhereClause
(
SQueryInfo
*
pQueryInfo
,
tSQLExpr
**
pExpr
,
SSqlObj
*
pSql
)
{
int32_t
parseWhereClause
(
SQueryInfo
*
pQueryInfo
,
tSQLExpr
**
pExpr
,
SSqlObj
*
pSql
)
{
if
(
pExpr
==
NULL
)
{
if
(
pExpr
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -6648,7 +6649,7 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pS
...
@@ -6648,7 +6649,7 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pS
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
else
{
}
else
{
return
TSDB_CODE_TSC_INVALID_SQL
;
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"not support filter expression"
)
;
}
}
}
else
{
}
else
{
...
...
src/common/src/tglobal.c
浏览文件 @
88c11ce7
...
@@ -200,7 +200,7 @@ int32_t tsNumOfLogLines = 10000000;
...
@@ -200,7 +200,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/dnode/src/dnodeMain.c
浏览文件 @
88c11ce7
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "tutil.h"
#include "tutil.h"
#include "tconfig.h"
#include "tconfig.h"
#include "tglobal.h"
#include "tglobal.h"
#include "tfile.h"
#include "twal.h"
#include "twal.h"
#include "trpc.h"
#include "trpc.h"
#include "dnode.h"
#include "dnode.h"
...
@@ -55,6 +56,7 @@ typedef struct {
...
@@ -55,6 +56,7 @@ typedef struct {
}
SDnodeComponent
;
}
SDnodeComponent
;
static
const
SDnodeComponent
tsDnodeComponents
[]
=
{
static
const
SDnodeComponent
tsDnodeComponents
[]
=
{
{
"tfile"
,
tfInit
,
tfCleanup
},
{
"rpc"
,
rpcInit
,
rpcCleanup
},
{
"rpc"
,
rpcInit
,
rpcCleanup
},
{
"storage"
,
dnodeInitStorage
,
dnodeCleanupStorage
},
{
"storage"
,
dnodeInitStorage
,
dnodeCleanupStorage
},
{
"dnodecfg"
,
dnodeInitCfg
,
dnodeCleanupCfg
},
{
"dnodecfg"
,
dnodeInitCfg
,
dnodeCleanupCfg
},
...
...
src/dnode/src/dnodeMgmt.c
浏览文件 @
88c11ce7
...
@@ -444,12 +444,12 @@ static int32_t dnodeProcessCreateMnodeMsg(SRpcMsg *pMsg) {
...
@@ -444,12 +444,12 @@ static int32_t dnodeProcessCreateMnodeMsg(SRpcMsg *pMsg) {
SCreateMnodeMsg
*
pCfg
=
pMsg
->
pCont
;
SCreateMnodeMsg
*
pCfg
=
pMsg
->
pCont
;
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
if
(
pCfg
->
dnodeId
!=
dnodeGetDnodeId
())
{
if
(
pCfg
->
dnodeId
!=
dnodeGetDnodeId
())
{
d
Error
(
"dnodeId:%d, in create mnode msg is not equal with saved dnodeId:%d"
,
pCfg
->
dnodeId
,
dnodeGetDnodeId
());
d
Debug
(
"dnodeId:%d, in create mnode msg is not equal with saved dnodeId:%d"
,
pCfg
->
dnodeId
,
dnodeGetDnodeId
());
return
TSDB_CODE_MND_DNODE_ID_NOT_CONFIGURED
;
return
TSDB_CODE_MND_DNODE_ID_NOT_CONFIGURED
;
}
}
if
(
strcmp
(
pCfg
->
dnodeEp
,
tsLocalEp
)
!=
0
)
{
if
(
strcmp
(
pCfg
->
dnodeEp
,
tsLocalEp
)
!=
0
)
{
d
Error
(
"dnodeEp:%s, in create mnode msg is not equal with saved dnodeEp:%s"
,
pCfg
->
dnodeEp
,
tsLocalEp
);
d
Debug
(
"dnodeEp:%s, in create mnode msg is not equal with saved dnodeEp:%s"
,
pCfg
->
dnodeEp
,
tsLocalEp
);
return
TSDB_CODE_MND_DNODE_EP_NOT_CONFIGURED
;
return
TSDB_CODE_MND_DNODE_EP_NOT_CONFIGURED
;
}
}
...
...
src/inc/taoserror.h
浏览文件 @
88c11ce7
...
@@ -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"
)
...
@@ -390,7 +394,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_CONV_SRC_BAD_SEQ, 0, 0x2113, "src bad se
...
@@ -390,7 +394,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_ODBC_CONV_SRC_BAD_SEQ, 0, 0x2113, "src bad se
TAOS_DEFINE_ERROR
(
TSDB_CODE_ODBC_CONV_SRC_INCOMPLETE
,
0
,
0x2114
,
"src incomplete"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_ODBC_CONV_SRC_INCOMPLETE
,
0
,
0x2114
,
"src incomplete"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_ODBC_CONV_SRC_GENERAL
,
0
,
0x2115
,
"src general"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_ODBC_CONV_SRC_GENERAL
,
0
,
0x2115
,
"src general"
)
#ifdef TAOS_ERROR_C
#ifdef TAOS_ERROR_C
};
};
#endif
#endif
...
...
src/inc/tsync.h
浏览文件 @
88c11ce7
...
@@ -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/inc/twal.h
浏览文件 @
88c11ce7
...
@@ -51,9 +51,8 @@ typedef struct {
...
@@ -51,9 +51,8 @@ typedef struct {
typedef
void
*
twalh
;
// WAL HANDLE
typedef
void
*
twalh
;
// WAL HANDLE
typedef
int32_t
FWalWrite
(
void
*
ahandle
,
void
*
pHead
,
int32_t
qtype
,
void
*
pMsg
);
typedef
int32_t
FWalWrite
(
void
*
ahandle
,
void
*
pHead
,
int32_t
qtype
,
void
*
pMsg
);
int32_t
walInit
();
int32_t
walInit
();
void
walCleanUp
();
void
walCleanUp
();
twalh
walOpen
(
char
*
path
,
SWalCfg
*
pCfg
);
twalh
walOpen
(
char
*
path
,
SWalCfg
*
pCfg
);
int32_t
walAlter
(
twalh
pWal
,
SWalCfg
*
pCfg
);
int32_t
walAlter
(
twalh
pWal
,
SWalCfg
*
pCfg
);
void
walStop
(
twalh
);
void
walStop
(
twalh
);
...
...
src/mnode/inc/mnodeAcct.h
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -79,10 +79,13 @@ typedef struct {
...
@@ -79,10 +79,13 @@ typedef struct {
int32_t
(
*
fpRestored
)();
int32_t
(
*
fpRestored
)();
}
SSdbTableDesc
;
}
SSdbTableDesc
;
int32_t
sdbInitRef
();
void
sdbCleanUpRef
();
int32_t
sdbInit
();
int32_t
sdbInit
();
void
sdbCleanUp
();
void
sdbCleanUp
();
void
*
sdbOpenTable
(
SSdbTableDesc
*
desc
);
int64_t
sdbOpenTable
(
SSdbTableDesc
*
desc
);
void
sdbCloseTable
(
void
*
handle
);
void
sdbCloseTable
(
int64_t
rid
);
void
*
sdbGetTableByRid
(
int64_t
rid
);
bool
sdbIsMaster
();
bool
sdbIsMaster
();
bool
sdbIsServing
();
bool
sdbIsServing
();
void
sdbUpdateMnodeRoles
();
void
sdbUpdateMnodeRoles
();
...
@@ -92,9 +95,9 @@ int32_t sdbDeleteRow(SSdbRow *pRow);
...
@@ -92,9 +95,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
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include "mnodeUser.h"
#include "mnodeUser.h"
#include "mnodeVgroup.h"
#include "mnodeVgroup.h"
int64_t
tsAcctRid
=
-
1
;
void
*
tsAcctSdb
=
NULL
;
void
*
tsAcctSdb
=
NULL
;
static
int32_t
tsAcctUpdateSize
;
static
int32_t
tsAcctUpdateSize
;
static
int32_t
mnodeCreateRootAcct
();
static
int32_t
mnodeCreateRootAcct
();
...
@@ -114,7 +115,8 @@ int32_t mnodeInitAccts() {
...
@@ -114,7 +115,8 @@ int32_t mnodeInitAccts() {
.
fpRestored
=
mnodeAcctActionRestored
.
fpRestored
=
mnodeAcctActionRestored
};
};
tsAcctSdb
=
sdbOpenTable
(
&
desc
);
tsAcctRid
=
sdbOpenTable
(
&
desc
);
tsAcctSdb
=
sdbGetTableByRid
(
tsAcctRid
);
if
(
tsAcctSdb
==
NULL
)
{
if
(
tsAcctSdb
==
NULL
)
{
mError
(
"table:%s, failed to create hash"
,
desc
.
name
);
mError
(
"table:%s, failed to create hash"
,
desc
.
name
);
return
-
1
;
return
-
1
;
...
@@ -126,7 +128,7 @@ int32_t mnodeInitAccts() {
...
@@ -126,7 +128,7 @@ int32_t mnodeInitAccts() {
void
mnodeCleanupAccts
()
{
void
mnodeCleanupAccts
()
{
acctCleanUp
();
acctCleanUp
();
sdbCloseTable
(
tsAcct
Sdb
);
sdbCloseTable
(
tsAcct
Rid
);
tsAcctSdb
=
NULL
;
tsAcctSdb
=
NULL
;
}
}
...
@@ -144,7 +146,6 @@ void mnodeGetStatOfAllAcct(SAcctInfo* pAcctInfo) {
...
@@ -144,7 +146,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 +159,6 @@ void mnodeGetStatOfAllAcct(SAcctInfo* pAcctInfo) {
...
@@ -158,7 +159,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 +169,10 @@ void *mnodeGetNextAcct(void *pIter, SAcctObj **pAcct) {
...
@@ -169,6 +169,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
浏览文件 @
88c11ce7
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include "mnodeShow.h"
#include "mnodeShow.h"
#include "tglobal.h"
#include "tglobal.h"
int64_t
tsClusterRid
=
-
1
;
static
void
*
tsClusterSdb
=
NULL
;
static
void
*
tsClusterSdb
=
NULL
;
static
int32_t
tsClusterUpdateSize
;
static
int32_t
tsClusterUpdateSize
;
static
char
tsClusterId
[
TSDB_CLUSTER_ID_LEN
];
static
char
tsClusterId
[
TSDB_CLUSTER_ID_LEN
];
...
@@ -31,6 +32,7 @@ static int32_t mnodeCreateCluster();
...
@@ -31,6 +32,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
);
...
@@ -100,21 +102,23 @@ int32_t mnodeInitCluster() {
...
@@ -100,21 +102,23 @@ int32_t mnodeInitCluster() {
.
fpRestored
=
mnodeClusterActionRestored
.
fpRestored
=
mnodeClusterActionRestored
};
};
tsClusterSdb
=
sdbOpenTable
(
&
desc
);
tsClusterRid
=
sdbOpenTable
(
&
desc
);
tsClusterSdb
=
sdbGetTableByRid
(
tsClusterRid
);
if
(
tsClusterSdb
==
NULL
)
{
if
(
tsClusterSdb
==
NULL
)
{
mError
(
"table:%s,
failed to create hash"
,
desc
.
name
);
mError
(
"table:%s,
rid:%"
PRId64
", failed to create hash"
,
desc
.
name
,
tsClusterRid
);
return
-
1
;
return
-
1
;
}
}
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
;
}
}
void
mnodeCleanupCluster
()
{
void
mnodeCleanupCluster
()
{
sdbCloseTable
(
tsCluster
Sdb
);
sdbCloseTable
(
tsCluster
Rid
);
tsClusterSdb
=
NULL
;
tsClusterSdb
=
NULL
;
}
}
...
@@ -122,6 +126,10 @@ void *mnodeGetNextCluster(void *pIter, SClusterObj **pCluster) {
...
@@ -122,6 +126,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 +175,7 @@ void mnodeUpdateClusterId() {
...
@@ -167,7 +175,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
浏览文件 @
88c11ce7
...
@@ -38,6 +38,7 @@
...
@@ -38,6 +38,7 @@
#include "mnodeVgroup.h"
#include "mnodeVgroup.h"
#define VG_LIST_SIZE 8
#define VG_LIST_SIZE 8
int64_t
tsDbRid
=
-
1
;
static
void
*
tsDbSdb
=
NULL
;
static
void
*
tsDbSdb
=
NULL
;
static
int32_t
tsDbUpdateSize
;
static
int32_t
tsDbUpdateSize
;
...
@@ -160,7 +161,8 @@ int32_t mnodeInitDbs() {
...
@@ -160,7 +161,8 @@ int32_t mnodeInitDbs() {
.
fpRestored
=
mnodeDbActionRestored
.
fpRestored
=
mnodeDbActionRestored
};
};
tsDbSdb
=
sdbOpenTable
(
&
desc
);
tsDbRid
=
sdbOpenTable
(
&
desc
);
tsDbSdb
=
sdbGetTableByRid
(
tsDbRid
);
if
(
tsDbSdb
==
NULL
)
{
if
(
tsDbSdb
==
NULL
)
{
mError
(
"failed to init db data"
);
mError
(
"failed to init db data"
);
return
-
1
;
return
-
1
;
...
@@ -171,6 +173,7 @@ int32_t mnodeInitDbs() {
...
@@ -171,6 +173,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 +183,10 @@ void *mnodeGetNextDb(void *pIter, SDbObj **pDb) {
...
@@ -180,6 +183,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
);
}
}
...
@@ -491,7 +498,7 @@ void mnodeRemoveVgroupFromDb(SVgObj *pVgroup) {
...
@@ -491,7 +498,7 @@ void mnodeRemoveVgroupFromDb(SVgObj *pVgroup) {
}
}
void
mnodeCleanupDbs
()
{
void
mnodeCleanupDbs
()
{
sdbCloseTable
(
tsDb
Sdb
);
sdbCloseTable
(
tsDb
Rid
);
tsDbSdb
=
NULL
;
tsDbSdb
=
NULL
;
}
}
...
@@ -986,8 +993,8 @@ static int32_t mnodeAlterDbCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -986,8 +993,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 +1002,6 @@ static int32_t mnodeAlterDbCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -995,7 +1002,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 +1152,5 @@ void mnodeDropAllDbs(SAcctObj *pAcct) {
...
@@ -1146,7 +1152,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
浏览文件 @
88c11ce7
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
#include "mnodeCluster.h"
#include "mnodeCluster.h"
int32_t
tsAccessSquence
=
0
;
int32_t
tsAccessSquence
=
0
;
int64_t
tsDnodeRid
=
-
1
;
static
void
*
tsDnodeSdb
=
NULL
;
static
void
*
tsDnodeSdb
=
NULL
;
static
int32_t
tsDnodeUpdateSize
=
0
;
static
int32_t
tsDnodeUpdateSize
=
0
;
extern
void
*
tsMnodeSdb
;
extern
void
*
tsMnodeSdb
;
...
@@ -187,7 +188,8 @@ int32_t mnodeInitDnodes() {
...
@@ -187,7 +188,8 @@ int32_t mnodeInitDnodes() {
.
fpRestored
=
mnodeDnodeActionRestored
.
fpRestored
=
mnodeDnodeActionRestored
};
};
tsDnodeSdb
=
sdbOpenTable
(
&
desc
);
tsDnodeRid
=
sdbOpenTable
(
&
desc
);
tsDnodeSdb
=
sdbGetTableByRid
(
tsDnodeRid
);
if
(
tsDnodeSdb
==
NULL
)
{
if
(
tsDnodeSdb
==
NULL
)
{
mError
(
"failed to init dnodes data"
);
mError
(
"failed to init dnodes data"
);
return
-
1
;
return
-
1
;
...
@@ -206,13 +208,14 @@ int32_t mnodeInitDnodes() {
...
@@ -206,13 +208,14 @@ 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
;
}
}
void
mnodeCleanupDnodes
()
{
void
mnodeCleanupDnodes
()
{
sdbCloseTable
(
tsDnode
Sdb
);
sdbCloseTable
(
tsDnode
Rid
);
pthread_mutex_destroy
(
&
tsDnodeEpsMutex
);
pthread_mutex_destroy
(
&
tsDnodeEpsMutex
);
free
(
tsDnodeEps
);
free
(
tsDnodeEps
);
tsDnodeEps
=
NULL
;
tsDnodeEps
=
NULL
;
...
@@ -223,6 +226,10 @@ void *mnodeGetNextDnode(void *pIter, SDnodeObj **pDnode) {
...
@@ -223,6 +226,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 +248,6 @@ int32_t mnodeGetOnlinDnodesCpuCoreNum() {
...
@@ -241,8 +248,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 +264,6 @@ int32_t mnodeGetOnlineDnodesNum() {
...
@@ -259,8 +264,6 @@ int32_t mnodeGetOnlineDnodesNum() {
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
}
}
sdbFreeIter
(
pIter
);
return
onlineDnodes
;
return
onlineDnodes
;
}
}
...
@@ -276,13 +279,12 @@ void *mnodeGetDnodeByEp(char *ep) {
...
@@ -276,13 +279,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 +466,10 @@ static void mnodeUpdateDnodeEps() {
...
@@ -464,7 +466,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 +479,6 @@ static void mnodeUpdateDnodeEps() {
...
@@ -474,7 +479,6 @@ static void mnodeUpdateDnodeEps() {
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
}
}
sdbFreeIter
(
pIter
);
pthread_mutex_unlock
(
&
tsDnodeEpsMutex
);
pthread_mutex_unlock
(
&
tsDnodeEpsMutex
);
}
}
...
@@ -1100,7 +1104,7 @@ static int32_t mnodeGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
...
@@ -1100,7 +1104,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 +1152,6 @@ static int32_t mnodeRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, vo
...
@@ -1148,7 +1152,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 +1220,6 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
...
@@ -1217,8 +1220,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/mnodeMain.c
浏览文件 @
88c11ce7
...
@@ -47,6 +47,7 @@ void *tsMnodeTmr = NULL;
...
@@ -47,6 +47,7 @@ void *tsMnodeTmr = NULL;
static
bool
tsMgmtIsRunning
=
false
;
static
bool
tsMgmtIsRunning
=
false
;
static
const
SMnodeComponent
tsMnodeComponents
[]
=
{
static
const
SMnodeComponent
tsMnodeComponents
[]
=
{
{
"sdbref"
,
sdbInitRef
,
sdbCleanUpRef
},
{
"profile"
,
mnodeInitProfile
,
mnodeCleanupProfile
},
{
"profile"
,
mnodeInitProfile
,
mnodeCleanupProfile
},
{
"cluster"
,
mnodeInitCluster
,
mnodeCleanupCluster
},
{
"cluster"
,
mnodeInitCluster
,
mnodeCleanupCluster
},
{
"accts"
,
mnodeInitAccts
,
mnodeCleanupAccts
},
{
"accts"
,
mnodeInitAccts
,
mnodeCleanupAccts
},
...
...
src/mnode/src/mnodeMnode.c
浏览文件 @
88c11ce7
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "mnodeUser.h"
#include "mnodeUser.h"
#include "mnodeVgroup.h"
#include "mnodeVgroup.h"
int64_t
tsMnodeRid
=
-
1
;
static
void
*
tsMnodeSdb
=
NULL
;
static
void
*
tsMnodeSdb
=
NULL
;
static
int32_t
tsMnodeUpdateSize
=
0
;
static
int32_t
tsMnodeUpdateSize
=
0
;
static
SRpcEpSet
tsMnodeEpSetForShell
;
static
SRpcEpSet
tsMnodeEpSetForShell
;
...
@@ -123,7 +124,7 @@ static int32_t mnodeMnodeActionRestored() {
...
@@ -123,7 +124,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
();
...
@@ -153,7 +154,8 @@ int32_t mnodeInitMnodes() {
...
@@ -153,7 +154,8 @@ int32_t mnodeInitMnodes() {
.
fpRestored
=
mnodeMnodeActionRestored
.
fpRestored
=
mnodeMnodeActionRestored
};
};
tsMnodeSdb
=
sdbOpenTable
(
&
desc
);
tsMnodeRid
=
sdbOpenTable
(
&
desc
);
tsMnodeSdb
=
sdbGetTableByRid
(
tsMnodeRid
);
if
(
tsMnodeSdb
==
NULL
)
{
if
(
tsMnodeSdb
==
NULL
)
{
mError
(
"failed to init mnodes data"
);
mError
(
"failed to init mnodes data"
);
return
-
1
;
return
-
1
;
...
@@ -161,13 +163,14 @@ int32_t mnodeInitMnodes() {
...
@@ -161,13 +163,14 @@ 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
;
}
}
void
mnodeCleanupMnodes
()
{
void
mnodeCleanupMnodes
()
{
sdbCloseTable
(
tsMnode
Sdb
);
sdbCloseTable
(
tsMnode
Rid
);
tsMnodeSdb
=
NULL
;
tsMnodeSdb
=
NULL
;
mnodeMnodeDestroyLock
();
mnodeMnodeDestroyLock
();
}
}
...
@@ -192,6 +195,10 @@ void *mnodeGetNextMnode(void *pIter, SMnodeObj **pMnode) {
...
@@ -192,6 +195,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 +246,6 @@ void mnodeUpdateMnodeEpSet() {
...
@@ -239,8 +246,6 @@ void mnodeUpdateMnodeEpSet() {
tsMnodeEpSetForShell
.
numOfEps
=
index
;
tsMnodeEpSetForShell
.
numOfEps
=
index
;
tsMnodeEpSetForPeer
.
numOfEps
=
index
;
tsMnodeEpSetForPeer
.
numOfEps
=
index
;
sdbFreeIter
(
pIter
);
mnodeMnodeUnLock
();
mnodeMnodeUnLock
();
}
}
...
@@ -248,12 +253,30 @@ void mnodeGetMnodeEpSetForPeer(SRpcEpSet *epSet) {
...
@@ -248,12 +253,30 @@ void mnodeGetMnodeEpSetForPeer(SRpcEpSet *epSet) {
mnodeMnodeRdLock
();
mnodeMnodeRdLock
();
*
epSet
=
tsMnodeEpSetForPeer
;
*
epSet
=
tsMnodeEpSetForPeer
;
mnodeMnodeUnLock
();
mnodeMnodeUnLock
();
for
(
int32_t
i
=
0
;
i
<
epSet
->
numOfEps
;
++
i
)
{
if
(
strcmp
(
epSet
->
fqdn
[
i
],
tsLocalFqdn
)
==
0
&&
htons
(
epSet
->
port
[
i
])
==
tsServerPort
+
TSDB_PORT_DNODEDNODE
)
{
epSet
->
inUse
=
(
i
+
1
)
%
epSet
->
numOfEps
;
mTrace
(
"mnode:%d, for peer ep:%s:%u, set inUse to %d"
,
i
,
epSet
->
fqdn
[
i
],
htons
(
epSet
->
port
[
i
]),
epSet
->
inUse
);
}
else
{
mTrace
(
"mpeer:%d, for peer ep:%s:%u"
,
i
,
epSet
->
fqdn
[
i
],
htons
(
epSet
->
port
[
i
]));
}
}
}
}
void
mnodeGetMnodeEpSetForShell
(
SRpcEpSet
*
epSet
)
{
void
mnodeGetMnodeEpSetForShell
(
SRpcEpSet
*
epSet
)
{
mnodeMnodeRdLock
();
mnodeMnodeRdLock
();
*
epSet
=
tsMnodeEpSetForShell
;
*
epSet
=
tsMnodeEpSetForShell
;
mnodeMnodeUnLock
();
mnodeMnodeUnLock
();
for
(
int32_t
i
=
0
;
i
<
epSet
->
numOfEps
;
++
i
)
{
if
(
strcmp
(
epSet
->
fqdn
[
i
],
tsLocalFqdn
)
==
0
&&
htons
(
epSet
->
port
[
i
])
==
tsServerPort
)
{
epSet
->
inUse
=
(
i
+
1
)
%
epSet
->
numOfEps
;
mTrace
(
"mnode:%d, for shell ep:%s:%u, set inUse to %d"
,
i
,
epSet
->
fqdn
[
i
],
htons
(
epSet
->
port
[
i
]),
epSet
->
inUse
);
}
else
{
mTrace
(
"mnode:%d, for shell ep:%s:%u"
,
i
,
epSet
->
fqdn
[
i
],
htons
(
epSet
->
port
[
i
]));
}
}
}
}
char
*
mnodeGetMnodeMasterEp
()
{
char
*
mnodeGetMnodeMasterEp
()
{
...
...
src/mnode/src/mnodePeer.c
浏览文件 @
88c11ce7
...
@@ -58,16 +58,8 @@ int32_t mnodeProcessPeerReq(SMnodeMsg *pMsg) {
...
@@ -58,16 +58,8 @@ int32_t mnodeProcessPeerReq(SMnodeMsg *pMsg) {
rpcRsp
->
rsp
=
epSet
;
rpcRsp
->
rsp
=
epSet
;
rpcRsp
->
len
=
sizeof
(
SRpcEpSet
);
rpcRsp
->
len
=
sizeof
(
SRpcEpSet
);
mDebug
(
"msg:%p, ahandle:%p type:%s in mpeer queue will be redirected, numOfEps:%d inUse:%d"
,
pMsg
,
mDebug
(
"msg:%p, ahandle:%p type:%s in mpeer queue is redirected, numOfEps:%d inUse:%d"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
->
rpcMsg
.
ahandle
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
],
epSet
->
numOfEps
,
epSet
->
inUse
);
taosMsg
[
pMsg
->
rpcMsg
.
msgType
],
epSet
->
numOfEps
,
epSet
->
inUse
);
for
(
int32_t
i
=
0
;
i
<
epSet
->
numOfEps
;
++
i
)
{
if
(
strcmp
(
epSet
->
fqdn
[
i
],
tsLocalFqdn
)
==
0
&&
htons
(
epSet
->
port
[
i
])
==
tsServerPort
+
TSDB_PORT_DNODEDNODE
)
{
epSet
->
inUse
=
(
i
+
1
)
%
epSet
->
numOfEps
;
mDebug
(
"mpeer:%d ep:%s:%u, set inUse to %d"
,
i
,
epSet
->
fqdn
[
i
],
htons
(
epSet
->
port
[
i
]),
epSet
->
inUse
);
}
else
{
mDebug
(
"mpeer:%d ep:%s:%u"
,
i
,
epSet
->
fqdn
[
i
],
htons
(
epSet
->
port
[
i
]));
}
}
return
TSDB_CODE_RPC_REDIRECT
;
return
TSDB_CODE_RPC_REDIRECT
;
}
}
...
...
src/mnode/src/mnodeProfile.c
浏览文件 @
88c11ce7
...
@@ -34,7 +34,6 @@
...
@@ -34,7 +34,6 @@
#define QUERY_ID_SIZE 20
#define QUERY_ID_SIZE 20
#define QUERY_STREAM_SAVE_SIZE 20
#define QUERY_STREAM_SAVE_SIZE 20
extern
void
*
tsMnodeTmr
;
static
SCacheObj
*
tsMnodeConnCache
=
NULL
;
static
SCacheObj
*
tsMnodeConnCache
=
NULL
;
static
int32_t
tsConnIndex
=
0
;
static
int32_t
tsConnIndex
=
0
;
...
@@ -42,6 +41,7 @@ static int32_t mnodeGetQueryMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC
...
@@ -42,6 +41,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 +52,13 @@ static int32_t mnodeProcessKillConnectionMsg(SMnodeMsg *pMsg);
...
@@ -52,10 +52,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 +140,15 @@ static void mnodeFreeConn(void *data) {
...
@@ -137,21 +140,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 +156,10 @@ static void *mnodeGetNextConn(SHashMutableIterator *pIter, SConnObj **pConn) {
...
@@ -159,6 +156,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/mnodeRead.c
浏览文件 @
88c11ce7
...
@@ -51,21 +51,12 @@ int32_t mnodeProcessRead(SMnodeMsg *pMsg) {
...
@@ -51,21 +51,12 @@ int32_t mnodeProcessRead(SMnodeMsg *pMsg) {
SMnodeRsp
*
rpcRsp
=
&
pMsg
->
rpcRsp
;
SMnodeRsp
*
rpcRsp
=
&
pMsg
->
rpcRsp
;
SRpcEpSet
*
epSet
=
rpcMallocCont
(
sizeof
(
SRpcEpSet
));
SRpcEpSet
*
epSet
=
rpcMallocCont
(
sizeof
(
SRpcEpSet
));
mnodeGetMnodeEpSetForShell
(
epSet
);
mnodeGetMnodeEpSetForShell
(
epSet
);
mDebug
(
"msg:%p, app:%p type:%s in mread queue will be redirected, numOfEps:%d inUse:%d"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
],
epSet
->
numOfEps
,
epSet
->
inUse
);
for
(
int32_t
i
=
0
;
i
<
epSet
->
numOfEps
;
++
i
)
{
if
(
strcmp
(
epSet
->
fqdn
[
i
],
tsLocalFqdn
)
==
0
&&
htons
(
epSet
->
port
[
i
])
==
tsServerPort
)
{
epSet
->
inUse
=
(
i
+
1
)
%
epSet
->
numOfEps
;
mDebug
(
"mnode index:%d ep:%s:%u, set inUse to %d"
,
i
,
epSet
->
fqdn
[
i
],
htons
(
epSet
->
port
[
i
]),
epSet
->
inUse
);
}
else
{
mDebug
(
"mnode index:%d ep:%s:%u"
,
i
,
epSet
->
fqdn
[
i
],
htons
(
epSet
->
port
[
i
]));
}
}
rpcRsp
->
rsp
=
epSet
;
rpcRsp
->
rsp
=
epSet
;
rpcRsp
->
len
=
sizeof
(
SRpcEpSet
);
rpcRsp
->
len
=
sizeof
(
SRpcEpSet
);
mDebug
(
"msg:%p, app:%p type:%s in mread queue is redirected, numOfEps:%d inUse:%d"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
],
epSet
->
numOfEps
,
epSet
->
inUse
);
return
TSDB_CODE_RPC_REDIRECT
;
return
TSDB_CODE_RPC_REDIRECT
;
}
}
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
88c11ce7
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include "taoserror.h"
#include "taoserror.h"
#include "hash.h"
#include "hash.h"
#include "tutil.h"
#include "tutil.h"
#include "tref.h"
#include "tbalance.h"
#include "tbalance.h"
#include "tqueue.h"
#include "tqueue.h"
#include "twal.h"
#include "twal.h"
...
@@ -98,6 +99,7 @@ typedef struct {
...
@@ -98,6 +99,7 @@ typedef struct {
SSdbWorker
*
worker
;
SSdbWorker
*
worker
;
}
SSdbWorkerPool
;
}
SSdbWorkerPool
;
int32_t
tsSdbRid
;
extern
void
*
tsMnodeTmr
;
extern
void
*
tsMnodeTmr
;
static
void
*
tsSdbTmr
;
static
void
*
tsSdbTmr
;
static
SSdbMgmt
tsSdbMgmt
=
{
0
};
static
SSdbMgmt
tsSdbMgmt
=
{
0
};
...
@@ -118,6 +120,7 @@ static void sdbFreeQueue();
...
@@ -118,6 +120,7 @@ static void sdbFreeQueue();
static
int32_t
sdbInsertHash
(
SSdbTable
*
pTable
,
SSdbRow
*
pRow
);
static
int32_t
sdbInsertHash
(
SSdbTable
*
pTable
,
SSdbRow
*
pRow
);
static
int32_t
sdbUpdateHash
(
SSdbTable
*
pTable
,
SSdbRow
*
pRow
);
static
int32_t
sdbUpdateHash
(
SSdbTable
*
pTable
,
SSdbRow
*
pRow
);
static
int32_t
sdbDeleteHash
(
SSdbTable
*
pTable
,
SSdbRow
*
pRow
);
static
int32_t
sdbDeleteHash
(
SSdbTable
*
pTable
,
SSdbRow
*
pRow
);
static
void
sdbCloseTableObj
(
void
*
handle
);
int32_t
sdbGetId
(
void
*
pTable
)
{
int32_t
sdbGetId
(
void
*
pTable
)
{
return
((
SSdbTable
*
)
pTable
)
->
autoIndex
;
return
((
SSdbTable
*
)
pTable
)
->
autoIndex
;
...
@@ -325,7 +328,6 @@ void sdbUpdateSync(void *pMnodes) {
...
@@ -325,7 +328,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
{
...
@@ -386,6 +388,17 @@ void sdbUpdateSync(void *pMnodes) {
...
@@ -386,6 +388,17 @@ void sdbUpdateSync(void *pMnodes) {
sdbUpdateMnodeRoles
();
sdbUpdateMnodeRoles
();
}
}
int32_t
sdbInitRef
()
{
tsSdbRid
=
taosOpenRef
(
10
,
sdbCloseTableObj
);
if
(
tsSdbRid
<=
0
)
{
sdbError
(
"failed to init sdb ref"
);
return
-
1
;
}
return
0
;
}
void
sdbCleanUpRef
()
{
taosCloseRef
(
tsSdbRid
);
}
int32_t
sdbInit
()
{
int32_t
sdbInit
()
{
pthread_mutex_init
(
&
tsSdbMgmt
.
mutex
,
NULL
);
pthread_mutex_init
(
&
tsSdbMgmt
.
mutex
,
NULL
);
...
@@ -424,7 +437,7 @@ void sdbCleanUp() {
...
@@ -424,7 +437,7 @@ void sdbCleanUp() {
walClose
(
tsSdbMgmt
.
wal
);
walClose
(
tsSdbMgmt
.
wal
);
tsSdbMgmt
.
wal
=
NULL
;
tsSdbMgmt
.
wal
=
NULL
;
}
}
pthread_mutex_destroy
(
&
tsSdbMgmt
.
mutex
);
pthread_mutex_destroy
(
&
tsSdbMgmt
.
mutex
);
}
}
...
@@ -507,7 +520,7 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbRow *pRow) {
...
@@ -507,7 +520,7 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbRow *pRow) {
atomic_add_fetch_32
(
&
pTable
->
autoIndex
,
1
);
atomic_add_fetch_32
(
&
pTable
->
autoIndex
,
1
);
}
}
sdb
Debug
(
"vgId:1, sdb:%s, insert key:%s to hash, rowSize:%d rows:%"
PRId64
", msg:%p"
,
pTable
->
name
,
sdb
Trace
(
"vgId:1, sdb:%s, insert key:%s to hash, rowSize:%d rows:%"
PRId64
", msg:%p"
,
pTable
->
name
,
sdbGetRowStr
(
pTable
,
pRow
->
pObj
),
pRow
->
rowSize
,
pTable
->
numOfRows
,
pRow
->
pMsg
);
sdbGetRowStr
(
pTable
,
pRow
->
pObj
),
pRow
->
rowSize
,
pTable
->
numOfRows
,
pRow
->
pMsg
);
int32_t
code
=
(
*
pTable
->
fpInsert
)(
pRow
);
int32_t
code
=
(
*
pTable
->
fpInsert
)(
pRow
);
...
@@ -543,7 +556,7 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbRow *pRow) {
...
@@ -543,7 +556,7 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbRow *pRow) {
atomic_sub_fetch_32
(
&
pTable
->
numOfRows
,
1
);
atomic_sub_fetch_32
(
&
pTable
->
numOfRows
,
1
);
sdb
Debug
(
"vgId:1, sdb:%s, delete key:%s from hash, numOfRows:%"
PRId64
", msg:%p"
,
pTable
->
name
,
sdb
Trace
(
"vgId:1, sdb:%s, delete key:%s from hash, numOfRows:%"
PRId64
", msg:%p"
,
pTable
->
name
,
sdbGetRowStr
(
pTable
,
pRow
->
pObj
),
pTable
->
numOfRows
,
pRow
->
pMsg
);
sdbGetRowStr
(
pTable
,
pRow
->
pObj
),
pTable
->
numOfRows
,
pRow
->
pMsg
);
sdbDecRef
(
pTable
,
pRow
->
pObj
);
sdbDecRef
(
pTable
,
pRow
->
pObj
);
...
@@ -552,7 +565,7 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbRow *pRow) {
...
@@ -552,7 +565,7 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbRow *pRow) {
}
}
static
int32_t
sdbUpdateHash
(
SSdbTable
*
pTable
,
SSdbRow
*
pRow
)
{
static
int32_t
sdbUpdateHash
(
SSdbTable
*
pTable
,
SSdbRow
*
pRow
)
{
sdb
Debug
(
"vgId:1, sdb:%s, update key:%s in hash, numOfRows:%"
PRId64
", msg:%p"
,
pTable
->
name
,
sdb
Trace
(
"vgId:1, sdb:%s, update key:%s in hash, numOfRows:%"
PRId64
", msg:%p"
,
pTable
->
name
,
sdbGetRowStr
(
pTable
,
pRow
->
pObj
),
pTable
->
numOfRows
,
pRow
->
pMsg
);
sdbGetRowStr
(
pTable
,
pRow
->
pObj
),
pTable
->
numOfRows
,
pRow
->
pMsg
);
(
*
pTable
->
fpUpdate
)(
pRow
);
(
*
pTable
->
fpUpdate
)(
pRow
);
...
@@ -650,7 +663,7 @@ static int32_t sdbProcessWrite(void *wparam, void *hparam, int32_t qtype, void *
...
@@ -650,7 +663,7 @@ static int32_t sdbProcessWrite(void *wparam, void *hparam, int32_t qtype, void *
return
syncCode
;
return
syncCode
;
}
}
sdb
Debug
(
"vgId:1, sdb:%s, record from wal/fwd is disposed, action:%s key:%s hver:%"
PRIu64
,
pTable
->
name
,
sdb
Trace
(
"vgId:1, sdb:%s, record from %s is disposed, action:%s key:%s hver:%"
PRIu64
,
pTable
->
name
,
qtypeStr
[
qtype
]
,
actStr
[
action
],
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
);
actStr
[
action
],
sdbGetKeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
);
// even it is WAL/FWD, it shall be called to update version in sync
// even it is WAL/FWD, it shall be called to update version in sync
...
@@ -775,24 +788,17 @@ int32_t sdbUpdateRow(SSdbRow *pRow) {
...
@@ -775,24 +788,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
))
{
void
**
ppMetaRow
=
pIter
;
taosHashDestroyIter
(
pIter
);
return
NULL
;
}
void
**
ppMetaRow
=
taosHashIterGet
(
pIter
);
if
(
ppMetaRow
==
NULL
)
{
if
(
ppMetaRow
==
NULL
)
{
taosHash
DestroyIter
(
pIter
);
taosHash
CancelIterate
(
pTable
->
iHandle
,
pIter
);
return
NULL
;
return
NULL
;
}
}
...
@@ -802,16 +808,17 @@ void *sdbFetchRow(void *tparam, void *pNode, void **ppRow) {
...
@@ -802,16 +808,17 @@ 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
)
{
int64_t
sdbOpenTable
(
SSdbTableDesc
*
pDesc
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
calloc
(
1
,
sizeof
(
SSdbTable
));
SSdbTable
*
pTable
=
(
SSdbTable
*
)
calloc
(
1
,
sizeof
(
SSdbTable
));
if
(
pTable
==
NULL
)
return
NULL
;
if
(
pTable
==
NULL
)
return
-
1
;
pthread_mutex_init
(
&
pTable
->
mutex
,
NULL
);
pthread_mutex_init
(
&
pTable
->
mutex
,
NULL
);
tstrncpy
(
pTable
->
name
,
pDesc
->
name
,
SDB_TABLE_LEN
);
tstrncpy
(
pTable
->
name
,
pDesc
->
name
,
SDB_TABLE_LEN
);
...
@@ -836,19 +843,31 @@ void *sdbOpenTable(SSdbTableDesc *pDesc) {
...
@@ -836,19 +843,31 @@ void *sdbOpenTable(SSdbTableDesc *pDesc) {
tsSdbMgmt
.
numOfTables
++
;
tsSdbMgmt
.
numOfTables
++
;
tsSdbMgmt
.
tableList
[
pTable
->
id
]
=
pTable
;
tsSdbMgmt
.
tableList
[
pTable
->
id
]
=
pTable
;
return
pTable
;
return
taosAddRef
(
tsSdbRid
,
pTable
);
}
void
sdbCloseTable
(
int64_t
rid
)
{
taosRemoveRef
(
tsSdbRid
,
rid
);
}
void
*
sdbGetTableByRid
(
int64_t
rid
)
{
void
*
handle
=
taosAcquireRef
(
tsSdbRid
,
rid
);
taosReleaseRef
(
tsSdbRid
,
rid
);
return
handle
;
}
}
void
sdbCloseTable
(
void
*
handle
)
{
static
void
sdbCloseTableObj
(
void
*
handle
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
handle
;
SSdbTable
*
pTable
=
(
SSdbTable
*
)
handle
;
if
(
pTable
==
NULL
)
return
;
if
(
pTable
==
NULL
)
return
;
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,8 +878,9 @@ void sdbCloseTable(void *handle) {
...
@@ -859,8 +878,9 @@ void sdbCloseTable(void *handle) {
(
*
pTable
->
fpDestroy
)(
&
row
);
(
*
pTable
->
fpDestroy
)(
&
row
);
}
}
taosHash
DestroyIter
(
pIter
);
taosHash
CancelIterate
(
pTable
->
iHandle
,
pIter
);
taosHashCleanup
(
pTable
->
iHandle
);
taosHashCleanup
(
pTable
->
iHandle
);
pTable
->
iHandle
=
NULL
;
pthread_mutex_destroy
(
&
pTable
->
mutex
);
pthread_mutex_destroy
(
&
pTable
->
mutex
);
sdbDebug
(
"vgId:1, sdb:%s, is closed, numOfTables:%d"
,
pTable
->
name
,
tsSdbMgmt
.
numOfTables
);
sdbDebug
(
"vgId:1, sdb:%s, is closed, numOfTables:%d"
,
pTable
->
name
,
tsSdbMgmt
.
numOfTables
);
...
...
src/mnode/src/mnodeShow.c
浏览文件 @
88c11ce7
...
@@ -52,11 +52,11 @@ static bool mnodeCheckShowFinished(SShowObj *pShow);
...
@@ -52,11 +52,11 @@ static bool mnodeCheckShowFinished(SShowObj *pShow);
static
void
*
mnodePutShowObj
(
SShowObj
*
pShow
);
static
void
*
mnodePutShowObj
(
SShowObj
*
pShow
);
static
void
mnodeReleaseShowObj
(
SShowObj
*
pShow
,
bool
forceRemove
);
static
void
mnodeReleaseShowObj
(
SShowObj
*
pShow
,
bool
forceRemove
);
extern
void
*
tsMnodeTmr
;
static
void
*
tsMnodeShowCache
=
NULL
;
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 +85,10 @@ void mnodeAddShowRetrieveHandle(uint8_t msgType, SShowRetrieveFp fp) {
...
@@ -85,6 +85,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 +416,9 @@ static void* mnodePutShowObj(SShowObj *pShow) {
...
@@ -412,7 +416,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
浏览文件 @
88c11ce7
...
@@ -49,7 +49,9 @@
...
@@ -49,7 +49,9 @@
#define CREATE_CTABLE_RETRY_TIMES 10
#define CREATE_CTABLE_RETRY_TIMES 10
#define CREATE_CTABLE_RETRY_SEC 14
#define CREATE_CTABLE_RETRY_SEC 14
int64_t
tsCTableRid
=
-
1
;
static
void
*
tsChildTableSdb
;
static
void
*
tsChildTableSdb
;
int64_t
tsSTableRid
=
-
1
;
static
void
*
tsSuperTableSdb
;
static
void
*
tsSuperTableSdb
;
static
int32_t
tsChildTableUpdateSize
;
static
int32_t
tsChildTableUpdateSize
;
static
int32_t
tsSuperTableUpdateSize
;
static
int32_t
tsSuperTableUpdateSize
;
...
@@ -342,8 +344,7 @@ static int32_t mnodeChildTableActionRestored() {
...
@@ -342,8 +344,7 @@ static int32_t mnodeChildTableActionRestored() {
mnodeDecTableRef
(
pTable
);
mnodeDecTableRef
(
pTable
);
}
}
sdbFreeIter
(
pIter
);
mnodeCancelGetNextChildTable
(
pIter
);
return
0
;
return
0
;
}
}
...
@@ -351,7 +352,7 @@ static int32_t mnodeInitChildTables() {
...
@@ -351,7 +352,7 @@ static int32_t mnodeInitChildTables() {
SCTableObj
tObj
;
SCTableObj
tObj
;
tsChildTableUpdateSize
=
(
int8_t
*
)
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
.
info
.
type
;
tsChildTableUpdateSize
=
(
int8_t
*
)
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
.
info
.
type
;
SSdbTableDesc
tableD
esc
=
{
SSdbTableDesc
d
esc
=
{
.
id
=
SDB_TABLE_CTABLE
,
.
id
=
SDB_TABLE_CTABLE
,
.
name
=
"ctables"
,
.
name
=
"ctables"
,
.
hashSessions
=
TSDB_DEFAULT_CTABLES_HASH_SIZE
,
.
hashSessions
=
TSDB_DEFAULT_CTABLES_HASH_SIZE
,
...
@@ -367,7 +368,8 @@ static int32_t mnodeInitChildTables() {
...
@@ -367,7 +368,8 @@ static int32_t mnodeInitChildTables() {
.
fpRestored
=
mnodeChildTableActionRestored
.
fpRestored
=
mnodeChildTableActionRestored
};
};
tsChildTableSdb
=
sdbOpenTable
(
&
tableDesc
);
tsCTableRid
=
sdbOpenTable
(
&
desc
);
tsChildTableSdb
=
sdbGetTableByRid
(
tsCTableRid
);
if
(
tsChildTableSdb
==
NULL
)
{
if
(
tsChildTableSdb
==
NULL
)
{
mError
(
"failed to init child table data"
);
mError
(
"failed to init child table data"
);
return
-
1
;
return
-
1
;
...
@@ -378,7 +380,7 @@ static int32_t mnodeInitChildTables() {
...
@@ -378,7 +380,7 @@ static int32_t mnodeInitChildTables() {
}
}
static
void
mnodeCleanupChildTables
()
{
static
void
mnodeCleanupChildTables
()
{
sdbCloseTable
(
tsC
hildTableSdb
);
sdbCloseTable
(
tsC
TableRid
);
tsChildTableSdb
=
NULL
;
tsChildTableSdb
=
NULL
;
}
}
...
@@ -544,7 +546,7 @@ static int32_t mnodeInitSuperTables() {
...
@@ -544,7 +546,7 @@ static int32_t mnodeInitSuperTables() {
SSTableObj
tObj
;
SSTableObj
tObj
;
tsSuperTableUpdateSize
=
(
int8_t
*
)
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
.
info
.
type
;
tsSuperTableUpdateSize
=
(
int8_t
*
)
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
.
info
.
type
;
SSdbTableDesc
tableD
esc
=
{
SSdbTableDesc
d
esc
=
{
.
id
=
SDB_TABLE_STABLE
,
.
id
=
SDB_TABLE_STABLE
,
.
name
=
"stables"
,
.
name
=
"stables"
,
.
hashSessions
=
TSDB_DEFAULT_STABLES_HASH_SIZE
,
.
hashSessions
=
TSDB_DEFAULT_STABLES_HASH_SIZE
,
...
@@ -560,7 +562,8 @@ static int32_t mnodeInitSuperTables() {
...
@@ -560,7 +562,8 @@ static int32_t mnodeInitSuperTables() {
.
fpRestored
=
mnodeSuperTableActionRestored
.
fpRestored
=
mnodeSuperTableActionRestored
};
};
tsSuperTableSdb
=
sdbOpenTable
(
&
tableDesc
);
tsSTableRid
=
sdbOpenTable
(
&
desc
);
tsSuperTableSdb
=
sdbGetTableByRid
(
tsSTableRid
);
if
(
tsSuperTableSdb
==
NULL
)
{
if
(
tsSuperTableSdb
==
NULL
)
{
mError
(
"failed to init stables data"
);
mError
(
"failed to init stables data"
);
return
-
1
;
return
-
1
;
...
@@ -571,7 +574,7 @@ static int32_t mnodeInitSuperTables() {
...
@@ -571,7 +574,7 @@ static int32_t mnodeInitSuperTables() {
}
}
static
void
mnodeCleanupSuperTables
()
{
static
void
mnodeCleanupSuperTables
()
{
sdbCloseTable
(
tsS
uperTableSdb
);
sdbCloseTable
(
tsS
TableRid
);
tsSuperTableSdb
=
NULL
;
tsSuperTableSdb
=
NULL
;
}
}
...
@@ -602,10 +605,13 @@ int32_t mnodeInitTables() {
...
@@ -602,10 +605,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 +632,12 @@ static void *mnodeGetSuperTableByUid(uint64_t uid) {
...
@@ -626,14 +632,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 +659,18 @@ void *mnodeGetNextChildTable(void *pIter, SCTableObj **pTable) {
...
@@ -655,10 +659,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 +926,10 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
...
@@ -914,10 +926,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 +945,8 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
...
@@ -933,7 +945,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 +1443,6 @@ void mnodeDropAllSuperTables(SDbObj *pDropDb) {
...
@@ -1430,8 +1443,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 +1534,11 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
...
@@ -1523,11 +1534,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 +1558,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
...
@@ -1547,7 +1558,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 +2241,6 @@ void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup) {
...
@@ -2230,8 +2241,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 +2272,6 @@ void mnodeDropAllChildTables(SDbObj *pDropDb) {
...
@@ -2263,8 +2272,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 +2300,6 @@ static void mnodeDropAllChildTablesInStable(SSTableObj *pStable) {
...
@@ -2293,8 +2300,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
浏览文件 @
88c11ce7
...
@@ -33,6 +33,7 @@
...
@@ -33,6 +33,7 @@
#include "mnodeWrite.h"
#include "mnodeWrite.h"
#include "mnodePeer.h"
#include "mnodePeer.h"
int64_t
tsUserRid
=
-
1
;
static
void
*
tsUserSdb
=
NULL
;
static
void
*
tsUserSdb
=
NULL
;
static
int32_t
tsUserUpdateSize
=
0
;
static
int32_t
tsUserUpdateSize
=
0
;
static
int32_t
mnodeGetUserMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeGetUserMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
...
@@ -123,7 +124,6 @@ static void mnodePrintUserAuth() {
...
@@ -123,7 +124,6 @@ static void mnodePrintUserAuth() {
}
}
fflush
(
fp
);
fflush
(
fp
);
sdbFreeIter
(
pIter
);
fclose
(
fp
);
fclose
(
fp
);
}
}
...
@@ -166,7 +166,8 @@ int32_t mnodeInitUsers() {
...
@@ -166,7 +166,8 @@ int32_t mnodeInitUsers() {
.
fpRestored
=
mnodeUserActionRestored
.
fpRestored
=
mnodeUserActionRestored
};
};
tsUserSdb
=
sdbOpenTable
(
&
desc
);
tsUserRid
=
sdbOpenTable
(
&
desc
);
tsUserSdb
=
sdbGetTableByRid
(
tsUserRid
);
if
(
tsUserSdb
==
NULL
)
{
if
(
tsUserSdb
==
NULL
)
{
mError
(
"table:%s, failed to create hash"
,
desc
.
name
);
mError
(
"table:%s, failed to create hash"
,
desc
.
name
);
return
-
1
;
return
-
1
;
...
@@ -177,6 +178,8 @@ int32_t mnodeInitUsers() {
...
@@ -177,6 +178,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
);
...
@@ -184,7 +187,7 @@ int32_t mnodeInitUsers() {
...
@@ -184,7 +187,7 @@ int32_t mnodeInitUsers() {
}
}
void
mnodeCleanupUsers
()
{
void
mnodeCleanupUsers
()
{
sdbCloseTable
(
tsUser
Sdb
);
sdbCloseTable
(
tsUser
Rid
);
tsUserSdb
=
NULL
;
tsUserSdb
=
NULL
;
}
}
...
@@ -196,6 +199,10 @@ void *mnodeGetNextUser(void *pIter, SUserObj **pUser) {
...
@@ -196,6 +199,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 +581,6 @@ void mnodeDropAllUsers(SAcctObj *pAcct) {
...
@@ -574,8 +581,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
浏览文件 @
88c11ce7
...
@@ -51,6 +51,7 @@ char* vgroupStatus[] = {
...
@@ -51,6 +51,7 @@ char* vgroupStatus[] = {
"updating"
"updating"
};
};
int64_t
tsVgroupRid
=
-
1
;
static
void
*
tsVgroupSdb
=
NULL
;
static
void
*
tsVgroupSdb
=
NULL
;
static
int32_t
tsVgUpdateSize
=
0
;
static
int32_t
tsVgUpdateSize
=
0
;
...
@@ -222,7 +223,8 @@ int32_t mnodeInitVgroups() {
...
@@ -222,7 +223,8 @@ int32_t mnodeInitVgroups() {
.
fpRestored
=
mnodeVgroupActionRestored
,
.
fpRestored
=
mnodeVgroupActionRestored
,
};
};
tsVgroupSdb
=
sdbOpenTable
(
&
desc
);
tsVgroupRid
=
sdbOpenTable
(
&
desc
);
tsVgroupSdb
=
sdbGetTableByRid
(
tsVgroupRid
);
if
(
tsVgroupSdb
==
NULL
)
{
if
(
tsVgroupSdb
==
NULL
)
{
mError
(
"failed to init vgroups data"
);
mError
(
"failed to init vgroups data"
);
return
-
1
;
return
-
1
;
...
@@ -230,6 +232,7 @@ int32_t mnodeInitVgroups() {
...
@@ -230,6 +232,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 +307,7 @@ void mnodeCheckUnCreatedVgroup(SDnodeObj *pDnode, SVnodeLoad *pVloads, int32_t o
...
@@ -304,7 +307,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 +494,10 @@ void *mnodeGetNextVgroup(void *pIter, SVgObj **pVgroup) {
...
@@ -491,6 +494,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
;
...
@@ -605,7 +612,7 @@ void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle) {
...
@@ -605,7 +612,7 @@ void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle) {
}
}
void
mnodeCleanupVgroups
()
{
void
mnodeCleanupVgroups
()
{
sdbCloseTable
(
tsVgroup
Sdb
);
sdbCloseTable
(
tsVgroup
Rid
);
tsVgroupSdb
=
NULL
;
tsVgroupSdb
=
NULL
;
}
}
...
@@ -1095,8 +1102,6 @@ void mnodeDropAllDnodeVgroups(SDnodeObj *pDropDnode) {
...
@@ -1095,8 +1102,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 +1123,6 @@ void mnodeUpdateAllDbVgroups(SDbObj *pAlterDb) {
...
@@ -1118,8 +1123,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 +1150,6 @@ void mnodeDropAllDbVgroups(SDbObj *pDropDb) {
...
@@ -1147,8 +1150,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 +1171,5 @@ void mnodeSendDropAllDbVgroupsMsg(SDbObj *pDropDb) {
...
@@ -1170,7 +1171,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/mnode/src/mnodeWrite.c
浏览文件 @
88c11ce7
...
@@ -54,18 +54,8 @@ int32_t mnodeProcessWrite(SMnodeMsg *pMsg) {
...
@@ -54,18 +54,8 @@ int32_t mnodeProcessWrite(SMnodeMsg *pMsg) {
rpcRsp
->
rsp
=
epSet
;
rpcRsp
->
rsp
=
epSet
;
rpcRsp
->
len
=
sizeof
(
SRpcEpSet
);
rpcRsp
->
len
=
sizeof
(
SRpcEpSet
);
mDebug
(
"msg:%p, app:%p type:%s in write queue, will be redirected, numOfEps:%d inUse:%d"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
mDebug
(
"msg:%p, app:%p type:%s in write queue, is redirected, numOfEps:%d inUse:%d"
,
pMsg
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
],
epSet
->
numOfEps
,
epSet
->
inUse
);
pMsg
->
rpcMsg
.
ahandle
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
],
epSet
->
numOfEps
,
epSet
->
inUse
);
for
(
int32_t
i
=
0
;
i
<
epSet
->
numOfEps
;
++
i
)
{
if
(
strcmp
(
epSet
->
fqdn
[
i
],
tsLocalFqdn
)
==
0
&&
htons
(
epSet
->
port
[
i
])
==
tsServerPort
)
{
epSet
->
inUse
=
(
i
+
1
)
%
epSet
->
numOfEps
;
mDebug
(
"msg:%p, app:%p mnode index:%d ep:%s:%d, set inUse to %d"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
i
,
epSet
->
fqdn
[
i
],
htons
(
epSet
->
port
[
i
]),
epSet
->
inUse
);
}
else
{
mDebug
(
"msg:%p, app:%p mnode index:%d ep:%s:%d"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
i
,
epSet
->
fqdn
[
i
],
htons
(
epSet
->
port
[
i
]));
}
}
return
TSDB_CODE_RPC_REDIRECT
;
return
TSDB_CODE_RPC_REDIRECT
;
}
}
...
...
src/os/inc/osFile.h
浏览文件 @
88c11ce7
...
@@ -20,17 +20,6 @@
...
@@ -20,17 +20,6 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#define tread(fd, buf, count) read(fd, buf, count)
#define twrite(fd, buf, count) write(fd, buf, count)
#define tlseek(fd, offset, whence) lseek(fd, offset, whence)
#define tclose(fd) \
{ \
if (FD_VALID(fd)) { \
close(fd); \
fd = FD_INITIALIZER; \
} \
}
int64_t
taosReadImp
(
int32_t
fd
,
void
*
buf
,
int64_t
count
);
int64_t
taosReadImp
(
int32_t
fd
,
void
*
buf
,
int64_t
count
);
int64_t
taosWriteImp
(
int32_t
fd
,
void
*
buf
,
int64_t
count
);
int64_t
taosWriteImp
(
int32_t
fd
,
void
*
buf
,
int64_t
count
);
int64_t
taosLSeekImp
(
int32_t
fd
,
int64_t
offset
,
int32_t
whence
);
int64_t
taosLSeekImp
(
int32_t
fd
,
int64_t
offset
,
int32_t
whence
);
...
@@ -39,7 +28,13 @@ int32_t taosRenameFile(char *fullPath, char *suffix, char delimiter, char **dstP
...
@@ -39,7 +28,13 @@ int32_t taosRenameFile(char *fullPath, char *suffix, char delimiter, char **dstP
#define taosRead(fd, buf, count) taosReadImp(fd, buf, count)
#define taosRead(fd, buf, count) taosReadImp(fd, buf, count)
#define taosWrite(fd, buf, count) taosWriteImp(fd, buf, count)
#define taosWrite(fd, buf, count) taosWriteImp(fd, buf, count)
#define taosLSeek(fd, offset, whence) taosLSeekImp(fd, offset, whence)
#define taosLSeek(fd, offset, whence) taosLSeekImp(fd, offset, whence)
#define taosClose(x) tclose(x)
#define taosClose(fd) \
{ \
if (FD_VALID(fd)) { \
close(fd); \
fd = FD_INITIALIZER; \
} \
}
// TAOS_OS_FUNC_FILE_SENDIFLE
// TAOS_OS_FUNC_FILE_SENDIFLE
int64_t
taosSendFile
(
int32_t
dfd
,
int32_t
sfd
,
int64_t
*
offset
,
int64_t
size
);
int64_t
taosSendFile
(
int32_t
dfd
,
int32_t
sfd
,
int64_t
*
offset
,
int64_t
size
);
...
...
src/os/src/detail/osFile.c
浏览文件 @
88c11ce7
...
@@ -116,7 +116,7 @@ int64_t taosWriteImp(int32_t fd, void *buf, int64_t n) {
...
@@ -116,7 +116,7 @@ int64_t taosWriteImp(int32_t fd, void *buf, int64_t n) {
}
}
int64_t
taosLSeekImp
(
int32_t
fd
,
int64_t
offset
,
int32_t
whence
)
{
int64_t
taosLSeekImp
(
int32_t
fd
,
int64_t
offset
,
int32_t
whence
)
{
return
(
int64_t
)
t
lseek
(
fd
,
(
long
)
offset
,
whence
);
return
(
int64_t
)
lseek
(
fd
,
(
long
)
offset
,
whence
);
}
}
#ifndef TAOS_OS_FUNC_FILE_SENDIFLE
#ifndef TAOS_OS_FUNC_FILE_SENDIFLE
...
...
src/query/inc/qExecutor.h
浏览文件 @
88c11ce7
...
@@ -63,9 +63,11 @@ typedef struct SSqlGroupbyExpr {
...
@@ -63,9 +63,11 @@ typedef struct SSqlGroupbyExpr {
typedef
struct
SResultRow
{
typedef
struct
SResultRow
{
int32_t
pageId
;
// pageId & rowId is the position of current result in disk-based output buffer
int32_t
pageId
;
// pageId & rowId is the position of current result in disk-based output buffer
int32_t
rowId
:
15
;
int32_t
rowId
:
29
;
// row index in buffer page
bool
closed
:
1
;
// this result status: closed or opened
bool
startInterp
;
// the time window start timestamp has done the interpolation already.
uint16_t
numOfRows
;
// number of rows of current time window
bool
endInterp
;
// the time window end timestamp has done the interpolation already.
bool
closed
;
// this result status: closed or opened
uint32_t
numOfRows
;
// number of rows of current time window
SResultRowCellInfo
*
pCellInfo
;
// For each result column, there is a resultInfo
SResultRowCellInfo
*
pCellInfo
;
// For each result column, there is a resultInfo
union
{
STimeWindow
win
;
char
*
key
;};
// start key of current time window
union
{
STimeWindow
win
;
char
*
key
;};
// start key of current time window
}
SResultRow
;
}
SResultRow
;
...
@@ -187,6 +189,7 @@ typedef struct SQueryRuntimeEnv {
...
@@ -187,6 +189,7 @@ typedef struct SQueryRuntimeEnv {
bool
topBotQuery
;
// false
bool
topBotQuery
;
// false
bool
groupbyNormalCol
;
// denote if this is a groupby normal column query
bool
groupbyNormalCol
;
// denote if this is a groupby normal column query
bool
hasTagResults
;
// if there are tag values in final result or not
bool
hasTagResults
;
// if there are tag values in final result or not
bool
timeWindowInterpo
;
// if the time window start/end required interpolation
int32_t
interBufSize
;
// intermediate buffer sizse
int32_t
interBufSize
;
// intermediate buffer sizse
int32_t
prevGroupId
;
// previous executed group id
int32_t
prevGroupId
;
// previous executed group id
SDiskbasedResultBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
SDiskbasedResultBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
...
@@ -195,6 +198,8 @@ typedef struct SQueryRuntimeEnv {
...
@@ -195,6 +198,8 @@ typedef struct SQueryRuntimeEnv {
SResultRowPool
*
pool
;
// window result object pool
SResultRowPool
*
pool
;
// window result object pool
int32_t
*
rowCellInfoOffset
;
// offset value for each row result cell info
int32_t
*
rowCellInfoOffset
;
// offset value for each row result cell info
char
**
prevRow
;
char
**
nextRow
;
}
SQueryRuntimeEnv
;
}
SQueryRuntimeEnv
;
enum
{
enum
{
...
...
src/query/inc/tsqlfunction.h
浏览文件 @
88c11ce7
...
@@ -152,6 +152,11 @@ typedef struct SResultRowCellInfo {
...
@@ -152,6 +152,11 @@ typedef struct SResultRowCellInfo {
uint32_t
numOfRes
;
// num of output result in current buffer
uint32_t
numOfRes
;
// num of output result in current buffer
}
SResultRowCellInfo
;
}
SResultRowCellInfo
;
typedef
struct
SPoint1
{
int64_t
key
;
double
val
;
}
SPoint1
;
#define GET_ROWCELL_INTERBUF(_c) ((void*) ((char*)(_c) + sizeof(SResultRowCellInfo)))
#define GET_ROWCELL_INTERBUF(_c) ((void*) ((char*)(_c) + sizeof(SResultRowCellInfo)))
struct
SQLFunctionCtx
;
struct
SQLFunctionCtx
;
...
@@ -194,6 +199,8 @@ typedef struct SQLFunctionCtx {
...
@@ -194,6 +199,8 @@ typedef struct SQLFunctionCtx {
SResultRowCellInfo
*
resultInfo
;
SResultRowCellInfo
*
resultInfo
;
SExtTagsInfo
tagInfo
;
SExtTagsInfo
tagInfo
;
SPoint1
start
;
SPoint1
end
;
}
SQLFunctionCtx
;
}
SQLFunctionCtx
;
typedef
struct
SQLAggFuncElem
{
typedef
struct
SQLAggFuncElem
{
...
@@ -243,21 +250,11 @@ enum {
...
@@ -243,21 +250,11 @@ enum {
};
};
typedef
struct
STwaInfo
{
typedef
struct
STwaInfo
{
TSKEY
lastKey
;
TSKEY
lastKey
;
int8_t
hasResult
;
// flag to denote has value
int8_t
hasResult
;
// flag to denote has value
int16_t
type
;
// source data type
double
dOutput
;
TSKEY
SKey
;
double
lastValue
;
TSKEY
EKey
;
STimeWindow
win
;
union
{
double
dOutput
;
int64_t
iOutput
;
};
union
{
double
dLastValue
;
int64_t
iLastValue
;
};
}
STwaInfo
;
}
STwaInfo
;
/* global sql function array */
/* global sql function array */
...
@@ -276,8 +273,6 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, const cha
...
@@ -276,8 +273,6 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, int32_t functionId, const cha
(_r)->initialized = false; \
(_r)->initialized = false; \
} while (0)
} while (0)
//void setResultInfoBuf(SResultRowCellInfo *pResInfo, char* buf);
static
FORCE_INLINE
void
initResultInfo
(
SResultRowCellInfo
*
pResInfo
,
uint32_t
bufLen
)
{
static
FORCE_INLINE
void
initResultInfo
(
SResultRowCellInfo
*
pResInfo
,
uint32_t
bufLen
)
{
pResInfo
->
initialized
=
true
;
// the this struct has been initialized flag
pResInfo
->
initialized
=
true
;
// the this struct has been initialized flag
...
...
src/query/src/qAst.c
浏览文件 @
88c11ce7
...
@@ -370,6 +370,66 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
...
@@ -370,6 +370,66 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
#endif
#endif
}
}
static
void
reverseCopy
(
char
*
dest
,
const
char
*
src
,
int16_t
type
,
int32_t
numOfRows
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_TINYINT
:
{
int8_t
*
p
=
(
int8_t
*
)
dest
;
int8_t
*
pSrc
=
(
int8_t
*
)
src
;
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
p
[
i
]
=
pSrc
[
numOfRows
-
i
-
1
];
}
break
;
}
case
TSDB_DATA_TYPE_SMALLINT
:
{
int16_t
*
p
=
(
int16_t
*
)
dest
;
int16_t
*
pSrc
=
(
int16_t
*
)
src
;
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
p
[
i
]
=
pSrc
[
numOfRows
-
i
-
1
];
}
break
;
}
case
TSDB_DATA_TYPE_INT
:
{
int32_t
*
p
=
(
int32_t
*
)
dest
;
int32_t
*
pSrc
=
(
int32_t
*
)
src
;
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
p
[
i
]
=
pSrc
[
numOfRows
-
i
-
1
];
}
break
;
}
case
TSDB_DATA_TYPE_BIGINT
:
{
int64_t
*
p
=
(
int64_t
*
)
dest
;
int64_t
*
pSrc
=
(
int64_t
*
)
src
;
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
p
[
i
]
=
pSrc
[
numOfRows
-
i
-
1
];
}
break
;
}
case
TSDB_DATA_TYPE_FLOAT
:
{
float
*
p
=
(
float
*
)
dest
;
float
*
pSrc
=
(
float
*
)
src
;
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
p
[
i
]
=
pSrc
[
numOfRows
-
i
-
1
];
}
break
;
}
case
TSDB_DATA_TYPE_DOUBLE
:
{
double
*
p
=
(
double
*
)
dest
;
double
*
pSrc
=
(
double
*
)
src
;
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
p
[
i
]
=
pSrc
[
numOfRows
-
i
-
1
];
}
break
;
}
default:
assert
(
0
);
}
}
void
tExprTreeCalcTraverse
(
tExprNode
*
pExprs
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
void
tExprTreeCalcTraverse
(
tExprNode
*
pExprs
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
getSourceDataBlock
)(
void
*
,
const
char
*
,
int32_t
))
{
char
*
(
*
getSourceDataBlock
)(
void
*
,
const
char
*
,
int32_t
))
{
if
(
pExprs
==
NULL
)
{
if
(
pExprs
==
NULL
)
{
...
@@ -387,6 +447,8 @@ void tExprTreeCalcTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput,
...
@@ -387,6 +447,8 @@ void tExprTreeCalcTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput,
/* the right output has result from the right child syntax tree */
/* the right output has result from the right child syntax tree */
char
*
pRightOutput
=
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
char
*
pRightOutput
=
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
char
*
pdata
=
malloc
(
sizeof
(
int64_t
)
*
numOfRows
);
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
)
{
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
)
{
tExprTreeCalcTraverse
(
pRight
,
numOfRows
,
pRightOutput
,
param
,
order
,
getSourceDataBlock
);
tExprTreeCalcTraverse
(
pRight
,
numOfRows
,
pRightOutput
,
param
,
order
,
getSourceDataBlock
);
}
}
...
@@ -398,52 +460,75 @@ void tExprTreeCalcTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput,
...
@@ -398,52 +460,75 @@ void tExprTreeCalcTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput,
* the type of returned value of one expression is always double float precious
* the type of returned value of one expression is always double float precious
*/
*/
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
TSDB_DATA_TYPE_DOUBLE
,
TSDB_DATA_TYPE_DOUBLE
,
pExprs
->
_node
.
optr
);
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
TSDB_DATA_TYPE_DOUBLE
,
TSDB_DATA_TYPE_DOUBLE
,
pExprs
->
_node
.
optr
);
fp
(
pLeftOutput
,
pRightOutput
,
numOfRows
,
numOfRows
,
pOutput
,
order
);
fp
(
pLeftOutput
,
pRightOutput
,
numOfRows
,
numOfRows
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
// exprLeft + columnRight
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
// exprLeft + columnRight
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
TSDB_DATA_TYPE_DOUBLE
,
pRight
->
pSchema
->
type
,
pExprs
->
_node
.
optr
);
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
TSDB_DATA_TYPE_DOUBLE
,
pRight
->
pSchema
->
type
,
pExprs
->
_node
.
optr
);
// set input buffer
// set input buffer
char
*
pInputData
=
getSourceDataBlock
(
param
,
pRight
->
pSchema
->
name
,
pRight
->
pSchema
->
colId
);
char
*
pInputData
=
getSourceDataBlock
(
param
,
pRight
->
pSchema
->
name
,
pRight
->
pSchema
->
colId
);
fp
(
pLeftOutput
,
pInputData
,
numOfRows
,
numOfRows
,
pOutput
,
order
);
if
(
order
==
TSDB_ORDER_DESC
)
{
reverseCopy
(
pdata
,
pInputData
,
pRight
->
pSchema
->
type
,
numOfRows
);
fp
(
pLeftOutput
,
pdata
,
numOfRows
,
numOfRows
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
{
fp
(
pLeftOutput
,
pInputData
,
numOfRows
,
numOfRows
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
// exprLeft + 12
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
// exprLeft + 12
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
TSDB_DATA_TYPE_DOUBLE
,
pRight
->
pVal
->
nType
,
pExprs
->
_node
.
optr
);
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
TSDB_DATA_TYPE_DOUBLE
,
pRight
->
pVal
->
nType
,
pExprs
->
_node
.
optr
);
fp
(
pLeftOutput
,
&
pRight
->
pVal
->
i64Key
,
numOfRows
,
1
,
pOutput
,
order
);
fp
(
pLeftOutput
,
&
pRight
->
pVal
->
i64Key
,
numOfRows
,
1
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
}
else
if
(
pLeft
->
nodeType
==
TSQL_NODE_COL
)
{
}
else
if
(
pLeft
->
nodeType
==
TSQL_NODE_COL
)
{
// column data specified on left-hand-side
// column data specified on left-hand-side
char
*
pLeftInputData
=
getSourceDataBlock
(
param
,
pLeft
->
pSchema
->
name
,
pLeft
->
pSchema
->
colId
);
char
*
pLeftInputData
=
getSourceDataBlock
(
param
,
pLeft
->
pSchema
->
name
,
pLeft
->
pSchema
->
colId
);
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
)
{
// columnLeft + expr2
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
)
{
// columnLeft + expr2
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
pLeft
->
pSchema
->
type
,
TSDB_DATA_TYPE_DOUBLE
,
pExprs
->
_node
.
optr
);
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
pLeft
->
pSchema
->
type
,
TSDB_DATA_TYPE_DOUBLE
,
pExprs
->
_node
.
optr
);
fp
(
pLeftInputData
,
pRightOutput
,
numOfRows
,
numOfRows
,
pOutput
,
order
);
if
(
order
==
TSDB_ORDER_DESC
)
{
reverseCopy
(
pdata
,
pLeftInputData
,
pLeft
->
pSchema
->
type
,
numOfRows
);
fp
(
pdata
,
pRightOutput
,
numOfRows
,
numOfRows
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
{
fp
(
pLeftInputData
,
pRightOutput
,
numOfRows
,
numOfRows
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
// columnLeft + columnRight
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
// columnLeft + columnRight
// column data specified on right-hand-side
// column data specified on right-hand-side
char
*
pRightInputData
=
getSourceDataBlock
(
param
,
pRight
->
pSchema
->
name
,
pRight
->
pSchema
->
colId
);
char
*
pRightInputData
=
getSourceDataBlock
(
param
,
pRight
->
pSchema
->
name
,
pRight
->
pSchema
->
colId
);
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
pLeft
->
pSchema
->
type
,
pRight
->
pSchema
->
type
,
pExprs
->
_node
.
optr
);
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
pLeft
->
pSchema
->
type
,
pRight
->
pSchema
->
type
,
pExprs
->
_node
.
optr
);
fp
(
pLeftInputData
,
pRightInputData
,
numOfRows
,
numOfRows
,
pOutput
,
order
);
// both columns are descending order, do not reverse the source data
fp
(
pLeftInputData
,
pRightInputData
,
numOfRows
,
numOfRows
,
pOutput
,
order
);
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
// columnLeft + 12
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
// columnLeft + 12
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
pLeft
->
pSchema
->
type
,
pRight
->
pVal
->
nType
,
pExprs
->
_node
.
optr
);
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
pLeft
->
pSchema
->
type
,
pRight
->
pVal
->
nType
,
pExprs
->
_node
.
optr
);
fp
(
pLeftInputData
,
&
pRight
->
pVal
->
i64Key
,
numOfRows
,
1
,
pOutput
,
order
);
if
(
order
==
TSDB_ORDER_DESC
)
{
reverseCopy
(
pdata
,
pLeftInputData
,
pLeft
->
pSchema
->
type
,
numOfRows
);
fp
(
pdata
,
&
pRight
->
pVal
->
i64Key
,
numOfRows
,
1
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
{
fp
(
pLeftInputData
,
&
pRight
->
pVal
->
i64Key
,
numOfRows
,
1
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
}
}
else
{
}
else
{
// column data specified on left-hand-side
// column data specified on left-hand-side
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
)
{
// 12 + expr2
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
)
{
// 12 + expr2
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
pLeft
->
pVal
->
nType
,
TSDB_DATA_TYPE_DOUBLE
,
pExprs
->
_node
.
optr
);
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
pLeft
->
pVal
->
nType
,
TSDB_DATA_TYPE_DOUBLE
,
pExprs
->
_node
.
optr
);
fp
(
&
pLeft
->
pVal
->
i64Key
,
pRightOutput
,
1
,
numOfRows
,
pOutput
,
order
);
fp
(
&
pLeft
->
pVal
->
i64Key
,
pRightOutput
,
1
,
numOfRows
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
// 12 + columnRight
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
// 12 + columnRight
// column data specified on right-hand-side
// column data specified on right-hand-side
char
*
pRightInputData
=
getSourceDataBlock
(
param
,
pRight
->
pSchema
->
name
,
pRight
->
pSchema
->
colId
);
char
*
pRightInputData
=
getSourceDataBlock
(
param
,
pRight
->
pSchema
->
name
,
pRight
->
pSchema
->
colId
);
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
pLeft
->
pVal
->
nType
,
pRight
->
pSchema
->
type
,
pExprs
->
_node
.
optr
);
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
pLeft
->
pVal
->
nType
,
pRight
->
pSchema
->
type
,
pExprs
->
_node
.
optr
);
fp
(
&
pLeft
->
pVal
->
i64Key
,
pRightInputData
,
1
,
numOfRows
,
pOutput
,
order
);
if
(
order
==
TSDB_ORDER_DESC
)
{
reverseCopy
(
pdata
,
pRightInputData
,
pRight
->
pSchema
->
type
,
numOfRows
);
fp
(
&
pLeft
->
pVal
->
i64Key
,
pdata
,
numOfRows
,
1
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
{
fp
(
&
pLeft
->
pVal
->
i64Key
,
pRightInputData
,
1
,
numOfRows
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
// 12 + 12
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
// 12 + 12
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
pLeft
->
pVal
->
nType
,
pRight
->
pVal
->
nType
,
pExprs
->
_node
.
optr
);
_bi_consumer_fn_t
fp
=
tGetBiConsumerFn
(
pLeft
->
pVal
->
nType
,
pRight
->
pVal
->
nType
,
pExprs
->
_node
.
optr
);
fp
(
&
pLeft
->
pVal
->
i64Key
,
&
pRight
->
pVal
->
i64Key
,
1
,
1
,
pOutput
,
order
);
fp
(
&
pLeft
->
pVal
->
i64Key
,
&
pRight
->
pVal
->
i64Key
,
1
,
1
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
}
}
...
...
src/query/src/qExecutor.c
浏览文件 @
88c11ce7
此差异已折叠。
点击以展开。
src/query/src/qResultbuf.c
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -395,11 +395,10 @@ uint64_t getResultInfoUId(SQueryRuntimeEnv* pRuntimeEnv) {
...
@@ -395,11 +395,10 @@ uint64_t getResultInfoUId(SQueryRuntimeEnv* pRuntimeEnv) {
}
}
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
if
((
pQuery
->
checkBuffer
==
1
&&
pQuery
->
interval
.
interval
==
0
)
||
isPointInterpoQuery
(
pQuery
)
||
if
(
pQuery
->
interval
.
interval
==
0
||
isPointInterpoQuery
(
pQuery
)
||
pRuntimeEnv
->
groupbyNormalCol
)
{
pRuntimeEnv
->
groupbyNormalCol
)
{
return
0
;
return
0
;
}
}
STableId
*
id
=
TSDB_TABLEID
(
pRuntimeEnv
->
pQuery
->
current
);
STableId
*
id
=
TSDB_TABLEID
(
pRuntimeEnv
->
pQuery
->
current
->
pTable
);
return
id
->
uid
;
return
id
->
uid
;
}
}
\ No newline at end of file
src/rpc/src/rpcTcp.c
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -52,12 +52,12 @@ static void syncRemoveExtraFile(SSyncPeer *pPeer, int32_t sindex, int32_t eindex
...
@@ -52,12 +52,12 @@ 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
bool
fileChanged
=
false
;
bool
fileChanged
=
false
;
*
fversion
=
0
;
*
fversion
=
0
;
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -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
;
pPeer
->
fileChanged
=
1
;
char
*
ptr
;
return
TSDB_CODE_SYN_FILE_CHNAGED
;
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
;
code
=
1
;
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/util/inc/hash.h
浏览文件 @
88c11ce7
...
@@ -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/inc/tfile.h
浏览文件 @
88c11ce7
...
@@ -20,23 +20,26 @@
...
@@ -20,23 +20,26 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#include <unistd.h>
// init taos file module
// init taos file module
int32_t
tf
i
nit
();
int32_t
tf
I
nit
();
// clean up taos file module
// clean up taos file module
void
tf
c
leanup
();
void
tf
C
leanup
();
// the same syntax as UNIX standard open/close/read/write
// the same syntax as UNIX standard open/close/read/write
// but FD is int64_t and will never be reused
// but FD is int64_t and will never be reused
int64_t
tfopen
(
const
char
*
pathname
,
int32_t
flags
);
int64_t
tfOpen
(
const
char
*
pathname
,
int32_t
flags
);
int64_t
tfclose
(
int64_t
tfd
);
int64_t
tfOpenM
(
const
char
*
pathname
,
int32_t
flags
,
mode_t
mode
);
int64_t
tfwrite
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
);
int64_t
tfClose
(
int64_t
tfd
);
int64_t
tfread
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
);
int64_t
tfWrite
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
);
int64_t
tfRead
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
);
int32_t
tfFsync
(
int64_t
tfd
);
bool
tfValid
(
int64_t
tfd
);
int64_t
tfLseek
(
int64_t
tfd
,
int64_t
offset
,
int32_t
whence
);
int32_t
tfFtruncate
(
int64_t
tfd
,
int64_t
length
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif // TDENGINE_T
REF
_H
#endif // TDENGINE_T
FILE
_H
src/util/src/hash.c
浏览文件 @
88c11ce7
...
@@ -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
;
}
}
pNewNode
->
next
=
pNode
->
next
;
if
(
pNode
->
count
<=
0
)
{
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,37 +356,37 @@ int32_t taosHashRemoveWithData(SHashObj *pHashObj, const void *key, size_t keyLe
...
@@ -360,37 +356,37 @@ 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
;
break
;
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
;
}
pNode
=
pNode
->
next
;
prevNode
=
pNode
;
}
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
(
data
)
memcpy
(
data
,
GET_HASH_NODE_DATA
(
pNode
),
dsize
);
if
(
pe
->
num
==
0
)
{
pe
->
num
--
;
assert
(
pe
->
next
==
NULL
);
atomic_sub_fetch_64
(
&
pHashObj
->
size
,
1
);
}
else
{
FREE_HASH_NODE
(
pHashObj
,
pNode
);
assert
(
pe
->
next
!=
NULL
);
}
}
}
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
taosWUnLockLatch
(
&
pe
->
latch
);
taosWUnLockLatch
(
&
pe
->
latch
);
...
@@ -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
);
}
// release the pNode, return next pNode, and lock the current entry
static
void
*
taosHashReleaseNode
(
SHashObj
*
pHashObj
,
void
*
p
,
int
*
slot
)
{
pIter
->
entryIndex
++
;
SHashNode
*
pOld
=
(
SHashNode
*
)
GET_HASH_PNODE
(
p
)
;
SHashNode
*
p
=
NULL
;
SHashNode
*
p
revNode
=
NULL
;
while
(
pIter
->
entryIndex
<
pIter
->
numOfEntries
)
{
*
slot
=
HASH_INDEX
(
pOld
->
hashVal
,
pHashObj
->
capacity
);
SHashEntry
*
pEntry
=
pIter
->
pHashObj
->
hashList
[
pIter
->
entryIndex
];
SHashEntry
*
pe
=
pHashObj
->
hashList
[
*
slot
];
if
(
pEntry
->
num
==
0
)
{
pIter
->
entryIndex
++
;
// lock entry
continue
;
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
taosWLockLatch
(
&
pe
->
latch
);
}
SHashNode
*
pNode
=
pe
->
next
;
while
(
pNode
)
{
if
(
pNode
==
pOld
)
break
;
prevNode
=
pNode
;
pNode
=
pNode
->
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
--
;
taosRLockLatch
(
&
pEntry
->
latch
);
if
(
pOld
->
count
<=
0
)
{
if
(
prevNode
)
{
prevNode
->
next
=
pOld
->
next
;
}
else
{
pe
->
next
=
pOld
->
next
;
}
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
pNode
;
}
void
*
taosHashIterate
(
SHashObj
*
pHashObj
,
void
*
p
)
{
if
(
pHashObj
==
NULL
)
return
NULL
;
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
);
}
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
);
}
p
=
pEntry
->
next
;
pNode
=
pe
->
next
;
while
(
pNode
)
{
if
(
pNode
->
removed
==
0
)
break
;
pNode
=
pNode
->
next
;
}
if
(
pIter
->
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
if
(
pNode
)
break
;
taosRUnLockLatch
(
&
pEntry
->
latch
);
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
taosWUnLockLatch
(
&
pe
->
latch
);
}
}
}
}
return
p
;
if
(
pNode
)
{
SHashEntry
*
pe
=
pHashObj
->
hashList
[
slot
];
pNode
->
count
++
;
data
=
GET_HASH_NODE_DATA
(
pNode
);
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
taosWUnLockLatch
(
&
pe
->
latch
);
}
}
}
return
NULL
;
__rd_unlock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
return
data
;
}
}
size_t
taosHashGetMemSize
(
const
SHashObj
*
pHashObj
)
{
void
taosHashCancelIterate
(
SHashObj
*
pHashObj
,
void
*
p
)
{
if
(
pHashObj
==
NULL
)
{
if
(
pHashObj
==
NULL
||
p
==
NULL
)
return
;
return
0
;
}
return
(
pHashObj
->
capacity
*
(
sizeof
(
SHashEntry
)
+
POINTER_BYTES
))
+
sizeof
(
SHashNode
)
*
taosHashGetSize
(
pHashObj
)
+
sizeof
(
SHashObj
);
// 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/tfile.c
浏览文件 @
88c11ce7
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "os.h"
#include "taoserror.h"
#include "taoserror.h"
#include "tulog.h"
#include "tulog.h"
...
@@ -21,40 +22,52 @@
...
@@ -21,40 +22,52 @@
static
int32_t
tsFileRsetId
=
-
1
;
static
int32_t
tsFileRsetId
=
-
1
;
static
void
t
aos
CloseFile
(
void
*
p
)
{
static
void
t
f
CloseFile
(
void
*
p
)
{
close
((
int32_t
)(
uintptr_t
)
p
);
close
((
int32_t
)(
uintptr_t
)
p
);
}
}
int32_t
tfinit
()
{
int32_t
tfInit
()
{
tsFileRsetId
=
taosOpenRef
(
2000
,
taosCloseFile
);
tsFileRsetId
=
taosOpenRef
(
2000
,
tfCloseFile
);
return
tsFileRsetId
;
if
(
tsFileRsetId
>
0
)
{
return
0
;
}
else
{
return
-
1
;
}
}
}
void
tf
c
leanup
()
{
void
tf
C
leanup
()
{
if
(
tsFileRsetId
>=
0
)
taosCloseRef
(
tsFileRsetId
);
if
(
tsFileRsetId
>=
0
)
taosCloseRef
(
tsFileRsetId
);
tsFileRsetId
=
-
1
;
tsFileRsetId
=
-
1
;
}
}
int64_t
tfopen
(
const
char
*
pathname
,
int32_t
flags
)
{
static
int64_t
tfOpenImp
(
int32_t
fd
)
{
int32_t
fd
=
open
(
pathname
,
flags
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
}
void
*
p
=
(
void
*
)(
int64_t
)
fd
;
void
*
p
=
(
void
*
)(
int64_t
)
fd
;
int64_t
rid
=
taosAddRef
(
tsFileRsetId
,
p
);
int64_t
rid
=
taosAddRef
(
tsFileRsetId
,
p
);
if
(
rid
<
0
)
close
(
fd
);
if
(
rid
<
0
)
close
(
fd
);
return
rid
;
return
rid
;
}
}
int64_t
tfclose
(
int64_t
tfd
)
{
int64_t
tfOpen
(
const
char
*
pathname
,
int32_t
flags
)
{
int32_t
fd
=
open
(
pathname
,
flags
);
return
tfOpenImp
(
fd
);
}
int64_t
tfOpenM
(
const
char
*
pathname
,
int32_t
flags
,
mode_t
mode
)
{
int32_t
fd
=
open
(
pathname
,
flags
,
mode
);
return
tfOpenImp
(
fd
);
}
int64_t
tfClose
(
int64_t
tfd
)
{
return
taosRemoveRef
(
tsFileRsetId
,
tfd
);
return
taosRemoveRef
(
tsFileRsetId
,
tfd
);
}
}
int64_t
tf
w
rite
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
)
{
int64_t
tf
W
rite
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
)
{
void
*
p
=
taosAcquireRef
(
tsFileRsetId
,
tfd
);
void
*
p
=
taosAcquireRef
(
tsFileRsetId
,
tfd
);
if
(
p
==
NULL
)
return
-
1
;
if
(
p
==
NULL
)
return
-
1
;
...
@@ -67,7 +80,7 @@ int64_t tfwrite(int64_t tfd, void *buf, int64_t count) {
...
@@ -67,7 +80,7 @@ int64_t tfwrite(int64_t tfd, void *buf, int64_t count) {
return
ret
;
return
ret
;
}
}
int64_t
tf
r
ead
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
)
{
int64_t
tf
R
ead
(
int64_t
tfd
,
void
*
buf
,
int64_t
count
)
{
void
*
p
=
taosAcquireRef
(
tsFileRsetId
,
tfd
);
void
*
p
=
taosAcquireRef
(
tsFileRsetId
,
tfd
);
if
(
p
==
NULL
)
return
-
1
;
if
(
p
==
NULL
)
return
-
1
;
...
@@ -79,3 +92,32 @@ int64_t tfread(int64_t tfd, void *buf, int64_t count) {
...
@@ -79,3 +92,32 @@ int64_t tfread(int64_t tfd, void *buf, int64_t count) {
taosReleaseRef
(
tsFileRsetId
,
tfd
);
taosReleaseRef
(
tsFileRsetId
,
tfd
);
return
ret
;
return
ret
;
}
}
int64_t
tfFsync
(
int64_t
tfd
)
{
void
*
p
=
taosAcquireRef
(
tsFileRsetId
,
tfd
);
if
(
p
==
NULL
)
return
-
1
;
int32_t
fd
=
(
int32_t
)(
uintptr_t
)
p
;
return
fsync
(
fd
);
}
bool
tfValid
(
int64_t
tfd
)
{
void
*
p
=
taosAcquireRef
(
tsFileRsetId
,
tfd
);
return
p
!=
NULL
;
}
int64_t
tfLseek
(
int64_t
tfd
,
int64_t
offset
,
int32_t
whence
)
{
void
*
p
=
taosAcquireRef
(
tsFileRsetId
,
tfd
);
if
(
p
==
NULL
)
return
-
1
;
int32_t
fd
=
(
int32_t
)(
uintptr_t
)
p
;
return
taosLSeek
(
fd
,
offset
,
whence
);
}
int32_t
tfFtruncate
(
int64_t
tfd
,
int64_t
length
)
{
void
*
p
=
taosAcquireRef
(
tsFileRsetId
,
tfd
);
if
(
p
==
NULL
)
return
-
1
;
int32_t
fd
=
(
int32_t
)(
uintptr_t
)
p
;
return
taosFtruncate
(
fd
,
length
);
}
src/util/src/tkvstore.c
浏览文件 @
88c11ce7
...
@@ -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/vnode/inc/vnodeInt.h
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -38,6 +38,7 @@ static void vnodeCtrlFlow(int32_t vgId, int32_t level);
...
@@ -38,6 +38,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
;
}
...
@@ -352,6 +353,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
...
@@ -352,6 +353,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
...
@@ -520,11 +522,10 @@ static void vnodeBuildVloadMsg(SVnodeObj *pVnode, SStatusMsg *pStatus) {
...
@@ -520,11 +522,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
)
{
...
@@ -533,25 +534,25 @@ int32_t vnodeGetVnodeList(int32_t vnodeList[], int32_t *numOfVnodes) {
...
@@ -533,25 +534,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
;
vnodeBuildVloadMsg
(
*
pVnode
,
pStatus
);
void
*
pIter
=
taosHashIterate
(
tsVnodesHash
,
NULL
);
while
(
pIter
)
{
SVnodeObj
**
pVnode
=
pIter
;
if
(
*
pVnode
)
{
vnodeBuildVloadMsg
(
*
pVnode
,
pStatus
);
}
pIter
=
taosHashIterate
(
tsVnodesHash
,
pIter
);
}
}
taosHashDestroyIter
(
pIter
);
}
}
void
vnodeSetAccess
(
SVgroupAccess
*
pAccess
,
int32_t
numOfVnodes
)
{
void
vnodeSetAccess
(
SVgroupAccess
*
pAccess
,
int32_t
numOfVnodes
)
{
...
@@ -597,18 +598,19 @@ static void vnodeCleanUp(SVnodeObj *pVnode) {
...
@@ -597,18 +598,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
)
{
...
@@ -619,6 +621,7 @@ static int32_t vnodeProcessTsdbStatus(void *arg, int32_t status, int32_t eno) {
...
@@ -619,6 +621,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
);
...
@@ -684,8 +687,10 @@ static void vnodeCtrlFlow(int32_t vgId, int32_t level) {
...
@@ -684,8 +687,10 @@ static void vnodeCtrlFlow(int32_t vgId, int32_t level) {
return
;
return
;
}
}
pVnode
->
flowctrlLevel
=
level
;
if
(
pVnode
->
flowctrlLevel
!=
level
)
{
vDebug
(
"vgId:%d, set flowctrl level:%d"
,
pVnode
->
vgId
,
level
);
vDebug
(
"vgId:%d, set flowctrl level from %d to %d"
,
pVnode
->
vgId
,
pVnode
->
flowctrlLevel
,
level
);
pVnode
->
flowctrlLevel
=
level
;
}
vnodeRelease
(
pVnode
);
vnodeRelease
(
pVnode
);
}
}
...
@@ -765,3 +770,22 @@ static int32_t vnodeWriteToCache(int32_t vgId, void *wparam, int32_t qtype, void
...
@@ -765,3 +770,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
浏览文件 @
88c11ce7
...
@@ -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/inc/walInt.h
浏览文件 @
88c11ce7
...
@@ -44,8 +44,8 @@ typedef struct {
...
@@ -44,8 +44,8 @@ typedef struct {
uint64_t
version
;
uint64_t
version
;
int64_t
fileId
;
int64_t
fileId
;
int64_t
rid
;
int64_t
rid
;
int64_t
tfd
;
int32_t
vgId
;
int32_t
vgId
;
int32_t
fd
;
int32_t
keep
;
int32_t
keep
;
int32_t
level
;
int32_t
level
;
int32_t
fsyncPeriod
;
int32_t
fsyncPeriod
;
...
...
src/wal/src/walMgmt.c
浏览文件 @
88c11ce7
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include "os.h"
#include "os.h"
#include "taoserror.h"
#include "taoserror.h"
#include "tref.h"
#include "tref.h"
#include "tfile.h"
#include "twal.h"
#include "twal.h"
#include "walInt.h"
#include "walInt.h"
...
@@ -61,7 +62,7 @@ void *walOpen(char *path, SWalCfg *pCfg) {
...
@@ -61,7 +62,7 @@ void *walOpen(char *path, SWalCfg *pCfg) {
}
}
pWal
->
vgId
=
pCfg
->
vgId
;
pWal
->
vgId
=
pCfg
->
vgId
;
pWal
->
fd
=
-
1
;
pWal
->
t
fd
=
-
1
;
pWal
->
fileId
=
-
1
;
pWal
->
fileId
=
-
1
;
pWal
->
level
=
pCfg
->
walLevel
;
pWal
->
level
=
pCfg
->
walLevel
;
pWal
->
keep
=
pCfg
->
keep
;
pWal
->
keep
=
pCfg
->
keep
;
...
@@ -124,7 +125,7 @@ void walClose(void *handle) {
...
@@ -124,7 +125,7 @@ void walClose(void *handle) {
SWal
*
pWal
=
handle
;
SWal
*
pWal
=
handle
;
pthread_mutex_lock
(
&
pWal
->
mutex
);
pthread_mutex_lock
(
&
pWal
->
mutex
);
t
aosClose
(
pWal
->
fd
);
t
fClose
(
pWal
->
t
fd
);
pthread_mutex_unlock
(
&
pWal
->
mutex
);
pthread_mutex_unlock
(
&
pWal
->
mutex
);
taosRemoveRef
(
tsWal
.
refId
,
pWal
->
rid
);
taosRemoveRef
(
tsWal
.
refId
,
pWal
->
rid
);
}
}
...
@@ -143,7 +144,7 @@ static void walFreeObj(void *wal) {
...
@@ -143,7 +144,7 @@ static void walFreeObj(void *wal) {
SWal
*
pWal
=
wal
;
SWal
*
pWal
=
wal
;
wDebug
(
"vgId:%d, wal:%p is freed"
,
pWal
->
vgId
,
pWal
);
wDebug
(
"vgId:%d, wal:%p is freed"
,
pWal
->
vgId
,
pWal
);
t
aosClose
(
pWal
->
fd
);
t
fClose
(
pWal
->
t
fd
);
pthread_mutex_destroy
(
&
pWal
->
mutex
);
pthread_mutex_destroy
(
&
pWal
->
mutex
);
tfree
(
pWal
);
tfree
(
pWal
);
}
}
...
@@ -172,7 +173,7 @@ static void walFsyncAll() {
...
@@ -172,7 +173,7 @@ static void walFsyncAll() {
while
(
pWal
)
{
while
(
pWal
)
{
if
(
walNeedFsync
(
pWal
))
{
if
(
walNeedFsync
(
pWal
))
{
wTrace
(
"vgId:%d, do fsync, level:%d seq:%d rseq:%d"
,
pWal
->
vgId
,
pWal
->
level
,
pWal
->
fsyncSeq
,
tsWal
.
seq
);
wTrace
(
"vgId:%d, do fsync, level:%d seq:%d rseq:%d"
,
pWal
->
vgId
,
pWal
->
level
,
pWal
->
fsyncSeq
,
tsWal
.
seq
);
int32_t
code
=
fsync
(
pWal
->
fd
);
int32_t
code
=
tfFsync
(
pWal
->
t
fd
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
wError
(
"vgId:%d, file:%s, failed to fsync since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
code
));
wError
(
"vgId:%d, file:%s, failed to fsync since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
code
));
}
}
...
...
src/wal/src/walWrite.c
浏览文件 @
88c11ce7
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include "os.h"
#include "os.h"
#include "taoserror.h"
#include "taoserror.h"
#include "tchecksum.h"
#include "tchecksum.h"
#include "tfile.h"
#include "twal.h"
#include "twal.h"
#include "walInt.h"
#include "walInt.h"
...
@@ -36,8 +37,8 @@ int32_t walRenew(void *handle) {
...
@@ -36,8 +37,8 @@ int32_t walRenew(void *handle) {
pthread_mutex_lock
(
&
pWal
->
mutex
);
pthread_mutex_lock
(
&
pWal
->
mutex
);
if
(
pWal
->
fd
>=
0
)
{
if
(
tfValid
(
pWal
->
tfd
)
)
{
t
close
(
pWal
->
fd
);
t
fClose
(
pWal
->
t
fd
);
wDebug
(
"vgId:%d, file:%s, it is closed"
,
pWal
->
vgId
,
pWal
->
name
);
wDebug
(
"vgId:%d, file:%s, it is closed"
,
pWal
->
vgId
,
pWal
->
name
);
}
}
...
@@ -49,9 +50,9 @@ int32_t walRenew(void *handle) {
...
@@ -49,9 +50,9 @@ int32_t walRenew(void *handle) {
}
}
snprintf
(
pWal
->
name
,
sizeof
(
pWal
->
name
),
"%s/%s%"
PRId64
,
pWal
->
path
,
WAL_PREFIX
,
pWal
->
fileId
);
snprintf
(
pWal
->
name
,
sizeof
(
pWal
->
name
),
"%s/%s%"
PRId64
,
pWal
->
path
,
WAL_PREFIX
,
pWal
->
fileId
);
pWal
->
fd
=
open
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
pWal
->
tfd
=
tfOpenM
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
pWal
->
fd
<
0
)
{
if
(
!
tfValid
(
pWal
->
tfd
)
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"vgId:%d, file:%s, failed to open since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
errno
));
wError
(
"vgId:%d, file:%s, failed to open since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
errno
));
}
else
{
}
else
{
...
@@ -67,7 +68,7 @@ void walRemoveOneOldFile(void *handle) {
...
@@ -67,7 +68,7 @@ void walRemoveOneOldFile(void *handle) {
SWal
*
pWal
=
handle
;
SWal
*
pWal
=
handle
;
if
(
pWal
==
NULL
)
return
;
if
(
pWal
==
NULL
)
return
;
if
(
pWal
->
keep
==
TAOS_WAL_KEEP
)
return
;
if
(
pWal
->
keep
==
TAOS_WAL_KEEP
)
return
;
if
(
pWal
->
fd
<=
0
)
return
;
if
(
!
tfValid
(
pWal
->
tfd
)
)
return
;
pthread_mutex_lock
(
&
pWal
->
mutex
);
pthread_mutex_lock
(
&
pWal
->
mutex
);
...
@@ -113,7 +114,7 @@ int32_t walWrite(void *handle, SWalHead *pHead) {
...
@@ -113,7 +114,7 @@ int32_t walWrite(void *handle, SWalHead *pHead) {
int32_t
code
=
0
;
int32_t
code
=
0
;
// no wal
// no wal
if
(
pWal
->
fd
<=
0
)
return
0
;
if
(
!
tfValid
(
pWal
->
tfd
)
)
return
0
;
if
(
pWal
->
level
==
TAOS_WAL_NOLOG
)
return
0
;
if
(
pWal
->
level
==
TAOS_WAL_NOLOG
)
return
0
;
if
(
pHead
->
version
<=
pWal
->
version
)
return
0
;
if
(
pHead
->
version
<=
pWal
->
version
)
return
0
;
...
@@ -123,12 +124,12 @@ int32_t walWrite(void *handle, SWalHead *pHead) {
...
@@ -123,12 +124,12 @@ int32_t walWrite(void *handle, SWalHead *pHead) {
pthread_mutex_lock
(
&
pWal
->
mutex
);
pthread_mutex_lock
(
&
pWal
->
mutex
);
if
(
t
aosWrite
(
pWal
->
fd
,
pHead
,
contLen
)
!=
contLen
)
{
if
(
t
fWrite
(
pWal
->
t
fd
,
pHead
,
contLen
)
!=
contLen
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
TAOS_SYSTEM_ERROR
(
errno
);
wError
(
"vgId:%d, file:%s, failed to write since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
errno
));
wError
(
"vgId:%d, file:%s, failed to write since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
errno
));
}
else
{
}
else
{
wTrace
(
"vgId:%d, write wal, fileId:%"
PRId64
"
fd:%d
hver:%"
PRId64
" wver:%"
PRIu64
" len:%d"
,
pWal
->
vgId
,
wTrace
(
"vgId:%d, write wal, fileId:%"
PRId64
"
tfd:%"
PRId64
"
hver:%"
PRId64
" wver:%"
PRIu64
" len:%d"
,
pWal
->
vgId
,
pWal
->
fileId
,
pWal
->
fd
,
pHead
->
version
,
pWal
->
version
,
pHead
->
len
);
pWal
->
fileId
,
pWal
->
t
fd
,
pHead
->
version
,
pWal
->
version
,
pHead
->
len
);
pWal
->
version
=
pHead
->
version
;
pWal
->
version
=
pHead
->
version
;
}
}
...
@@ -141,11 +142,11 @@ int32_t walWrite(void *handle, SWalHead *pHead) {
...
@@ -141,11 +142,11 @@ int32_t walWrite(void *handle, SWalHead *pHead) {
void
walFsync
(
void
*
handle
,
bool
forceFsync
)
{
void
walFsync
(
void
*
handle
,
bool
forceFsync
)
{
SWal
*
pWal
=
handle
;
SWal
*
pWal
=
handle
;
if
(
pWal
==
NULL
||
pWal
->
fd
<
0
)
return
;
if
(
pWal
==
NULL
||
!
tfValid
(
pWal
->
tfd
)
)
return
;
if
(
forceFsync
||
(
pWal
->
level
==
TAOS_WAL_FSYNC
&&
pWal
->
fsyncPeriod
==
0
))
{
if
(
forceFsync
||
(
pWal
->
level
==
TAOS_WAL_FSYNC
&&
pWal
->
fsyncPeriod
==
0
))
{
wTrace
(
"vgId:%d, fileId:%"
PRId64
", do fsync"
,
pWal
->
vgId
,
pWal
->
fileId
);
wTrace
(
"vgId:%d, fileId:%"
PRId64
", do fsync"
,
pWal
->
vgId
,
pWal
->
fileId
);
if
(
fsync
(
pWal
->
fd
)
<
0
)
{
if
(
tfFsync
(
pWal
->
t
fd
)
<
0
)
{
wError
(
"vgId:%d, fileId:%"
PRId64
", fsync failed since %s"
,
pWal
->
vgId
,
pWal
->
fileId
,
strerror
(
errno
));
wError
(
"vgId:%d, fileId:%"
PRId64
", fsync failed since %s"
,
pWal
->
vgId
,
pWal
->
fileId
,
strerror
(
errno
));
}
}
}
}
...
@@ -186,8 +187,8 @@ int32_t walRestore(void *handle, void *pVnode, FWalWrite writeFp) {
...
@@ -186,8 +187,8 @@ int32_t walRestore(void *handle, void *pVnode, FWalWrite writeFp) {
// open the existing WAL file in append mode
// open the existing WAL file in append mode
pWal
->
fileId
=
0
;
pWal
->
fileId
=
0
;
snprintf
(
pWal
->
name
,
sizeof
(
pWal
->
name
),
"%s/%s%"
PRId64
,
pWal
->
path
,
WAL_PREFIX
,
pWal
->
fileId
);
snprintf
(
pWal
->
name
,
sizeof
(
pWal
->
name
),
"%s/%s%"
PRId64
,
pWal
->
path
,
WAL_PREFIX
,
pWal
->
fileId
);
pWal
->
fd
=
open
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
|
O_APPEND
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
pWal
->
tfd
=
tfOpenM
(
pWal
->
name
,
O_WRONLY
|
O_CREAT
|
O_APPEND
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
pWal
->
fd
<
0
)
{
if
(
!
tfValid
(
pWal
->
tfd
)
)
{
wError
(
"vgId:%d, file:%s, failed to open since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
errno
));
wError
(
"vgId:%d, file:%s, failed to open since %s"
,
pWal
->
vgId
,
pWal
->
name
,
strerror
(
errno
));
return
TAOS_SYSTEM_ERROR
(
errno
);
return
TAOS_SYSTEM_ERROR
(
errno
);
}
}
...
@@ -211,28 +212,28 @@ int32_t walGetWalFile(void *handle, char *fileName, int64_t *fileId) {
...
@@ -211,28 +212,28 @@ 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
;
}
}
static
void
walFtruncate
(
SWal
*
pWal
,
int
32_t
fd
,
int64_t
offset
)
{
static
void
walFtruncate
(
SWal
*
pWal
,
int
64_t
t
fd
,
int64_t
offset
)
{
t
aosFtruncate
(
fd
,
offset
);
t
fFtruncate
(
t
fd
,
offset
);
fsync
(
fd
);
tfFsync
(
t
fd
);
}
}
static
int32_t
walSkipCorruptedRecord
(
SWal
*
pWal
,
SWalHead
*
pHead
,
int
32_t
fd
,
int64_t
*
offset
)
{
static
int32_t
walSkipCorruptedRecord
(
SWal
*
pWal
,
SWalHead
*
pHead
,
int
64_t
t
fd
,
int64_t
*
offset
)
{
int64_t
pos
=
*
offset
;
int64_t
pos
=
*
offset
;
while
(
1
)
{
while
(
1
)
{
pos
++
;
pos
++
;
if
(
lseek
(
fd
,
pos
,
SEEK_SET
)
<
0
)
{
if
(
tfLseek
(
t
fd
,
pos
,
SEEK_SET
)
<
0
)
{
wError
(
"vgId:%d, failed to seek from corrupted wal file since %s"
,
pWal
->
vgId
,
strerror
(
errno
));
wError
(
"vgId:%d, failed to seek from corrupted wal file since %s"
,
pWal
->
vgId
,
strerror
(
errno
));
return
TSDB_CODE_WAL_FILE_CORRUPTED
;
return
TSDB_CODE_WAL_FILE_CORRUPTED
;
}
}
if
(
t
aosRead
(
fd
,
pHead
,
sizeof
(
SWalHead
))
<=
0
)
{
if
(
t
fRead
(
t
fd
,
pHead
,
sizeof
(
SWalHead
))
<=
0
)
{
wError
(
"vgId:%d, read to end of corrupted wal file, offset:%"
PRId64
,
pWal
->
vgId
,
pos
);
wError
(
"vgId:%d, read to end of corrupted wal file, offset:%"
PRId64
,
pWal
->
vgId
,
pos
);
return
TSDB_CODE_WAL_FILE_CORRUPTED
;
return
TSDB_CODE_WAL_FILE_CORRUPTED
;
}
}
...
@@ -259,8 +260,8 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
...
@@ -259,8 +260,8 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
return
TAOS_SYSTEM_ERROR
(
errno
);
return
TAOS_SYSTEM_ERROR
(
errno
);
}
}
int
32_t
fd
=
o
pen
(
name
,
O_RDWR
);
int
64_t
tfd
=
tfO
pen
(
name
,
O_RDWR
);
if
(
fd
<
0
)
{
if
(
!
tfValid
(
tfd
)
)
{
wError
(
"vgId:%d, file:%s, failed to open for restore since %s"
,
pWal
->
vgId
,
name
,
strerror
(
errno
));
wError
(
"vgId:%d, file:%s, failed to open for restore since %s"
,
pWal
->
vgId
,
name
,
strerror
(
errno
));
tfree
(
buffer
);
tfree
(
buffer
);
return
TAOS_SYSTEM_ERROR
(
errno
);
return
TAOS_SYSTEM_ERROR
(
errno
);
...
@@ -273,7 +274,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
...
@@ -273,7 +274,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
SWalHead
*
pHead
=
buffer
;
SWalHead
*
pHead
=
buffer
;
while
(
1
)
{
while
(
1
)
{
int32_t
ret
=
t
aosRead
(
fd
,
pHead
,
sizeof
(
SWalHead
));
int32_t
ret
=
t
fRead
(
t
fd
,
pHead
,
sizeof
(
SWalHead
));
if
(
ret
==
0
)
break
;
if
(
ret
==
0
)
break
;
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
...
@@ -284,16 +285,16 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
...
@@ -284,16 +285,16 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
if
(
ret
<
sizeof
(
SWalHead
))
{
if
(
ret
<
sizeof
(
SWalHead
))
{
wError
(
"vgId:%d, file:%s, failed to read wal head, ret is %d"
,
pWal
->
vgId
,
name
,
ret
);
wError
(
"vgId:%d, file:%s, failed to read wal head, ret is %d"
,
pWal
->
vgId
,
name
,
ret
);
walFtruncate
(
pWal
,
fd
,
offset
);
walFtruncate
(
pWal
,
t
fd
,
offset
);
break
;
break
;
}
}
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)
pHead
,
sizeof
(
SWalHead
)))
{
if
(
!
taosCheckChecksumWhole
((
uint8_t
*
)
pHead
,
sizeof
(
SWalHead
)))
{
wError
(
"vgId:%d, file:%s, wal head cksum is messed up, hver:%"
PRIu64
" len:%d offset:%"
PRId64
,
pWal
->
vgId
,
name
,
wError
(
"vgId:%d, file:%s, wal head cksum is messed up, hver:%"
PRIu64
" len:%d offset:%"
PRId64
,
pWal
->
vgId
,
name
,
pHead
->
version
,
pHead
->
len
,
offset
);
pHead
->
version
,
pHead
->
len
,
offset
);
code
=
walSkipCorruptedRecord
(
pWal
,
pHead
,
fd
,
&
offset
);
code
=
walSkipCorruptedRecord
(
pWal
,
pHead
,
t
fd
,
&
offset
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
walFtruncate
(
pWal
,
fd
,
offset
);
walFtruncate
(
pWal
,
t
fd
,
offset
);
break
;
break
;
}
}
}
}
...
@@ -310,7 +311,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
...
@@ -310,7 +311,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
pHead
=
buffer
;
pHead
=
buffer
;
}
}
ret
=
t
aosRead
(
fd
,
pHead
->
cont
,
pHead
->
len
);
ret
=
t
fRead
(
t
fd
,
pHead
->
cont
,
pHead
->
len
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
wError
(
"vgId:%d, file:%s, failed to read wal body since %s"
,
pWal
->
vgId
,
name
,
strerror
(
errno
));
wError
(
"vgId:%d, file:%s, failed to read wal body since %s"
,
pWal
->
vgId
,
name
,
strerror
(
errno
));
code
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
TAOS_SYSTEM_ERROR
(
errno
);
...
@@ -325,14 +326,14 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
...
@@ -325,14 +326,14 @@ 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
;
(
*
writeFp
)(
pVnode
,
pHead
,
TAOS_QTYPE_WAL
,
NULL
);
(
*
writeFp
)(
pVnode
,
pHead
,
TAOS_QTYPE_WAL
,
NULL
);
}
}
t
close
(
fd
);
t
fClose
(
t
fd
);
tfree
(
buffer
);
tfree
(
buffer
);
return
code
;
return
code
;
...
...
tests/script/basicSuite.sim
浏览文件 @
88c11ce7
...
@@ -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/parser/col_arithmetic_operation.sim
浏览文件 @
88c11ce7
...
@@ -117,16 +117,17 @@ run general/parser/col_arithmetic_query.sim
...
@@ -117,16 +117,17 @@ run general/parser/col_arithmetic_query.sim
# ================================================================================================
# ================================================================================================
print ====================> crash
print ====================> crash
# sql select spread(ts )/(1000*3600*24) from ca_stb0 interval(1y)
sql use $db
sql select spread(ts )/(1000*3600*24) from $stb interval(1y)
sql_error select first(c1, c2) - last(c1, c2) from stb interval(1y)
sql_error select first(ts) - last(ts) from stb interval(1y)
sql_error select first(c1, c2) - last(c1, c2) from $stb interval(1y)
sql_error select top(c1, 2) - last(c1) from stb;
sql_error select first(ts) - last(ts) from $stb interval(1y)
sql_error select stddev(c1) - last(c1) from stb;
sql_error select top(c1, 2) - last(c1) from $stb;
sql_error select diff(c1) - last(c1) from stb;
sql_error select stddev(c1) - last(c1) from $stb;
sql_error select first(c7) - last(c7) from stb;
sql_error select diff(c1) - last(c1) from $stb;
sql_error select first(c8) - last(c8) from stb;
sql_error select first(c7) - last(c7) from $stb;
sql_error select first(c9) - last(c9) from stb;
sql_error select first(c8) - last(c8) from $stb;
sql_error select first(c9) - last(c9) from $stb;
sql_error select max(c2*2) from $tb
sql_error select max(c2*2) from $tb
sql_error select max(c1-c2) from $tb
sql_error select max(c1-c2) from $tb
...
...
tests/script/general/parser/col_arithmetic_query.sim
浏览文件 @
88c11ce7
...
@@ -62,24 +62,73 @@ if $data91 != 1.000000000 then
...
@@ -62,24 +62,73 @@ if $data91 != 1.000000000 then
return -1
return -1
endi
endi
sql select (c1 * 2) % 7.9 from $tb order by ts desc;
sql select (c1 * 2) % 7.9
, c1*1, c1*1*1, c1*c1, c1*c1*c1
from $tb order by ts desc;
if $rows != 10000 then
if $rows != 10000 then
return -1
return -1
endi
endi
if $data00 !=
0.1
00000000 then
if $data00 !=
2.2
00000000 then
print expect
0.100000000, acut
al:$data00
print expect
2.200000000, actu
al:$data00
return -1
return -1
endi
endi
if $data
10 != 2.1
00000000 then
if $data
01 != 9.0
00000000 then
return -1
return -1
endi
endi
if $data90 != 6.000000000 then
if $data02 != 9.000000000 then
return -1
endi
if $data03 != 81.000000000 then
return -1
endi
if $data04 != 729.000000000 then
return -1
endi
if $data10 != 0.200000000 then
return -1
endi
if $data11 != 8.000000000 then
return -1
endi
if $data12 != 8.000000000 then
return -1
endi
if $data13 != 64.000000000 then
return -1
endi
if $data14 != 512.000000000 then
return -1
endi
if $data90 != 0.000000000 then
return -1
return -1
endi
endi
if $data91 != 0.000000000 then
return -1
endi
if $data92 != 0.000000000 then
return -1
endi
if $data93 != 0.000000000 then
return -1
endi
if $data94 != 0.000000000 then
return -1
endi
# [d.3]
# [d.3]
sql select c1 * c2 /4 from $tb where ts < 1537166000000 and ts > 1537156000000
sql select c1 * c2 /4 from $tb where ts < 1537166000000 and ts > 1537156000000
if $rows != 17 then
if $rows != 17 then
...
@@ -95,7 +144,7 @@ if $data10 != 16.000000000 then
...
@@ -95,7 +144,7 @@ if $data10 != 16.000000000 then
endi
endi
if $data20 != 20.250000000 then
if $data20 != 20.250000000 then
print expect 20.250000000, ac
ut
al:$data21
print expect 20.250000000, ac
tu
al:$data21
return -1
return -1
endi
endi
...
@@ -320,7 +369,9 @@ sql_error select c7-c9 from $tb interval(2y)
...
@@ -320,7 +369,9 @@ sql_error select c7-c9 from $tb interval(2y)
# multiple retrieve [d.20]===============================================================
# multiple retrieve [d.20]===============================================================
sql select c2-c2, 911 from $tb
sql select c2-c2, 911 from $tb
#======================================= aggregation function arithmetic query cases ================
#======================================= aggregation function arithmetic query cases ===================================
# on $tb percentile() spread(ts) bug
# asc/desc order [d.2]
# asc/desc order [d.2]
sql select first(c1) * ( 2 / 3 ) from $stb order by ts asc;
sql select first(c1) * ( 2 / 3 ) from $stb order by ts asc;
if $rows != 1 then
if $rows != 1 then
...
@@ -349,11 +400,11 @@ if $data00 != 1.800000000 then
...
@@ -349,11 +400,11 @@ if $data00 != 1.800000000 then
return -1
return -1
endi
endi
if $data01 != 100000 then
if $data01 != 100000
.000000000
then
return -1
return -1
endi
endi
if $data02 != 200000 then
if $data02 != 200000
.000000000
then
return -1
return -1
endi
endi
...
@@ -374,77 +425,192 @@ if $data02 != 9.000000020 then
...
@@ -374,77 +425,192 @@ if $data02 != 9.000000020 then
return -1
return -1
endi
endi
# all possible function in the arithmetic expressioin
# all possible function in the arithmetic expression, add more
sql select min(c1) * max(c2) /4, sum(c1) * percentile(c2, 20), apercentile(c4, 33) + 52/9, spread(c5)/min(c2) from $stb where ts < and ts >
sql select min(c1) * max(c2) /4, sum(c1) * apercentile(c2, 20), apercentile(c4, 33) + 52/9, spread(c5)/min(c2), count(1)/sum(c1), avg(c2)*count(c2) from $stb where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-11-25 19:30:00.000';
if $rows != 1 then
return -1
endi
# no result return [d.3]
if $data00 != 0.000000000 then
return -1
endi
if $data01 != 225000.000000000 then
return -1
endi
if $data02 != 8.077777778 then
return -1
endi
if $data03 != inf then
return -1
endi
if $data04 != 0.444444444 then
return -1
endi
if $data05 != 450000.000000000 then
return -1
endi
# no result return [d.3]===============================================================
sql select first(c1) * 91 - 7, last(c3) from $stb where ts < 1537146000000
sql select first(c1) * 91 - 7, last(c3) from $stb where ts < 1537146000000
if $rows != 0 then
if $rows != 0 then
return -1
return -1
endi
endi
# no result return [d.3]
# no result return [d.3]
sql select sum(c2) - avg(c2) from $
tb where ts>xxx
sql select sum(c2) - avg(c2) from $
stb where ts > '2018-11-25 19:30:00.000'
if $rows != 0 then
if $rows != 0 then
return -1
return -1
endi
endi
# single row result aggregation [d.4]
# single row result aggregation [d.4]
===================================================
sql select
# all those cases are aggregation test cases.
# error cases
# error cases
sql_error select first(c1, c2) - last(c1, c2) from $tb
sql_error select first(c1, c2) - last(c1, c2) from $stb
sql_error select top(c1, 5) - bottom(c1, 5) from $stb
sql_error select first(*) - 99 from $stb
# multi row result aggregation [d.4]
# multi row result aggregation [d.4]
sql select top(c1, 1) - bottom(c1, 1) from $tb
sql_error select top(c1, 1) - bottom(c1, 1) from $stb
sql select top(c1, 99) - bottom(c1, 99) from $tb
sql_error select top(c1, 99) - bottom(c1, 99) from $stb
# query on super table [d.5]=============================================================
# all cases in this part are query on super table
# all data types [d.6]
# all data types [d.6]
===================================================================
sql select c2-c1, c3/c2, c4*c3, c5%c4, c6+99%22 from $tb
sql select c2-c1, c3/c2, c4*c3, c5%c4, c6+99%22 from $
s
tb
# error case, ts/bool/binary/nchar not support arithmetic expression
# error case, ts/bool/binary/nchar not support arithmetic expression
sql_error select ts+ts from $tb
sql_error select first(c7)*12 from $stb
sql_error select ts+22 from $tb
sql_error select last(c8)/55 from $stb
sql_error select c7*12 from $tb
sql_error select last_row(c9) + last_row(c8) from $stb
sql_error select c8/55 from $tb
sql_error select c9+c8 from $tb
# arithmetic expression in join [d.7]
# arithmetic expression in join [d.7]
===============================================================
# arithmetic expression in union [d.8]
# arithmetic expression in union [d.8]
===============================================================
# arithmetic expression in group by [d.9]
# arithmetic expression in group by [d.9]
===============================================================
# in group by tag
# in group by tag
# not support for normal table
sql select avg(c4)*99 from $stb group by t1
sql_error select c5*99 from $tb group by t1
if $rows != 10 then
return -1
endi
if $data00 != 445.500000000 then
return -1
endi
if $data01 != 0 then
return -1
endi
if $data90 != 445.500000000 then
return -1
endi
if $data91 != 9 then
return -1
endi
# in group by column
# in group by column
sql_error select c6-c6+c3*12 from $tb group by c3;
sql select apercentile(c6, 50)-first(c6)+last(c5)*12, last(c5)*12 from ca_stb0 group by c2;
if $rows != 10 then
return -1
endi
if $data00 != 0.000000000 then
return -1
endi
sql select first(c6) - last(c6) *12 / count(*) from $tb group by c3;
if $data01 != 0.000000000 then
return -1
endi
# limit offset [d.10]
if $data10 != 12.000000000 then
sql select c6-c6+12 from $tb limit 12 offset 99;
return -1
sql select c4/99.123 from $tb limit 1 offset 9999;
endi
# slimit/soffset not suport for normal table query. [d.11]
if $data11 != 12.000000000 then
sql_error select sum(c1) from $tb slimit 1 soffset 19;
return -1
endi
if $data20 != 24.000000000 then
return -1
endi
if $data21 != 24.000000000 then
return -1
endi
sql_error select first(c6) - last(c6) *12 / count(*) from $stb group by c3;
sql select first(c6) - last(c6) *12 / count(*) from $stb group by c5;
if $rows != 10 then
return -1
endi
if $data00 != 0.000000000 then
return -1
endi
if $data10 != 0.997600000 then
return -1
endi
if $data90 != 8.978400000 then
return -1
endi
# limit offset [d.10]===============================================================
sql select first(c6) - sum(c6) + 12 from $stb limit 12 offset 0;
if $rows != 1 then
return -1
endi
if $data00 != -449988.000000000 then
return -1
endi
sql select apercentile(c4, 21) / 99.123 from $stb limit 1 offset 1;
if $rows != 0 then
return -1
endi
sql select apercentile(c4, 21) / sum(c4) from $stb interval(1s) limit 1 offset 1;
if $rows != 1 then
return -1
endi
# slimit/soffset not support for normal table query. [d.11]===============================================================
sql select sum(c1) from $stb slimit 1 soffset 19;
if $rows != 0 then
return -1
endi
# fill [d.12]
sql select sum(c1) from $stb interval(1s) group by tbname slimit 1 soffset 1
sql
_error select c2-c2, c3-c4, c5%c6 from $tb fill(value, 12);
sql
select sum(c1) from ca_stb0 interval(1s) group by tbname slimit 2 soffset 4 limit 10 offset 1
# constant column. [d.13]
# fill [d.12]===============================================================
sql_error select first(c1)-last(c1), sum(c3)*count(c3), spread(c5 ) % count(*) from $stb interval(1s) fill(prev);
sql_error select first(c1) from $stb fill(value, 20);
# constant column. [d.13]===============================================================
# column value filter [d.14]
# column value filter [d.14]===============================================================
# tag filter(not support for normal table). [d.15]
sql_error select sum(c2)+99 from $tb where t1=12;
# multi-field output [d.16]
# tag filter. [d.15]===============================================================
sql select sum(c2)+99 from $stb where t1=12;
# multi-field output [d.16]===============================================================
sql select count(*), sum(c1)*avg(c2), avg(c3)*count(c3), sum(c3), sum(c4), first(c7), last(c8), first(c9), first(c7), last(c8) from $tb
sql select count(*), sum(c1)*avg(c2), avg(c3)*count(c3), sum(c3), sum(c4), first(c7), last(c8), first(c9), first(c7), last(c8) from $tb
sql select c4*1+1/2 from $tb
sql select c4*1+1/2 from $tb
...
@@ -461,18 +627,30 @@ if $data90 != 9.500000000 then
...
@@ -461,18 +627,30 @@ if $data90 != 9.500000000 then
return -1
return -1
endi
endi
# interval query [d.17]
# interval query [d.17]===============================================================
sql_error select c2*c2, c3-c3, c4+9 from $tb interval(1s)
sql select avg(c2)*count(c2), sum(c3)-first(c3), last(c4)+9 from $stb interval(1s)
sql_error select c7-c9 from $tb interval(2y)
if $rows != 10000 then
return -1
endi
# aggregation query [d.18]
if $data00 != @18-09-17 09:00:00.000@ then
# see test cases below
return -1
endi
# first/last query [d.19]
sql_error select first(c7)- last(c1) from $tb interval(2y)
# see test cases below
# multiple retrieve [d.20]
# aggregation query [d.18]===============================================================
sql select c2-c2 from $tb;
# all cases in this part are aggregation query test.
# first/last query [d.19]===============================================================
# multiple retrieve [d.20]===============================================================
sql select c2-c2 from $tb
sql select first(c1)-last(c1), spread(c2), max(c3) - min(c3), avg(c4)*count(c4) from $tb
sql select first(c1)-last(c1), spread(c2), max(c3) - min(c3), avg(c4)*count(c4) from $tb
#====================================================super table query==================================================
tests/script/general/parser/limit1_tb.sim
浏览文件 @
88c11ce7
...
@@ -703,13 +703,13 @@ sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where t
...
@@ -703,13 +703,13 @@ sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where t
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != 4.
499549955
then
if $data00 != 4.
500000000
then
return -1
return -1
endi
endi
if $data02 != 4.
499549955
then
if $data02 != 4.
500000000
then
return -1
return -1
endi
endi
if $data05 != 4.
499549955
then
if $data05 != 4.
500000000
then
return -1
return -1
endi
endi
...
@@ -717,10 +717,12 @@ sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from
...
@@ -717,10 +717,12 @@ sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from
if $rows != 0 then
if $rows != 0 then
return -1
return -1
endi
endi
sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1
sql select first(c1), first(c2), first(c3), first(c4), first(c5), first(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1
if $rows != 3 then
if $rows != 3 then
return -1
return -1
endi
endi
if $data01 != 3 then
if $data01 != 3 then
return -1
return -1
endi
endi
...
@@ -731,7 +733,6 @@ if $data23 != 9.00000 then
...
@@ -731,7 +733,6 @@ if $data23 != 9.00000 then
return -1
return -1
endi
endi
sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1
sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu limit 5 offset 1
if $rows != 0 then
if $rows != 0 then
return -1
return -1
...
...
tests/script/general/parser/limit_tb.sim
浏览文件 @
88c11ce7
...
@@ -327,22 +327,22 @@ sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where t
...
@@ -327,22 +327,22 @@ sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where t
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != 4.
0
00000000 then
if $data00 != 4.
5
00000000 then
return -1
return -1
endi
endi
if $data01 != 4.
0
00000000 then
if $data01 != 4.
5
00000000 then
return -1
return -1
endi
endi
if $data02 != 4.
0
00000000 then
if $data02 != 4.
5
00000000 then
return -1
return -1
endi
endi
if $data03 != 4.
0
00000000 then
if $data03 != 4.
5
00000000 then
return -1
return -1
endi
endi
if $data04 != 4.
0
00000000 then
if $data04 != 4.
5
00000000 then
return -1
return -1
endi
endi
if $data05 != 4.
0
00000000 then
if $data05 != 4.
5
00000000 then
return -1
return -1
endi
endi
...
@@ -690,13 +690,13 @@ sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where t
...
@@ -690,13 +690,13 @@ sql select twa(c1), twa(c2), twa(c3), twa(c4), twa(c5), twa(c6) from $tb where t
if $rows != 1 then
if $rows != 1 then
return -1
return -1
endi
endi
if $data00 != 4.
0
00000000 then
if $data00 != 4.
5
00000000 then
return -1
return -1
endi
endi
if $data02 != 4.
0
00000000 then
if $data02 != 4.
5
00000000 then
return -1
return -1
endi
endi
if $data05 != 4.
0
00000000 then
if $data05 != 4.
5
00000000 then
return -1
return -1
endi
endi
...
...
tests/script/general/parser/where.sim
浏览文件 @
88c11ce7
...
@@ -131,7 +131,6 @@ if $data00 != $rowNum then
...
@@ -131,7 +131,6 @@ if $data00 != $rowNum then
return -1
return -1
endi
endi
## like
## like
sql_error select * from $mt where c1 like 1
sql_error select * from $mt where c1 like 1
#sql_error select * from $mt where t1 like 1
#sql_error select * from $mt where t1 like 1
...
@@ -178,7 +177,8 @@ sql create table wh_mt2_tb1 using wh_mt2 tags ('wh_mt2_tb1')
...
@@ -178,7 +177,8 @@ sql create table wh_mt2_tb1 using wh_mt2 tags ('wh_mt2_tb1')
# 2019-01-01 09:00:00.000 1546304400000
# 2019-01-01 09:00:00.000 1546304400000
# 2019-01-01 09:10:00.000 1546305000000
# 2019-01-01 09:10:00.000 1546305000000
sql insert into wh_mt2_tb1 values ('2019-01-01 00:00:00.000', '2019-01-01 09:00:00.000', 'binary10', 'nchar10')
sql insert into wh_mt2_tb1 values ('2019-01-01 00:00:00.000', '2019-01-01 09:00:00.000', 'binary10', 'nchar10')
sql insert into wh_mt2_tb1 values ('2019-01-01 00:10:00.000', '2019-01-01 09:10:00.000', 'binary10', 'nchar10')
sql insert into wh_mt2_tb1 values ('2019-01-01 00:10:00.000', '2019-01-01 09:10:00.000', 'binary10', 'nchar10')
sql select * from wh_mt2_tb1 where c1 > 1546304400000
sql select * from wh_mt2_tb1 where c1 > 1546304400000
if $rows != 1 then
if $rows != 1 then
return -1
return -1
...
...
tests/script/general/wal/sync.sim
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
...
@@ -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
浏览文件 @
88c11ce7
/*
* 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录