Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fbc69a10
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fbc69a10
编写于
8月 18, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into feature/TD-14761
上级
44ce4f1c
8681f639
变更
46
展开全部
隐藏空白更改
内联
并排
Showing
46 changed file
with
1080 addition
and
427 deletion
+1080
-427
Jenkinsfile2
Jenkinsfile2
+1
-0
examples/c/stream_demo.c
examples/c/stream_demo.c
+3
-4
include/common/tcommon.h
include/common/tcommon.h
+1
-0
include/common/tmsg.h
include/common/tmsg.h
+4
-0
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-0
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+5
-1
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-0
include/util/taoserror.h
include/util/taoserror.h
+2
-0
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+1
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+1
-0
source/dnode/mnode/impl/inc/mndStb.h
source/dnode/mnode/impl/inc/mndStb.h
+1
-0
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+19
-0
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+2
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+22
-10
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+12
-1
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+1
-0
source/dnode/vnode/src/inc/sma.h
source/dnode/vnode/src/inc/sma.h
+44
-28
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+1
-0
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-0
source/dnode/vnode/src/sma/smaCommit.c
source/dnode/vnode/src/sma/smaCommit.c
+97
-71
source/dnode/vnode/src/sma/smaEnv.c
source/dnode/vnode/src/sma/smaEnv.c
+14
-9
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+535
-123
source/dnode/vnode/src/sma/smaSnapshot.c
source/dnode/vnode/src/sma/smaSnapshot.c
+3
-3
source/dnode/vnode/src/sma/smaTimeRange.c
source/dnode/vnode/src/sma/smaTimeRange.c
+1
-1
source/dnode/vnode/src/sma/smaUtil.c
source/dnode/vnode/src/sma/smaUtil.c
+14
-18
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+3
-11
source/dnode/vnode/src/tq/tqSink.c
source/dnode/vnode/src/tq/tqSink.c
+22
-20
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+0
-26
source/dnode/vnode/src/vnd/vnodeBufPool.c
source/dnode/vnode/src/vnd/vnodeBufPool.c
+10
-2
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+4
-4
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+19
-0
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+5
-1
source/libs/executor/inc/tsimplehash.h
source/libs/executor/inc/tsimplehash.h
+30
-12
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+1
-1
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+1
-1
source/libs/executor/src/tsimplehash.c
source/libs/executor/src/tsimplehash.c
+87
-48
source/libs/executor/test/tSimpleHashTests.cpp
source/libs/executor/test/tSimpleHashTests.cpp
+8
-6
source/libs/stream/inc/streamInc.h
source/libs/stream/inc/streamInc.h
+0
-1
source/libs/stream/src/stream.c
source/libs/stream/src/stream.c
+6
-2
source/libs/stream/src/streamMeta.c
source/libs/stream/src/streamMeta.c
+27
-6
source/libs/stream/src/streamQueue.c
source/libs/stream/src/streamQueue.c
+6
-3
source/libs/stream/src/streamTask.c
source/libs/stream/src/streamTask.c
+10
-2
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+1
-1
source/libs/sync/src/syncCommit.c
source/libs/sync/src/syncCommit.c
+32
-8
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+19
-3
source/util/src/terror.c
source/util/src/terror.c
+2
-0
未找到文件。
Jenkinsfile2
浏览文件 @
fbc69a10
...
@@ -43,6 +43,7 @@ def pre_test(){
...
@@ -43,6 +43,7 @@ def pre_test(){
cd ${WKC}
cd ${WKC}
git reset --hard
git reset --hard
git clean -fxd
git clean -fxd
rm -rf examples/rust/
git remote prune origin
git remote prune origin
git fetch
git fetch
'''
'''
...
...
examples/c/stream_demo.c
浏览文件 @
fbc69a10
...
@@ -98,10 +98,9 @@ int32_t create_stream() {
...
@@ -98,10 +98,9 @@ int32_t create_stream() {
/*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/
/*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
pRes
=
pRes
=
taos_query
(
pConn
,
taos_query
(
pConn
,
"create stream stream1 trigger max_delay 10s watermark 10s into outstb as select _wstart start, "
"create stream stream1 trigger max_delay 10s into outstb as select _wstart, sum(k) from st1 partition "
"count(k) from st1 partition by tbname interval(20s) "
);
"by tbname session(ts, 10s) "
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create stream stream1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"failed to create stream stream1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
return
-
1
;
...
...
include/common/tcommon.h
浏览文件 @
fbc69a10
...
@@ -60,6 +60,7 @@ enum {
...
@@ -60,6 +60,7 @@ enum {
STREAM_INPUT__DATA_RETRIEVE
,
STREAM_INPUT__DATA_RETRIEVE
,
STREAM_INPUT__GET_RES
,
STREAM_INPUT__GET_RES
,
STREAM_INPUT__CHECKPOINT
,
STREAM_INPUT__CHECKPOINT
,
STREAM_INPUT__DESTROY
,
};
};
typedef
enum
EStreamType
{
typedef
enum
EStreamType
{
...
...
include/common/tmsg.h
浏览文件 @
fbc69a10
...
@@ -2663,6 +2663,10 @@ typedef struct {
...
@@ -2663,6 +2663,10 @@ typedef struct {
SEpSet
epSet
;
SEpSet
epSet
;
}
SVgEpSet
;
}
SVgEpSet
;
typedef
struct
{
int32_t
padding
;
}
SRSmaExecMsg
;
typedef
struct
{
typedef
struct
{
int64_t
suid
;
int64_t
suid
;
int8_t
level
;
int8_t
level
;
...
...
include/common/tmsgdef.h
浏览文件 @
fbc69a10
...
@@ -202,6 +202,7 @@ enum {
...
@@ -202,6 +202,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_VND_DROP_SMA
,
"vnode-drop-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_DROP_SMA
,
"vnode-drop-sma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SUBMIT_RSMA
,
"vnode-submit-rsma"
,
SSubmitReq
,
SSubmitRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_SUBMIT_RSMA
,
"vnode-submit-rsma"
,
SSubmitReq
,
SSubmitRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_FETCH_RSMA
,
"vnode-fetch-rsma"
,
SRSmaFetchMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_FETCH_RSMA
,
"vnode-fetch-rsma"
,
SRSmaFetchMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_EXEC_RSMA
,
"vnode-exec-rsma"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_DELETE
,
"delete-data"
,
SVDeleteReq
,
SVDeleteRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_DELETE
,
"delete-data"
,
SVDeleteReq
,
SVDeleteRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_BATCH_DEL
,
"batch-delete"
,
SBatchDeleteReq
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_BATCH_DEL
,
"batch-delete"
,
SBatchDeleteReq
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_ALTER_CONFIG
,
"alter-config"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_ALTER_CONFIG
,
"alter-config"
,
NULL
,
NULL
)
...
...
include/libs/stream/tstream.h
浏览文件 @
fbc69a10
...
@@ -53,6 +53,7 @@ enum {
...
@@ -53,6 +53,7 @@ enum {
TASK_SCHED_STATUS__WAITING
,
TASK_SCHED_STATUS__WAITING
,
TASK_SCHED_STATUS__ACTIVE
,
TASK_SCHED_STATUS__ACTIVE
,
TASK_SCHED_STATUS__FAILED
,
TASK_SCHED_STATUS__FAILED
,
TASK_SCHED_STATUS__DROPPING
,
};
};
enum
{
enum
{
...
@@ -127,6 +128,10 @@ typedef struct {
...
@@ -127,6 +128,10 @@ typedef struct {
int8_t
type
;
int8_t
type
;
}
SStreamCheckpoint
;
}
SStreamCheckpoint
;
typedef
struct
{
int8_t
type
;
}
SStreamTaskDestroy
;
typedef
struct
{
typedef
struct
{
int8_t
type
;
int8_t
type
;
SSDataBlock
*
pBlock
;
SSDataBlock
*
pBlock
;
...
@@ -211,7 +216,6 @@ typedef struct {
...
@@ -211,7 +216,6 @@ typedef struct {
void
*
vnode
;
void
*
vnode
;
FTbSink
*
tbSinkFunc
;
FTbSink
*
tbSinkFunc
;
STSchema
*
pTSchema
;
STSchema
*
pTSchema
;
SHashObj
*
pHash
;
// groupId to tbuid
}
STaskSinkTb
;
}
STaskSinkTb
;
typedef
void
FSmaSink
(
void
*
vnode
,
int64_t
smaId
,
const
SArray
*
data
);
typedef
void
FSmaSink
(
void
*
vnode
,
int64_t
smaId
,
const
SArray
*
data
);
...
...
include/libs/sync/sync.h
浏览文件 @
fbc69a10
...
@@ -34,6 +34,7 @@ extern bool gRaftDetailLog;
...
@@ -34,6 +34,7 @@ extern bool gRaftDetailLog;
#define SYNC_MAX_PROGRESS_WAIT_MS 4000
#define SYNC_MAX_PROGRESS_WAIT_MS 4000
#define SYNC_MAX_START_TIME_RANGE_MS (1000 * 20)
#define SYNC_MAX_START_TIME_RANGE_MS (1000 * 20)
#define SYNC_MAX_RECV_TIME_RANGE_MS 1000
#define SYNC_MAX_RECV_TIME_RANGE_MS 1000
#define SYNC_ADD_QUORUM_COUNT 3
#define SYNC_MAX_BATCH_SIZE 1
#define SYNC_MAX_BATCH_SIZE 1
#define SYNC_INDEX_BEGIN 0
#define SYNC_INDEX_BEGIN 0
...
...
include/util/taoserror.h
浏览文件 @
fbc69a10
...
@@ -291,6 +291,7 @@ int32_t* taosGetErrno();
...
@@ -291,6 +291,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_STREAM_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03F1)
#define TSDB_CODE_MND_STREAM_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03F1)
#define TSDB_CODE_MND_INVALID_STREAM_OPTION TAOS_DEF_ERROR_CODE(0, 0x03F2)
#define TSDB_CODE_MND_INVALID_STREAM_OPTION TAOS_DEF_ERROR_CODE(0, 0x03F2)
#define TSDB_CODE_MND_STREAM_MUST_BE_DELETED TAOS_DEF_ERROR_CODE(0, 0x03F3)
#define TSDB_CODE_MND_STREAM_MUST_BE_DELETED TAOS_DEF_ERROR_CODE(0, 0x03F3)
#define TSDB_CODE_MND_STREAM_TASK_DROPPED TAOS_DEF_ERROR_CODE(0, 0x03F4)
// mnode-sma
// mnode-sma
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
#define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480)
...
@@ -614,6 +615,7 @@ int32_t* taosGetErrno();
...
@@ -614,6 +615,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_RSMA_REMOVE_EXISTS TAOS_DEF_ERROR_CODE(0, 0x3154)
#define TSDB_CODE_RSMA_REMOVE_EXISTS TAOS_DEF_ERROR_CODE(0, 0x3154)
#define TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x3155)
#define TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x3155)
#define TSDB_CODE_RSMA_EMPTY_INFO TAOS_DEF_ERROR_CODE(0, 0x3156)
#define TSDB_CODE_RSMA_EMPTY_INFO TAOS_DEF_ERROR_CODE(0, 0x3156)
#define TSDB_CODE_RSMA_INVALID_SCHEMA TAOS_DEF_ERROR_CODE(0, 0x3157)
//index
//index
#define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200)
#define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200)
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
fbc69a10
...
@@ -338,6 +338,7 @@ SArray *vmGetMsgHandles() {
...
@@ -338,6 +338,7 @@ SArray *vmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SCH_MERGE_QUERY
,
vmPutMsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SCH_MERGE_QUERY
,
vmPutMsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SCH_QUERY_CONTINUE
,
vmPutMsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SCH_QUERY_CONTINUE
,
vmPutMsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_FETCH_RSMA
,
vmPutMsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_FETCH_RSMA
,
vmPutMsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_EXEC_RSMA
,
vmPutMsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SCH_FETCH
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SCH_FETCH
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SCH_MERGE_FETCH
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SCH_MERGE_FETCH
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_TABLE
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_ALTER_TABLE
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
fbc69a10
...
@@ -636,6 +636,7 @@ typedef struct {
...
@@ -636,6 +636,7 @@ typedef struct {
int32_t
tEncodeSStreamObj
(
SEncoder
*
pEncoder
,
const
SStreamObj
*
pObj
);
int32_t
tEncodeSStreamObj
(
SEncoder
*
pEncoder
,
const
SStreamObj
*
pObj
);
int32_t
tDecodeSStreamObj
(
SDecoder
*
pDecoder
,
SStreamObj
*
pObj
);
int32_t
tDecodeSStreamObj
(
SDecoder
*
pDecoder
,
SStreamObj
*
pObj
);
void
tFreeStreamObj
(
SStreamObj
*
pObj
);
typedef
struct
{
typedef
struct
{
char
streamName
[
TSDB_STREAM_FNAME_LEN
];
char
streamName
[
TSDB_STREAM_FNAME_LEN
];
...
...
source/dnode/mnode/impl/inc/mndStb.h
浏览文件 @
fbc69a10
...
@@ -34,6 +34,7 @@ int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate);
...
@@ -34,6 +34,7 @@ int32_t mndCheckCreateStbReq(SMCreateStbReq *pCreate);
SDbObj
*
mndAcquireDbByStb
(
SMnode
*
pMnode
,
const
char
*
stbName
);
SDbObj
*
mndAcquireDbByStb
(
SMnode
*
pMnode
,
const
char
*
stbName
);
int32_t
mndBuildStbFromReq
(
SMnode
*
pMnode
,
SStbObj
*
pDst
,
SMCreateStbReq
*
pCreate
,
SDbObj
*
pDb
);
int32_t
mndBuildStbFromReq
(
SMnode
*
pMnode
,
SStbObj
*
pDst
,
SMCreateStbReq
*
pCreate
,
SDbObj
*
pDb
);
int32_t
mndAddStbToTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
);
int32_t
mndAddStbToTrans
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SDbObj
*
pDb
,
SStbObj
*
pStb
);
void
mndFreeStb
(
SStbObj
*
pStb
);
void
mndExtractDbNameFromStbFullName
(
const
char
*
stbFullName
,
char
*
dst
);
void
mndExtractDbNameFromStbFullName
(
const
char
*
stbFullName
,
char
*
dst
);
void
mndExtractTbNameFromStbFullName
(
const
char
*
stbFullName
,
char
*
dst
,
int32_t
dstSize
);
void
mndExtractTbNameFromStbFullName
(
const
char
*
stbFullName
,
char
*
dst
,
int32_t
dstSize
);
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
fbc69a10
...
@@ -116,6 +116,25 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
...
@@ -116,6 +116,25 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) {
return
0
;
return
0
;
}
}
void
tFreeStreamObj
(
SStreamObj
*
pStream
)
{
taosMemoryFree
(
pStream
->
sql
);
taosMemoryFree
(
pStream
->
ast
);
taosMemoryFree
(
pStream
->
physicalPlan
);
if
(
pStream
->
outputSchema
.
nCols
)
taosMemoryFree
(
pStream
->
outputSchema
.
pSchema
);
int32_t
sz
=
taosArrayGetSize
(
pStream
->
tasks
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SArray
*
pLevel
=
taosArrayGetP
(
pStream
->
tasks
,
i
);
int32_t
taskSz
=
taosArrayGetSize
(
pLevel
);
for
(
int32_t
j
=
0
;
j
<
taskSz
;
j
++
)
{
SStreamTask
*
pTask
=
taosArrayGetP
(
pLevel
,
j
);
tFreeSStreamTask
(
pTask
);
}
taosArrayDestroy
(
pLevel
);
}
taosArrayDestroy
(
pStream
->
tasks
);
}
SMqVgEp
*
tCloneSMqVgEp
(
const
SMqVgEp
*
pVgEp
)
{
SMqVgEp
*
tCloneSMqVgEp
(
const
SMqVgEp
*
pVgEp
)
{
SMqVgEp
*
pVgEpNew
=
taosMemoryMalloc
(
sizeof
(
SMqVgEp
));
SMqVgEp
*
pVgEpNew
=
taosMemoryMalloc
(
sizeof
(
SMqVgEp
));
if
(
pVgEpNew
==
NULL
)
return
NULL
;
if
(
pVgEpNew
==
NULL
)
return
NULL
;
...
...
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
fbc69a10
...
@@ -424,6 +424,8 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
...
@@ -424,6 +424,8 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
}
}
mndAddTaskToTaskSet
(
taskSourceLevel
,
pTask
);
mndAddTaskToTaskSet
(
taskSourceLevel
,
pTask
);
pTask
->
triggerParam
=
0
;
// source
// source
pTask
->
taskLevel
=
TASK_LEVEL__SOURCE
;
pTask
->
taskLevel
=
TASK_LEVEL__SOURCE
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
fbc69a10
...
@@ -266,6 +266,15 @@ _OVER:
...
@@ -266,6 +266,15 @@ _OVER:
return
pRow
;
return
pRow
;
}
}
void
mndFreeStb
(
SStbObj
*
pStb
)
{
taosArrayDestroy
(
pStb
->
pFuncs
);
taosMemoryFreeClear
(
pStb
->
pColumns
);
taosMemoryFreeClear
(
pStb
->
pTags
);
taosMemoryFreeClear
(
pStb
->
comment
);
taosMemoryFreeClear
(
pStb
->
pAst1
);
taosMemoryFreeClear
(
pStb
->
pAst2
);
}
static
int32_t
mndStbActionInsert
(
SSdb
*
pSdb
,
SStbObj
*
pStb
)
{
static
int32_t
mndStbActionInsert
(
SSdb
*
pSdb
,
SStbObj
*
pStb
)
{
mTrace
(
"stb:%s, perform insert action, row:%p"
,
pStb
->
name
,
pStb
);
mTrace
(
"stb:%s, perform insert action, row:%p"
,
pStb
->
name
,
pStb
);
return
0
;
return
0
;
...
@@ -273,12 +282,7 @@ static int32_t mndStbActionInsert(SSdb *pSdb, SStbObj *pStb) {
...
@@ -273,12 +282,7 @@ static int32_t mndStbActionInsert(SSdb *pSdb, SStbObj *pStb) {
static
int32_t
mndStbActionDelete
(
SSdb
*
pSdb
,
SStbObj
*
pStb
)
{
static
int32_t
mndStbActionDelete
(
SSdb
*
pSdb
,
SStbObj
*
pStb
)
{
mTrace
(
"stb:%s, perform delete action, row:%p"
,
pStb
->
name
,
pStb
);
mTrace
(
"stb:%s, perform delete action, row:%p"
,
pStb
->
name
,
pStb
);
taosArrayDestroy
(
pStb
->
pFuncs
);
mndFreeStb
(
pStb
);
taosMemoryFreeClear
(
pStb
->
pColumns
);
taosMemoryFreeClear
(
pStb
->
pTags
);
taosMemoryFreeClear
(
pStb
->
comment
);
taosMemoryFreeClear
(
pStb
->
pAst1
);
taosMemoryFreeClear
(
pStb
->
pAst2
);
return
0
;
return
0
;
}
}
...
@@ -2021,8 +2025,7 @@ static int32_t mndCheckDropStbForTopic(SMnode *pMnode, const char *stbFullName,
...
@@ -2021,8 +2025,7 @@ static int32_t mndCheckDropStbForTopic(SMnode *pMnode, const char *stbFullName,
FOREACH
(
pNode
,
pNodeList
)
{
FOREACH
(
pNode
,
pNodeList
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
if
(
pCol
->
tableId
!=
suid
)
{
if
(
pCol
->
tableId
==
suid
)
{
mDebug
(
"topic:%s, check colId:%d passed"
,
pTopic
->
name
,
pCol
->
colId
);
sdbRelease
(
pSdb
,
pTopic
);
sdbRelease
(
pSdb
,
pTopic
);
nodesDestroyNode
(
pAst
);
nodesDestroyNode
(
pAst
);
return
-
1
;
return
-
1
;
...
@@ -2045,6 +2048,16 @@ static int32_t mndCheckDropStbForStream(SMnode *pMnode, const char *stbFullName,
...
@@ -2045,6 +2048,16 @@ static int32_t mndCheckDropStbForStream(SMnode *pMnode, const char *stbFullName,
pIter
=
sdbFetch
(
pSdb
,
SDB_STREAM
,
pIter
,
(
void
**
)
&
pStream
);
pIter
=
sdbFetch
(
pSdb
,
SDB_STREAM
,
pIter
,
(
void
**
)
&
pStream
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
if
(
pStream
->
smaId
!=
0
)
{
sdbRelease
(
pSdb
,
pStream
);
continue
;
}
if
(
pStream
->
targetStbUid
==
suid
)
{
sdbRelease
(
pSdb
,
pStream
);
return
-
1
;
}
SNode
*
pAst
=
NULL
;
SNode
*
pAst
=
NULL
;
if
(
nodesStringToNode
(
pStream
->
ast
,
&
pAst
)
!=
0
)
{
if
(
nodesStringToNode
(
pStream
->
ast
,
&
pAst
)
!=
0
)
{
ASSERT
(
0
);
ASSERT
(
0
);
...
@@ -2057,8 +2070,7 @@ static int32_t mndCheckDropStbForStream(SMnode *pMnode, const char *stbFullName,
...
@@ -2057,8 +2070,7 @@ static int32_t mndCheckDropStbForStream(SMnode *pMnode, const char *stbFullName,
FOREACH
(
pNode
,
pNodeList
)
{
FOREACH
(
pNode
,
pNodeList
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
if
(
pCol
->
tableId
!=
suid
)
{
if
(
pCol
->
tableId
==
suid
)
{
mDebug
(
"stream:%s, check colId:%d passed"
,
pStream
->
name
,
pCol
->
colId
);
sdbRelease
(
pSdb
,
pStream
);
sdbRelease
(
pSdb
,
pStream
);
nodesDestroyNode
(
pAst
);
nodesDestroyNode
(
pAst
);
return
-
1
;
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
fbc69a10
...
@@ -167,6 +167,9 @@ static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream) {
...
@@ -167,6 +167,9 @@ static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream) {
static
int32_t
mndStreamActionDelete
(
SSdb
*
pSdb
,
SStreamObj
*
pStream
)
{
static
int32_t
mndStreamActionDelete
(
SSdb
*
pSdb
,
SStreamObj
*
pStream
)
{
mTrace
(
"stream:%s, perform delete action"
,
pStream
->
name
);
mTrace
(
"stream:%s, perform delete action"
,
pStream
->
name
);
taosWLockLatch
(
&
pStream
->
lock
);
tFreeStreamObj
(
pStream
);
taosWUnLockLatch
(
&
pStream
->
lock
);
return
0
;
return
0
;
}
}
...
@@ -493,10 +496,17 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
...
@@ -493,10 +496,17 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
stbObj
.
uid
=
pStream
->
targetStbUid
;
stbObj
.
uid
=
pStream
->
targetStbUid
;
if
(
mndAddStbToTrans
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
<
0
)
goto
_OVER
;
if
(
mndAddStbToTrans
(
pMnode
,
pTrans
,
pDb
,
&
stbObj
)
<
0
)
{
mndFreeStb
(
&
stbObj
);
goto
_OVER
;
}
tFreeSMCreateStbReq
(
&
createReq
);
mndFreeStb
(
&
stbObj
);
return
0
;
return
0
;
_OVER:
_OVER:
tFreeSMCreateStbReq
(
&
createReq
);
mndReleaseStb
(
pMnode
,
pStb
);
mndReleaseStb
(
pMnode
,
pStb
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
return
-
1
;
return
-
1
;
...
@@ -715,6 +725,7 @@ _OVER:
...
@@ -715,6 +725,7 @@ _OVER:
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
tFreeSCMCreateStreamReq
(
&
createStreamReq
);
tFreeSCMCreateStreamReq
(
&
createStreamReq
);
tFreeStreamObj
(
&
streamObj
);
return
code
;
return
code
;
}
}
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
fbc69a10
...
@@ -63,6 +63,7 @@ void vnodeGetInfo(SVnode *pVnode, const char **dbname, int32_t *vgId);
...
@@ -63,6 +63,7 @@ void vnodeGetInfo(SVnode *pVnode, const char **dbname, int32_t *vgId);
int32_t
vnodeProcessCreateTSma
(
SVnode
*
pVnode
,
void
*
pCont
,
uint32_t
contLen
);
int32_t
vnodeProcessCreateTSma
(
SVnode
*
pVnode
,
void
*
pCont
,
uint32_t
contLen
);
int32_t
vnodeGetAllTableList
(
SVnode
*
pVnode
,
uint64_t
uid
,
SArray
*
list
);
int32_t
vnodeGetAllTableList
(
SVnode
*
pVnode
,
uint64_t
uid
,
SArray
*
list
);
int32_t
vnodeGetCtbIdList
(
SVnode
*
pVnode
,
int64_t
suid
,
SArray
*
list
);
int32_t
vnodeGetCtbIdList
(
SVnode
*
pVnode
,
int64_t
suid
,
SArray
*
list
);
int32_t
vnodeGetStbIdList
(
SVnode
*
pVnode
,
int64_t
suid
,
SArray
*
list
);
void
*
vnodeGetIdx
(
SVnode
*
pVnode
);
void
*
vnodeGetIdx
(
SVnode
*
pVnode
);
void
*
vnodeGetIvtIdx
(
SVnode
*
pVnode
);
void
*
vnodeGetIvtIdx
(
SVnode
*
pVnode
);
...
...
source/dnode/vnode/src/inc/sma.h
浏览文件 @
fbc69a10
...
@@ -57,9 +57,10 @@ typedef struct {
...
@@ -57,9 +57,10 @@ typedef struct {
void
*
tmrHandle
;
// shared by all fetch tasks
void
*
tmrHandle
;
// shared by all fetch tasks
}
SSmaMgmt
;
}
SSmaMgmt
;
#define SMA_ENV_LOCK(env) (&(env)->lock)
#define SMA_ENV_LOCK(env) (&(env)->lock)
#define SMA_ENV_TYPE(env) ((env)->type)
#define SMA_ENV_TYPE(env) ((env)->type)
#define SMA_ENV_STAT(env) ((env)->pStat)
#define SMA_ENV_STAT(env) ((env)->pStat)
#define SMA_RSMA_STAT(sma) ((SRSmaStat *)SMA_ENV_STAT((SSmaEnv *)(sma)->pRSmaEnv))
struct
STSmaStat
{
struct
STSmaStat
{
int8_t
state
;
// ETsdbSmaStat
int8_t
state
;
// ETsdbSmaStat
...
@@ -86,15 +87,17 @@ struct SQTaskFWriter {
...
@@ -86,15 +87,17 @@ struct SQTaskFWriter {
};
};
struct
SRSmaStat
{
struct
SRSmaStat
{
SSma
*
pSma
;
SSma
*
pSma
;
int64_t
commitAppliedVer
;
// vnode applied version for async commit
int64_t
commitAppliedVer
;
// vnode applied version for async commit
int64_t
refId
;
// shared by fetch tasks
int64_t
refId
;
// shared by fetch tasks
SRWLatch
lock
;
// r/w lock for rsma fs(e.g. qtaskinfo)
volatile
int64_t
qBufSize
;
// queue buffer size
int8_t
triggerStat
;
// shared by fetch tasks
SRWLatch
lock
;
// r/w lock for rsma fs(e.g. qtaskinfo)
int8_t
commitStat
;
// 0 not in committing, 1 in committing
int8_t
triggerStat
;
// shared by fetch tasks
SArray
*
aTaskFile
;
// qTaskFiles committed recently(for recovery/snapshot r/w)
int8_t
commitStat
;
// 0 not in committing, 1 in committing
SHashObj
*
rsmaInfoHash
;
// key: stbUid, value: SRSmaInfo;
int8_t
execStat
;
// 0 not in exec , 1 in exec
SHashObj
*
iRsmaInfoHash
;
// key: stbUid, value: SRSmaInfo; immutable rsmaInfoHash
SArray
*
aTaskFile
;
// qTaskFiles committed recently(for recovery/snapshot r/w)
SHashObj
*
infoHash
;
// key: suid, value: SRSmaInfo
SHashObj
*
fetchHash
;
// key: suid, value: L1 or L2 or L1|L2
};
};
struct
SSmaStat
{
struct
SSmaStat
{
...
@@ -105,34 +108,40 @@ struct SSmaStat {
...
@@ -105,34 +108,40 @@ struct SSmaStat {
T_REF_DECLARE
()
T_REF_DECLARE
()
};
};
#define SMA_
TSMA_STAT(s)
(&(s)->tsmaStat)
#define SMA_
STAT_TSMA(s)
(&(s)->tsmaStat)
#define SMA_
RSMA_STAT(s)
(&(s)->rsmaStat)
#define SMA_
STAT_RSMA(s)
(&(s)->rsmaStat)
#define RSMA_INFO_HASH(r)
((r)->rsmaI
nfoHash)
#define RSMA_INFO_HASH(r)
((r)->i
nfoHash)
#define RSMA_
IMU_INFO_HASH(r) ((r)->iRsmaInfo
Hash)
#define RSMA_
FETCH_HASH(r) ((r)->fetch
Hash)
#define RSMA_TRIGGER_STAT(r)
(&(r)->triggerStat)
#define RSMA_TRIGGER_STAT(r) (&(r)->triggerStat)
#define RSMA_COMMIT_STAT(r)
(&(r)->commitStat)
#define RSMA_COMMIT_STAT(r) (&(r)->commitStat)
#define RSMA_REF_ID(r)
((r)->refId)
#define RSMA_REF_ID(r) ((r)->refId)
#define RSMA_FS_LOCK(r)
(&(r)->lock)
#define RSMA_FS_LOCK(r) (&(r)->lock)
struct
SRSmaInfoItem
{
struct
SRSmaInfoItem
{
int8_t
level
;
int8_t
level
;
int8_t
triggerStat
;
int8_t
triggerStat
;
int32_t
maxDelay
;
uint16_t
interval
;
// second
tmr_h
tmrId
;
int32_t
maxDelay
;
tmr_h
tmrId
;
};
};
struct
SRSmaInfo
{
struct
SRSmaInfo
{
STSchema
*
pTSchema
;
STSchema
*
pTSchema
;
int64_t
suid
;
int64_t
suid
;
int64_t
refId
;
// refId of SRSmaStat
int64_t
refId
;
// refId of SRSmaStat
int8_t
delFlag
;
uint64_t
delFlag
:
1
;
uint64_t
lastReceived
:
63
;
// second
T_REF_DECLARE
()
T_REF_DECLARE
()
SRSmaInfoItem
items
[
TSDB_RETENTION_L2
];
SRSmaInfoItem
items
[
TSDB_RETENTION_L2
];
void
*
taskInfo
[
TSDB_RETENTION_L2
];
// qTaskInfo_t
void
*
taskInfo
[
TSDB_RETENTION_L2
];
// qTaskInfo_t
void
*
iTaskInfo
[
TSDB_RETENTION_L2
];
// immutable
STaosQueue
*
queue
;
// buffer queue of SubmitReq
STaosQall
*
qall
;
// buffer qall of SubmitReq
void
*
iTaskInfo
[
TSDB_RETENTION_L2
];
// immutable qTaskInfo_t
STaosQueue
*
iQueue
;
// immutable buffer queue of SubmitReq
STaosQall
*
iQall
;
// immutable buffer qall of SubmitReq
};
};
#define RSMA_INFO_HEAD_LEN
32
#define RSMA_INFO_HEAD_LEN
offsetof(SRSmaInfo, items)
#define RSMA_INFO_IS_DEL(r) ((r)->delFlag == 1)
#define RSMA_INFO_IS_DEL(r) ((r)->delFlag == 1)
#define RSMA_INFO_SET_DEL(r) ((r)->delFlag = 1)
#define RSMA_INFO_SET_DEL(r) ((r)->delFlag = 1)
#define RSMA_INFO_QTASK(r, i) ((r)->taskInfo[i])
#define RSMA_INFO_QTASK(r, i) ((r)->taskInfo[i])
...
@@ -161,6 +170,12 @@ enum {
...
@@ -161,6 +170,12 @@ enum {
RSMA_RESTORE_SYNC
=
2
,
RSMA_RESTORE_SYNC
=
2
,
};
};
typedef
enum
{
RSMA_EXEC_OVERFLOW
=
1
,
// triggered by queue buf overflow
RSMA_EXEC_TIMEOUT
=
2
,
// triggered by timer
RSMA_EXEC_COMMIT
=
3
,
// triggered by commit
}
ERsmaExecType
;
void
tdDestroySmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
tdDestroySmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
*
tdFreeSmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
*
tdFreeSmaEnv
(
SSmaEnv
*
pSmaEnv
);
...
@@ -228,12 +243,13 @@ static FORCE_INLINE void tdSmaStatSetDropped(STSmaStat *pTStat) {
...
@@ -228,12 +243,13 @@ static FORCE_INLINE void tdSmaStatSetDropped(STSmaStat *pTStat) {
void
tdRSmaQTaskInfoGetFileName
(
int32_t
vid
,
int64_t
version
,
char
*
outputName
);
void
tdRSmaQTaskInfoGetFileName
(
int32_t
vid
,
int64_t
version
,
char
*
outputName
);
void
tdRSmaQTaskInfoGetFullName
(
int32_t
vid
,
int64_t
version
,
const
char
*
path
,
char
*
outputName
);
void
tdRSmaQTaskInfoGetFullName
(
int32_t
vid
,
int64_t
version
,
const
char
*
path
,
char
*
outputName
);
int32_t
tdCloneRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
*
pDest
,
SRSmaInfo
*
pSrc
);
int32_t
tdCloneRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pInfo
);
void
tdFreeQTaskInfo
(
qTaskInfo_t
*
taskHandle
,
int32_t
vgId
,
int32_t
level
);
void
tdFreeQTaskInfo
(
qTaskInfo_t
*
taskHandle
,
int32_t
vgId
,
int32_t
level
);
static
int32_t
tdDestroySmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
);
static
int32_t
tdDestroySmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
);
void
*
tdFreeSmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
);
void
*
tdFreeSmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
);
void
*
tdFreeRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pInfo
,
bool
isDeepFree
);
void
*
tdFreeRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pInfo
,
bool
isDeepFree
);
int32_t
tdRSmaPersistExecImpl
(
SRSmaStat
*
pRSmaStat
,
SHashObj
*
pInfoHash
);
int32_t
tdRSmaPersistExecImpl
(
SRSmaStat
*
pRSmaStat
,
SHashObj
*
pInfoHash
);
int32_t
tdRSmaProcessExecImpl
(
SSma
*
pSma
,
ERsmaExecType
type
);
int32_t
tdProcessRSmaCreateImpl
(
SSma
*
pSma
,
SRSmaParam
*
param
,
int64_t
suid
,
const
char
*
tbName
);
int32_t
tdProcessRSmaCreateImpl
(
SSma
*
pSma
,
SRSmaParam
*
param
,
int64_t
suid
,
const
char
*
tbName
);
int32_t
tdProcessRSmaRestoreImpl
(
SSma
*
pSma
,
int8_t
type
,
int64_t
qtaskFileVer
);
int32_t
tdProcessRSmaRestoreImpl
(
SSma
*
pSma
,
int8_t
type
,
int64_t
qtaskFileVer
);
...
...
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
fbc69a10
...
@@ -65,6 +65,7 @@ struct SVBufPool {
...
@@ -65,6 +65,7 @@ struct SVBufPool {
SVBufPool
*
next
;
SVBufPool
*
next
;
SVnode
*
pVnode
;
SVnode
*
pVnode
;
volatile
int32_t
nRef
;
volatile
int32_t
nRef
;
TdThreadSpinlock
lock
;
int64_t
size
;
int64_t
size
;
uint8_t
*
ptr
;
uint8_t
*
ptr
;
SVBufPoolNode
*
pTail
;
SVBufPoolNode
*
pTail
;
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
fbc69a10
...
@@ -199,6 +199,7 @@ int32_t smaAsyncCommit(SSma* pSma);
...
@@ -199,6 +199,7 @@ int32_t smaAsyncCommit(SSma* pSma);
int32_t
smaAsyncPostCommit
(
SSma
*
pSma
);
int32_t
smaAsyncPostCommit
(
SSma
*
pSma
);
int32_t
smaDoRetention
(
SSma
*
pSma
,
int64_t
now
);
int32_t
smaDoRetention
(
SSma
*
pSma
,
int64_t
now
);
int32_t
smaProcessFetch
(
SSma
*
pSma
,
void
*
pMsg
);
int32_t
smaProcessFetch
(
SSma
*
pSma
,
void
*
pMsg
);
int32_t
smaProcessExec
(
SSma
*
pSma
,
void
*
pMsg
);
int32_t
tdProcessTSmaCreate
(
SSma
*
pSma
,
int64_t
version
,
const
char
*
msg
);
int32_t
tdProcessTSmaCreate
(
SSma
*
pSma
,
int64_t
version
,
const
char
*
msg
);
int32_t
tdProcessTSmaInsert
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
);
int32_t
tdProcessTSmaInsert
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
);
...
...
source/dnode/vnode/src/sma/smaCommit.c
浏览文件 @
fbc69a10
...
@@ -83,8 +83,7 @@ int32_t smaBegin(SSma *pSma) {
...
@@ -83,8 +83,7 @@ int32_t smaBegin(SSma *pSma) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SSmaStat
*
pStat
=
SMA_ENV_STAT
(
pSmaEnv
);
SRSmaStat
*
pRSmaStat
=
(
SRSmaStat
*
)
SMA_ENV_STAT
(
pSmaEnv
);
SRSmaStat
*
pRSmaStat
=
SMA_RSMA_STAT
(
pStat
);
int8_t
rsmaTriggerStat
=
int8_t
rsmaTriggerStat
=
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_PAUSED
,
TASK_TRIGGER_STAT_ACTIVE
);
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_PAUSED
,
TASK_TRIGGER_STAT_ACTIVE
);
...
@@ -123,7 +122,7 @@ static int32_t tdProcessRSmaSyncPreCommitImpl(SSma *pSma) {
...
@@ -123,7 +122,7 @@ static int32_t tdProcessRSmaSyncPreCommitImpl(SSma *pSma) {
}
}
SSmaStat
*
pStat
=
SMA_ENV_STAT
(
pSmaEnv
);
SSmaStat
*
pStat
=
SMA_ENV_STAT
(
pSmaEnv
);
SRSmaStat
*
pRSmaStat
=
SMA_
RSMA_STAT
(
pStat
);
SRSmaStat
*
pRSmaStat
=
SMA_
STAT_RSMA
(
pStat
);
// step 1: set rsma stat paused
// step 1: set rsma stat paused
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_PAUSED
);
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_PAUSED
);
...
@@ -289,8 +288,7 @@ static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma) {
...
@@ -289,8 +288,7 @@ static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SSmaEnv
*
pSmaEnv
=
SMA_RSMA_ENV
(
pSma
);
SRSmaStat
*
pRSmaStat
=
SMA_RSMA_STAT
(
pSma
);
SRSmaStat
*
pRSmaStat
=
SMA_RSMA_STAT
(
SMA_ENV_STAT
(
pSmaEnv
));
// cleanup outdated qtaskinfo files
// cleanup outdated qtaskinfo files
tdCleanupQTaskInfoFiles
(
pSma
,
pRSmaStat
);
tdCleanupQTaskInfoFiles
(
pSma
,
pRSmaStat
);
...
@@ -299,10 +297,9 @@ static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma) {
...
@@ -299,10 +297,9 @@ static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma) {
}
}
/**
/**
* @brief Rsma async commit implementation
* @brief Rsma async commit implementation
(only do some necessary light weighted task)
* 1) set rsma stat TASK_TRIGGER_STAT_PAUSED
* 1) set rsma stat TASK_TRIGGER_STAT_PAUSED
* 2) Wait all running fetch task finish to fetch and put submitMsg into level 2/3 wQueue(blocking level 1 write)
* 2) Wait all running fetch task finish to fetch and put submitMsg into level 2/3 wQueue(blocking level 1 write)
* 3)
*
*
* @param pSma
* @param pSma
* @return int32_t
* @return int32_t
...
@@ -314,7 +311,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
...
@@ -314,7 +311,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
}
}
SSmaStat
*
pStat
=
SMA_ENV_STAT
(
pEnv
);
SSmaStat
*
pStat
=
SMA_ENV_STAT
(
pEnv
);
SRSmaStat
*
pRSmaStat
=
SMA_
RSMA_STAT
(
pStat
);
SRSmaStat
*
pRSmaStat
=
SMA_
STAT_RSMA
(
pStat
);
// step 1: set rsma stat
// step 1: set rsma stat
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_PAUSED
);
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_PAUSED
);
...
@@ -336,28 +333,55 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
...
@@ -336,28 +333,55 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
}
}
}
}
// step 3: swap rsmaInfoHash and iRsmaInfoHash
/**
* @brief step 3: consume the SubmitReq in buffer
* 1) This is high cost task and should not put in asyncPreCommit originally.
* 2) But, if put in asyncCommit, would trigger taskInfo cloning frequently.
*/
nLoops
=
0
;
smaInfo
(
"vgId:%d, start to wait for rsma qtask free, TID:%p"
,
SMA_VID
(
pSma
),
(
void
*
)
taosGetSelfPthreadId
());
int8_t
old
;
while
(
1
)
{
old
=
atomic_val_compare_exchange_8
(
&
pRSmaStat
->
execStat
,
0
,
1
);
if
(
old
==
0
)
break
;
if
(
++
nLoops
>
1000
)
{
sched_yield
();
nLoops
=
0
;
smaDebug
(
"vgId:%d, wait for rsma qtask free, TID:%p"
,
SMA_VID
(
pSma
),
(
void
*
)
taosGetSelfPthreadId
());
}
}
smaInfo
(
"vgId:%d, end to wait for rsma qtask free, TID:%p"
,
SMA_VID
(
pSma
),
(
void
*
)
taosGetSelfPthreadId
());
if
(
tdRSmaProcessExecImpl
(
pSma
,
RSMA_EXEC_COMMIT
)
<
0
)
{
atomic_store_8
(
&
pRSmaStat
->
execStat
,
0
);
return
TSDB_CODE_FAILED
;
}
// step 4: swap queue/qall and iQueue/iQall
// lock
// lock
taosWLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
taosWLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
ASSERT
(
RSMA_INFO_HASH
(
pRSmaStat
));
ASSERT
(
RSMA_INFO_HASH
(
pRSmaStat
));
ASSERT
(
!
RSMA_IMU_INFO_HASH
(
pRSmaStat
));
RSMA_IMU_INFO_HASH
(
pRSmaStat
)
=
RSMA_INFO_HASH
(
pRSmaStat
);
void
*
pIter
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
NULL
);
RSMA_INFO_HASH
(
pRSmaStat
)
=
taosHashInit
(
RSMA_TASK_INFO_HASH_SLOT
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_ENTRY_LOCK
);
if
(
!
RSMA_INFO_HASH
(
pRSmaStat
))
{
while
(
pIter
)
{
// unlock
SRSmaInfo
*
pInfo
=
*
(
SRSmaInfo
**
)
pIter
;
taosWUnLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
TSWAP
(
pInfo
->
iQall
,
pInfo
->
qall
);
smaError
(
"vgId:%d, rsma async commit failed since %s"
,
SMA_VID
(
pSma
),
terrstr
());
TSWAP
(
pInfo
->
iQueue
,
pInfo
->
queue
);
return
TSDB_CODE_FAILED
;
TSWAP
(
pInfo
->
iTaskInfo
[
0
],
pInfo
->
taskInfo
[
0
]);
TSWAP
(
pInfo
->
iTaskInfo
[
1
],
pInfo
->
taskInfo
[
1
]);
pIter
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
pIter
);
}
}
atomic_store_64
(
&
pRSmaStat
->
qBufSize
,
0
);
atomic_store_8
(
&
pRSmaStat
->
execStat
,
0
);
// unlock
// unlock
taosWUnLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
taosWUnLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
// step
4
: others
// step
5
: others
pRSmaStat
->
commitAppliedVer
=
pSma
->
pVnode
->
state
.
applied
;
pRSmaStat
->
commitAppliedVer
=
pSma
->
pVnode
->
state
.
applied
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -375,17 +399,18 @@ static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma) {
...
@@ -375,17 +399,18 @@ static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SSmaStat
*
pStat
=
SMA_ENV_STAT
(
pSmaEnv
);
SRSmaStat
*
pRSmaStat
=
(
SRSmaStat
*
)
SMA_ENV_STAT
(
pSmaEnv
);
SRSmaStat
*
pRSmaStat
=
SMA_RSMA_STAT
(
pStat
);
// perform persist task for qTaskInfo
// perform persist task for qTaskInfo operator
tdRSmaPersistExecImpl
(
pRSmaStat
,
RSMA_IMU_INFO_HASH
(
pRSmaStat
));
if
(
tdRSmaPersistExecImpl
(
pRSmaStat
,
RSMA_INFO_HASH
(
pRSmaStat
))
<
0
)
{
return
TSDB_CODE_FAILED
;
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
/**
/**
* @brief Migrate rsmaInfo from iRsmaInfo to rsmaInfo if rsma
I
nfoHash not empty.
* @brief Migrate rsmaInfo from iRsmaInfo to rsmaInfo if rsma
i
nfoHash not empty.
*
*
* @param pSma
* @param pSma
* @return int32_t
* @return int32_t
...
@@ -396,65 +421,66 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) {
...
@@ -396,65 +421,66 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
S
SmaStat
*
pStat
=
SMA_ENV_STAT
(
pEnv
);
S
RSmaStat
*
pRSmaStat
=
(
SRSmaStat
*
)
SMA_ENV_STAT
(
pEnv
);
S
RSmaStat
*
pRSmaStat
=
SMA_RSMA_STAT
(
pStat
)
;
S
Array
*
rsmaDeleted
=
NULL
;
// step 1: merge
rsmaInfoHash and iRsmaInfoHash
// step 1: merge
qTaskInfo and iQTaskInfo
// lock
// lock
taosWLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
taosWLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
#if 0
if (taosHashGetSize(RSMA_INFO_HASH(pRSmaStat)) <= 0) {
void
*
pIter
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
NULL
);
// just switch the hash pointer if rsmaInfoHash is empty
if (taosHashGetSize(RSMA_IMU_INFO_HASH(pRSmaStat)) > 0) {
SHashObj *infoHash = RSMA_INFO_HASH(pRSmaStat);
RSMA_INFO_HASH(pRSmaStat) = RSMA_IMU_INFO_HASH(pRSmaStat);
RSMA_IMU_INFO_HASH(pRSmaStat) = infoHash;
}
} else {
#endif
#if 1
void
*
pIter
=
taosHashIterate
(
RSMA_IMU_INFO_HASH
(
pRSmaStat
),
NULL
);
while
(
pIter
)
{
while
(
pIter
)
{
tb_uid_t
*
pSuid
=
(
tb_uid_t
*
)
taosHashGetKey
(
pIter
,
NULL
);
tb_uid_t
*
pSuid
=
(
tb_uid_t
*
)
taosHashGetKey
(
pIter
,
NULL
);
SRSmaInfo
*
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pIter
;
if
(
!
taosHashGet
(
RSMA_INFO_HASH
(
pRSmaStat
),
pSuid
,
sizeof
(
tb_uid_t
)))
{
if
(
RSMA_INFO_IS_DEL
(
pRSmaInfo
))
{
SRSmaInfo
*
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pIter
;
int32_t
refVal
=
T_REF_VAL_GET
(
pRSmaInfo
);
if
(
RSMA_INFO_IS_DEL
(
pRSmaInfo
))
{
if
(
refVal
==
0
)
{
int32_t
refVal
=
T_REF_VAL_GET
(
pRSmaInfo
);
if
(
!
rsmaDeleted
)
{
if
(
refVal
==
0
)
{
if
((
rsmaDeleted
=
taosArrayInit
(
1
,
sizeof
(
tb_uid_t
))))
{
tdFreeRSmaInfo
(
pSma
,
pRSmaInfo
,
true
);
taosArrayPush
(
rsmaDeleted
,
pSuid
);
smaDebug
(
}
"vgId:%d, rsma async post commit, free rsma info since already deleted and ref is 0 for "
"table:%"
PRIi64
,
SMA_VID
(
pSma
),
*
pSuid
);
}
else
{
smaDebug
(
"vgId:%d, rsma async post commit, not free rsma info since ref is %d although already deleted for "
"table:%"
PRIi64
,
SMA_VID
(
pSma
),
refVal
,
*
pSuid
);
}
}
}
else
{
smaDebug
(
"vgId:%d, rsma async post commit, not free rsma info since ref is %d although already deleted for "
"table:%"
PRIi64
,
SMA_VID
(
pSma
),
refVal
,
*
pSuid
);
}
pIter
=
taosHashIterate
(
RSMA_IMU_INFO_HASH
(
pRSmaStat
),
pIter
);
pIter
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
pIter
);
continue
;
continue
;
}
if
(
pRSmaInfo
->
taskInfo
[
0
])
{
if
(
pRSmaInfo
->
iTaskInfo
[
0
])
{
SRSmaInfo
*
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pRSmaInfo
->
iTaskInfo
[
0
];
tdFreeRSmaInfo
(
pSma
,
pRSmaInfo
,
true
);
pRSmaInfo
->
iTaskInfo
[
0
]
=
NULL
;
}
}
taosHashPut
(
RSMA_INFO_HASH
(
pRSmaStat
),
pSuid
,
sizeof
(
tb_uid_t
),
pIter
,
sizeof
(
pIter
));
smaDebug
(
"vgId:%d, rsma async post commit, migrated from iRsmaInfoHash for table:%"
PRIi64
,
SMA_VID
(
pSma
),
*
pSuid
);
}
else
{
}
else
{
// free the resources
TSWAP
(
pRSmaInfo
->
taskInfo
[
0
],
pRSmaInfo
->
iTaskInfo
[
0
]);
SRSmaInfo
*
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pIter
;
tdFreeRSmaInfo
(
pSma
,
pRSmaInfo
,
false
);
smaDebug
(
"vgId:%d, rsma async post commit, free rsma info since already COW for table:%"
PRIi64
,
SMA_VID
(
pSma
),
*
pSuid
);
}
}
pIter
=
taosHashIterate
(
RSMA_IMU_INFO_HASH
(
pRSmaStat
),
pIter
);
taosHashPut
(
RSMA_INFO_HASH
(
pRSmaStat
),
pSuid
,
sizeof
(
tb_uid_t
),
pIter
,
sizeof
(
pIter
));
smaDebug
(
"vgId:%d, rsma async post commit, migrated from iRsmaInfoHash for table:%"
PRIi64
,
SMA_VID
(
pSma
),
*
pSuid
);
pIter
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
pIter
);
}
}
#endif
// }
taosHashCleanup
(
RSMA_IMU_INFO_HASH
(
pRSmaStat
));
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
rsmaDeleted
);
++
i
)
{
RSMA_IMU_INFO_HASH
(
pRSmaStat
)
=
NULL
;
tb_uid_t
*
pSuid
=
taosArrayGet
(
rsmaDeleted
,
i
);
void
*
pRSmaInfo
=
taosHashGet
(
RSMA_INFO_HASH
(
pRSmaStat
),
pSuid
,
sizeof
(
tb_uid_t
));
if
((
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pRSmaInfo
))
{
tdFreeRSmaInfo
(
pSma
,
pRSmaInfo
,
true
);
smaDebug
(
"vgId:%d, rsma async post commit, free rsma info since already deleted and ref is 0 for "
"table:%"
PRIi64
,
SMA_VID
(
pSma
),
*
pSuid
);
}
taosHashRemove
(
RSMA_INFO_HASH
(
pRSmaStat
),
pSuid
,
sizeof
(
tb_uid_t
));
}
taosArrayDestroy
(
rsmaDeleted
);
// TODO: remove suid in files?
// unlock
// unlock
taosWUnLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
taosWUnLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
...
...
source/dnode/vnode/src/sma/smaEnv.c
浏览文件 @
fbc69a10
...
@@ -171,7 +171,7 @@ int32_t tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat) {
...
@@ -171,7 +171,7 @@ int32_t tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat) {
int32_t
tdRefRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pRSmaInfo
)
{
int32_t
tdRefRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pRSmaInfo
)
{
if
(
!
pRSmaInfo
)
return
0
;
if
(
!
pRSmaInfo
)
return
0
;
int
ref
=
T_REF_INC
(
pRSmaInfo
);
int
ref
=
T_REF_INC
(
pRSmaInfo
);
smaDebug
(
"vgId:%d, ref rsma info:%p, val:%d"
,
SMA_VID
(
pSma
),
pRSmaInfo
,
ref
);
smaDebug
(
"vgId:%d, ref rsma info:%p, val:%d"
,
SMA_VID
(
pSma
),
pRSmaInfo
,
ref
);
return
0
;
return
0
;
...
@@ -228,7 +228,12 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS
...
@@ -228,7 +228,12 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS
RSMA_INFO_HASH
(
pRSmaStat
)
=
taosHashInit
(
RSMA_INFO_HASH
(
pRSmaStat
)
=
taosHashInit
(
RSMA_TASK_INFO_HASH_SLOT
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_ENTRY_LOCK
);
RSMA_TASK_INFO_HASH_SLOT
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_ENTRY_LOCK
);
if
(
!
RSMA_INFO_HASH
(
pRSmaStat
))
{
if
(
!
RSMA_INFO_HASH
(
pRSmaStat
))
{
taosMemoryFreeClear
(
*
pSmaStat
);
return
TSDB_CODE_FAILED
;
}
RSMA_FETCH_HASH
(
pRSmaStat
)
=
taosHashInit
(
RSMA_TASK_INFO_HASH_SLOT
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_ENTRY_LOCK
);
if
(
!
RSMA_FETCH_HASH
(
pRSmaStat
))
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
}
else
if
(
smaType
==
TSDB_SMA_TYPE_TIME_RANGE
)
{
}
else
if
(
smaType
==
TSDB_SMA_TYPE_TIME_RANGE
)
{
...
@@ -264,8 +269,6 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
...
@@ -264,8 +269,6 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pStat
),
TASK_TRIGGER_STAT_CANCELLED
);
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pStat
),
TASK_TRIGGER_STAT_CANCELLED
);
// step 2: destroy the rsma info and associated fetch tasks
// step 2: destroy the rsma info and associated fetch tasks
// TODO: use taosHashSetFreeFp when taosHashSetFreeFp is ready.
#if 1
if
(
taosHashGetSize
(
RSMA_INFO_HASH
(
pStat
))
>
0
)
{
if
(
taosHashGetSize
(
RSMA_INFO_HASH
(
pStat
))
>
0
)
{
void
*
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pStat
),
NULL
);
void
*
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pStat
),
NULL
);
while
(
infoHash
)
{
while
(
infoHash
)
{
...
@@ -274,10 +277,12 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
...
@@ -274,10 +277,12 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pStat
),
infoHash
);
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pStat
),
infoHash
);
}
}
}
}
#endif
taosHashCleanup
(
RSMA_INFO_HASH
(
pStat
));
taosHashCleanup
(
RSMA_INFO_HASH
(
pStat
));
// step 3: wait all triggered fetch tasks finished
// step 3: destroy the rsma fetch hash
taosHashCleanup
(
RSMA_FETCH_HASH
(
pStat
));
// step 4: wait all triggered fetch tasks finished
int32_t
nLoops
=
0
;
int32_t
nLoops
=
0
;
while
(
1
)
{
while
(
1
)
{
if
(
T_REF_VAL_GET
((
SSmaStat
*
)
pStat
)
==
0
)
{
if
(
T_REF_VAL_GET
((
SSmaStat
*
)
pStat
)
==
0
)
{
...
@@ -293,7 +298,7 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
...
@@ -293,7 +298,7 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
}
}
}
}
// step
4
: free pStat
// step
5
: free pStat
taosMemoryFreeClear
(
pStat
);
taosMemoryFreeClear
(
pStat
);
}
}
}
}
...
@@ -318,9 +323,9 @@ void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) {
...
@@ -318,9 +323,9 @@ void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) {
int32_t
tdDestroySmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
)
{
int32_t
tdDestroySmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
)
{
if
(
pSmaStat
)
{
if
(
pSmaStat
)
{
if
(
smaType
==
TSDB_SMA_TYPE_TIME_RANGE
)
{
if
(
smaType
==
TSDB_SMA_TYPE_TIME_RANGE
)
{
tdDestroyTSmaStat
(
SMA_
TSMA_STAT
(
pSmaStat
));
tdDestroyTSmaStat
(
SMA_
STAT_TSMA
(
pSmaStat
));
}
else
if
(
smaType
==
TSDB_SMA_TYPE_ROLLUP
)
{
}
else
if
(
smaType
==
TSDB_SMA_TYPE_ROLLUP
)
{
SRSmaStat
*
pRSmaStat
=
SMA_RSMA_STAT
(
pSmaStat
)
;
SRSmaStat
*
pRSmaStat
=
&
pSmaStat
->
rsmaStat
;
int32_t
vid
=
SMA_VID
(
pRSmaStat
->
pSma
);
int32_t
vid
=
SMA_VID
(
pRSmaStat
->
pSma
);
int64_t
refId
=
RSMA_REF_ID
(
pRSmaStat
);
int64_t
refId
=
RSMA_REF_ID
(
pRSmaStat
);
if
(
taosRemoveRef
(
smaMgmt
.
rsetId
,
RSMA_REF_ID
(
pRSmaStat
))
<
0
)
{
if
(
taosRemoveRef
(
smaMgmt
.
rsetId
,
RSMA_REF_ID
(
pRSmaStat
))
<
0
)
{
...
...
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
fbc69a10
此差异已折叠。
点击以展开。
source/dnode/vnode/src/sma/smaSnapshot.c
浏览文件 @
fbc69a10
...
@@ -139,7 +139,6 @@ static int32_t rsmaSnapReadQTaskInfo(SRsmaSnapReader* pReader, uint8_t** ppBuf)
...
@@ -139,7 +139,6 @@ static int32_t rsmaSnapReadQTaskInfo(SRsmaSnapReader* pReader, uint8_t** ppBuf)
smaInfo
(
"vgId:%d, vnode snapshot rsma read qtaskinfo, size:%"
PRIi64
,
SMA_VID
(
pSma
),
size
);
smaInfo
(
"vgId:%d, vnode snapshot rsma read qtaskinfo, size:%"
PRIi64
,
SMA_VID
(
pSma
),
size
);
SSnapDataHdr
*
pHdr
=
(
SSnapDataHdr
*
)(
*
ppBuf
);
SSnapDataHdr
*
pHdr
=
(
SSnapDataHdr
*
)(
*
ppBuf
);
pHdr
->
type
=
SNAP_DATA_QTASK
;
pHdr
->
type
=
SNAP_DATA_QTASK
;
pHdr
->
size
=
size
;
pHdr
->
size
=
size
;
...
@@ -279,7 +278,8 @@ int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapWrit
...
@@ -279,7 +278,8 @@ int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapWrit
TdFilePtr
qTaskF
=
taosCreateFile
(
qTaskInfoFullName
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
TdFilePtr
qTaskF
=
taosCreateFile
(
qTaskInfoFullName
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
!
qTaskF
)
{
if
(
!
qTaskF
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
TAOS_SYSTEM_ERROR
(
errno
);
smaError
(
"vgId:%d, rsma snapshot writer open %s failed since %s"
,
TD_VID
(
pSma
->
pVnode
),
qTaskInfoFullName
,
tstrerror
(
code
));
smaError
(
"vgId:%d, rsma snapshot writer open %s failed since %s"
,
TD_VID
(
pSma
->
pVnode
),
qTaskInfoFullName
,
tstrerror
(
code
));
goto
_err
;
goto
_err
;
}
}
qWriter
->
pWriteH
=
qTaskF
;
qWriter
->
pWriteH
=
qTaskF
;
...
@@ -309,7 +309,7 @@ int32_t rsmaSnapWriterClose(SRsmaSnapWriter** ppWriter, int8_t rollback) {
...
@@ -309,7 +309,7 @@ int32_t rsmaSnapWriterClose(SRsmaSnapWriter** ppWriter, int8_t rollback) {
if
(
rollback
)
{
if
(
rollback
)
{
// TODO: rsma1/rsma2
// TODO: rsma1/rsma2
// qtaskinfo
// qtaskinfo
if
(
pWriter
->
pQTaskFWriter
)
{
if
(
pWriter
->
pQTaskFWriter
)
{
taosRemoveFile
(
pWriter
->
pQTaskFWriter
->
fname
);
taosRemoveFile
(
pWriter
->
pQTaskFWriter
->
fname
);
}
}
}
else
{
}
else
{
...
...
source/dnode/vnode/src/sma/smaTimeRange.c
浏览文件 @
fbc69a10
...
@@ -175,7 +175,7 @@ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) {
...
@@ -175,7 +175,7 @@ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) {
}
}
tdRefSmaStat
(
pSma
,
pStat
);
tdRefSmaStat
(
pSma
,
pStat
);
pTsmaStat
=
SMA_
TSMA_STAT
(
pStat
);
pTsmaStat
=
SMA_
STAT_TSMA
(
pStat
);
if
(
!
pTsmaStat
->
pTSma
)
{
if
(
!
pTsmaStat
->
pTSma
)
{
STSma
*
pTSma
=
metaGetSmaInfoByIndex
(
SMA_META
(
pSma
),
indexUid
);
STSma
*
pTSma
=
metaGetSmaInfoByIndex
(
SMA_META
(
pSma
),
indexUid
);
...
...
source/dnode/vnode/src/sma/smaUtil.c
浏览文件 @
fbc69a10
...
@@ -350,49 +350,45 @@ _err:
...
@@ -350,49 +350,45 @@ _err:
}
}
/**
/**
* @brief
pTSchema is shared
* @brief
Clone qTaskInfo of SRSmaInfo
*
*
* @param pSma
* @param pSma
* @param pDest
* @param pInfo
* @param pSrc
* @return int32_t
* @return int32_t
*/
*/
int32_t
tdCloneRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
**
pDest
,
SRSmaInfo
*
pSrc
)
{
int32_t
tdCloneRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pInfo
)
{
SVnode
*
pVnode
=
pSma
->
pVnode
;
SRSmaParam
*
param
=
NULL
;
SRSmaParam
*
param
=
NULL
;
if
(
!
pSrc
)
{
if
(
!
pInfo
)
{
*
pDest
=
NULL
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SMetaReader
mr
=
{
0
};
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
SMA_META
(
pSma
),
0
);
metaReaderInit
(
&
mr
,
SMA_META
(
pSma
),
0
);
smaDebug
(
"vgId:%d, rsma clone
, suid is %"
PRIi64
,
TD_VID
(
pVnode
),
pSrc
->
suid
);
smaDebug
(
"vgId:%d, rsma clone
qTaskInfo for suid:%"
PRIi64
,
SMA_VID
(
pSma
),
pInfo
->
suid
);
if
(
metaGetTableEntryByUid
(
&
mr
,
p
Src
->
suid
)
<
0
)
{
if
(
metaGetTableEntryByUid
(
&
mr
,
p
Info
->
suid
)
<
0
)
{
smaError
(
"vgId:%d, rsma clone, failed to get table meta for %"
PRIi64
" since %s"
,
TD_VID
(
pVnode
),
pSrc
->
suid
,
smaError
(
"vgId:%d, rsma clone, failed to get table meta for %"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
pInfo
->
suid
,
terrstr
());
terrstr
());
goto
_err
;
goto
_err
;
}
}
ASSERT
(
mr
.
me
.
type
==
TSDB_SUPER_TABLE
);
ASSERT
(
mr
.
me
.
type
==
TSDB_SUPER_TABLE
);
ASSERT
(
mr
.
me
.
uid
==
p
Src
->
suid
);
ASSERT
(
mr
.
me
.
uid
==
p
Info
->
suid
);
if
(
TABLE_IS_ROLLUP
(
mr
.
me
.
flags
))
{
if
(
TABLE_IS_ROLLUP
(
mr
.
me
.
flags
))
{
param
=
&
mr
.
me
.
stbEntry
.
rsmaParam
;
param
=
&
mr
.
me
.
stbEntry
.
rsmaParam
;
for
(
int32_t
i
=
0
;
i
<
TSDB_RETENTION_L2
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
TSDB_RETENTION_L2
;
++
i
)
{
if
(
tdCloneQTaskInfo
(
pSma
,
p
Src
->
iTaskInfo
[
i
],
pSrc
->
taskInfo
[
i
],
param
,
pSrc
->
suid
,
i
)
<
0
)
{
if
(
tdCloneQTaskInfo
(
pSma
,
p
Info
->
taskInfo
[
i
],
pInfo
->
iTaskInfo
[
i
],
param
,
pInfo
->
suid
,
i
)
<
0
)
{
goto
_err
;
goto
_err
;
}
}
}
}
smaDebug
(
"vgId:%d, rsma clone env success for %"
PRIi64
,
TD_VID
(
pVnode
),
pSrc
->
suid
);
smaDebug
(
"vgId:%d, rsma clone env success for %"
PRIi64
,
SMA_VID
(
pSma
),
pInfo
->
suid
);
}
else
{
terrno
=
TSDB_CODE_RSMA_INVALID_SCHEMA
;
goto
_err
;
}
}
metaReaderClear
(
&
mr
);
metaReaderClear
(
&
mr
);
*
pDest
=
pSrc
;
// pointer copy
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_err:
_err:
*
pDest
=
NULL
;
metaReaderClear
(
&
mr
);
metaReaderClear
(
&
mr
);
smaError
(
"vgId:%d, rsma clone env failed for %"
PRIi64
" since %s"
,
TD_VID
(
pVnode
),
pSrc
->
suid
,
terrstr
());
smaError
(
"vgId:%d, rsma clone env failed for %"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
pInfo
->
suid
,
terrstr
());
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
\ No newline at end of file
source/dnode/vnode/src/tq/tq.c
浏览文件 @
fbc69a10
...
@@ -569,8 +569,6 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe
...
@@ -569,8 +569,6 @@ int32_t tqProcessVgChangeReq(STQ* pTq, int64_t version, char* msg, int32_t msgLe
}
}
int32_t
tqExpandTask
(
STQ
*
pTq
,
SStreamTask
*
pTask
)
{
int32_t
tqExpandTask
(
STQ
*
pTq
,
SStreamTask
*
pTask
)
{
int32_t
code
=
0
;
if
(
pTask
->
taskLevel
==
TASK_LEVEL__AGG
)
{
if
(
pTask
->
taskLevel
==
TASK_LEVEL__AGG
)
{
ASSERT
(
taosArrayGetSize
(
pTask
->
childEpInfo
)
!=
0
);
ASSERT
(
taosArrayGetSize
(
pTask
->
childEpInfo
)
!=
0
);
}
}
...
@@ -581,8 +579,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask) {
...
@@ -581,8 +579,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask) {
pTask
->
outputQueue
=
streamQueueOpen
();
pTask
->
outputQueue
=
streamQueueOpen
();
if
(
pTask
->
inputQueue
==
NULL
||
pTask
->
outputQueue
==
NULL
)
{
if
(
pTask
->
inputQueue
==
NULL
||
pTask
->
outputQueue
==
NULL
)
{
code
=
-
1
;
return
-
1
;
goto
FAIL
;
}
}
pTask
->
inputStatus
=
TASK_INPUT_STATUS__NORMAL
;
pTask
->
inputStatus
=
TASK_INPUT_STATUS__NORMAL
;
...
@@ -627,14 +624,9 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask) {
...
@@ -627,14 +624,9 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask) {
streamSetupTrigger
(
pTask
);
streamSetupTrigger
(
pTask
);
tqInfo
(
"
deploy
stream task on vg %d, task id %d, child id %d"
,
TD_VID
(
pTq
->
pVnode
),
pTask
->
taskId
,
tqInfo
(
"
expand
stream task on vg %d, task id %d, child id %d"
,
TD_VID
(
pTq
->
pVnode
),
pTask
->
taskId
,
pTask
->
selfChildId
);
pTask
->
selfChildId
);
return
0
;
FAIL:
if
(
pTask
->
inputQueue
)
streamQueueClose
(
pTask
->
inputQueue
);
if
(
pTask
->
outputQueue
)
streamQueueClose
(
pTask
->
outputQueue
);
// TODO free executor
return
code
;
}
}
int32_t
tqProcessTaskDeployReq
(
STQ
*
pTq
,
int64_t
version
,
char
*
msg
,
int32_t
msgLen
)
{
int32_t
tqProcessTaskDeployReq
(
STQ
*
pTq
,
int64_t
version
,
char
*
msg
,
int32_t
msgLen
)
{
...
...
source/dnode/vnode/src/tq/tqSink.c
浏览文件 @
fbc69a10
...
@@ -231,34 +231,35 @@ void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
...
@@ -231,34 +231,35 @@ void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
ASSERT
(
pTask
->
tbSink
.
pTSchema
);
ASSERT
(
pTask
->
tbSink
.
pTSchema
);
deleteReq
.
deleteReqs
=
taosArrayInit
(
0
,
sizeof
(
SSingleDeleteReq
));
deleteReq
.
deleteReqs
=
taosArrayInit
(
0
,
sizeof
(
SSingleDeleteReq
));
SSubmitReq
*
p
Req
=
tqBlockToSubmit
(
pVnode
,
pRes
,
pTask
->
tbSink
.
pTSchema
,
true
,
pTask
->
tbSink
.
stbUid
,
SSubmitReq
*
submit
Req
=
tqBlockToSubmit
(
pVnode
,
pRes
,
pTask
->
tbSink
.
pTSchema
,
true
,
pTask
->
tbSink
.
stbUid
,
pTask
->
tbSink
.
stbFullName
,
&
deleteReq
);
pTask
->
tbSink
.
stbFullName
,
&
deleteReq
);
tqDebug
(
"vgId:%d, task %d convert blocks over, put into write-queue"
,
TD_VID
(
pVnode
),
pTask
->
taskId
);
tqDebug
(
"vgId:%d, task %d convert blocks over, put into write-queue"
,
TD_VID
(
pVnode
),
pTask
->
taskId
);
int32_t
code
;
if
(
taosArrayGetSize
(
deleteReq
.
deleteReqs
)
!=
0
)
{
int32_t
len
;
int32_t
code
;
tEncodeSize
(
tEncodeSBatchDeleteReq
,
&
deleteReq
,
len
,
code
);
int32_t
len
;
if
(
code
<
0
)
{
tEncodeSize
(
tEncodeSBatchDeleteReq
,
&
deleteReq
,
len
,
code
);
//
if
(
code
<
0
)
{
ASSERT
(
0
);
//
}
ASSERT
(
0
);
SEncoder
encoder
;
}
void
*
buf
=
rpcMallocCont
(
len
+
sizeof
(
SMsgHead
));
SEncoder
encoder
;
void
*
abuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
void
*
serializedDeleteReq
=
rpcMallocCont
(
len
+
sizeof
(
SMsgHead
));
tEncoderInit
(
&
encoder
,
abuf
,
len
);
void
*
abuf
=
POINTER_SHIFT
(
serializedDeleteReq
,
sizeof
(
SMsgHead
));
tEncodeSBatchDeleteReq
(
&
encoder
,
&
deleteReq
);
tEncoderInit
(
&
encoder
,
abuf
,
len
);
tEncoderClear
(
&
encoder
);
tEncodeSBatchDeleteReq
(
&
encoder
,
&
deleteReq
);
tEncoderClear
(
&
encoder
);
((
SMsgHead
*
)
buf
)
->
vgId
=
pVnode
->
config
.
vgId
;
((
SMsgHead
*
)
serializedDeleteReq
)
->
vgId
=
pVnode
->
config
.
vgId
;
if
(
taosArrayGetSize
(
deleteReq
.
deleteReqs
)
!=
0
)
{
SRpcMsg
msg
=
{
SRpcMsg
msg
=
{
.
msgType
=
TDMT_VND_BATCH_DEL
,
.
msgType
=
TDMT_VND_BATCH_DEL
,
.
pCont
=
buf
,
.
pCont
=
serializedDeleteReq
,
.
contLen
=
len
+
sizeof
(
SMsgHead
),
.
contLen
=
len
+
sizeof
(
SMsgHead
),
};
};
if
(
tmsgPutToQueue
(
&
pVnode
->
msgCb
,
WRITE_QUEUE
,
&
msg
)
!=
0
)
{
if
(
tmsgPutToQueue
(
&
pVnode
->
msgCb
,
WRITE_QUEUE
,
&
msg
)
!=
0
)
{
rpcFreeCont
(
serializedDeleteReq
);
tqDebug
(
"failed to put into write-queue since %s"
,
terrstr
());
tqDebug
(
"failed to put into write-queue since %s"
,
terrstr
());
}
}
}
}
...
@@ -268,11 +269,12 @@ void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
...
@@ -268,11 +269,12 @@ void tqTableSink(SStreamTask* pTask, void* vnode, int64_t ver, void* data) {
// build write msg
// build write msg
SRpcMsg
msg
=
{
SRpcMsg
msg
=
{
.
msgType
=
TDMT_VND_SUBMIT
,
.
msgType
=
TDMT_VND_SUBMIT
,
.
pCont
=
p
Req
,
.
pCont
=
submit
Req
,
.
contLen
=
ntohl
(
p
Req
->
length
),
.
contLen
=
ntohl
(
submit
Req
->
length
),
};
};
if
(
tmsgPutToQueue
(
&
pVnode
->
msgCb
,
WRITE_QUEUE
,
&
msg
)
!=
0
)
{
if
(
tmsgPutToQueue
(
&
pVnode
->
msgCb
,
WRITE_QUEUE
,
&
msg
)
!=
0
)
{
rpcFreeCont
(
submitReq
);
tqDebug
(
"failed to put into write-queue since %s"
,
terrstr
());
tqDebug
(
"failed to put into write-queue since %s"
,
terrstr
());
}
}
}
}
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
fbc69a10
...
@@ -2585,32 +2585,6 @@ void* tsdbGetIvtIdx(SMeta* pMeta) {
...
@@ -2585,32 +2585,6 @@ void* tsdbGetIvtIdx(SMeta* pMeta) {
uint64_t
getReaderMaxVersion
(
STsdbReader
*
pReader
)
{
return
pReader
->
verRange
.
maxVer
;
}
uint64_t
getReaderMaxVersion
(
STsdbReader
*
pReader
)
{
return
pReader
->
verRange
.
maxVer
;
}
/**
* @brief Get all suids since suid
*
* @param pMeta
* @param suid return all suids in one vnode if suid is 0
* @param list
* @return int32_t
*/
int32_t
tsdbGetStbIdList
(
SMeta
*
pMeta
,
int64_t
suid
,
SArray
*
list
)
{
SMStbCursor
*
pCur
=
metaOpenStbCursor
(
pMeta
,
suid
);
if
(
!
pCur
)
{
return
TSDB_CODE_FAILED
;
}
while
(
1
)
{
tb_uid_t
id
=
metaStbCursorNext
(
pCur
);
if
(
id
==
0
)
{
break
;
}
taosArrayPush
(
list
,
&
id
);
}
metaCloseStbCursor
(
pCur
);
return
TSDB_CODE_SUCCESS
;
}
// ====================================== EXPOSED APIs ======================================
// ====================================== EXPOSED APIs ======================================
int32_t
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
SArray
*
pTableList
,
STsdbReader
**
ppReader
,
int32_t
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
SArray
*
pTableList
,
STsdbReader
**
ppReader
,
...
...
source/dnode/vnode/src/vnd/vnodeBufPool.c
浏览文件 @
fbc69a10
...
@@ -78,7 +78,7 @@ void vnodeBufPoolReset(SVBufPool *pPool) {
...
@@ -78,7 +78,7 @@ void vnodeBufPoolReset(SVBufPool *pPool) {
void
*
vnodeBufPoolMalloc
(
SVBufPool
*
pPool
,
int
size
)
{
void
*
vnodeBufPoolMalloc
(
SVBufPool
*
pPool
,
int
size
)
{
SVBufPoolNode
*
pNode
;
SVBufPoolNode
*
pNode
;
void
*
p
;
void
*
p
;
taosThreadSpinLock
(
&
pPool
->
lock
);
if
(
pPool
->
node
.
size
>=
pPool
->
ptr
-
pPool
->
node
.
data
+
size
)
{
if
(
pPool
->
node
.
size
>=
pPool
->
ptr
-
pPool
->
node
.
data
+
size
)
{
// allocate from the anchor node
// allocate from the anchor node
p
=
pPool
->
ptr
;
p
=
pPool
->
ptr
;
...
@@ -89,6 +89,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
...
@@ -89,6 +89,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
pNode
=
taosMemoryMalloc
(
sizeof
(
*
pNode
)
+
size
);
pNode
=
taosMemoryMalloc
(
sizeof
(
*
pNode
)
+
size
);
if
(
pNode
==
NULL
)
{
if
(
pNode
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
taosThreadSpinUnlock
(
&
pPool
->
lock
);
return
NULL
;
return
NULL
;
}
}
...
@@ -101,7 +102,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
...
@@ -101,7 +102,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
pPool
->
size
=
pPool
->
size
+
sizeof
(
*
pNode
)
+
size
;
pPool
->
size
=
pPool
->
size
+
sizeof
(
*
pNode
)
+
size
;
}
}
taosThreadSpinUnlock
(
&
pPool
->
lock
);
return
p
;
return
p
;
}
}
...
@@ -129,6 +130,12 @@ static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool)
...
@@ -129,6 +130,12 @@ static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool)
return
-
1
;
return
-
1
;
}
}
if
(
taosThreadSpinInit
(
&
pPool
->
lock
,
0
)
!=
0
)
{
taosMemoryFree
(
pPool
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
pPool
->
next
=
NULL
;
pPool
->
next
=
NULL
;
pPool
->
pVnode
=
pVnode
;
pPool
->
pVnode
=
pVnode
;
pPool
->
nRef
=
0
;
pPool
->
nRef
=
0
;
...
@@ -145,6 +152,7 @@ static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool)
...
@@ -145,6 +152,7 @@ static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool)
static
int
vnodeBufPoolDestroy
(
SVBufPool
*
pPool
)
{
static
int
vnodeBufPoolDestroy
(
SVBufPool
*
pPool
)
{
vnodeBufPoolReset
(
pPool
);
vnodeBufPoolReset
(
pPool
);
taosThreadSpinDestroy
(
&
pPool
->
lock
);
taosMemoryFree
(
pPool
);
taosMemoryFree
(
pPool
);
return
0
;
return
0
;
}
}
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
fbc69a10
...
@@ -220,6 +220,10 @@ int vnodeCommit(SVnode *pVnode) {
...
@@ -220,6 +220,10 @@ int vnodeCommit(SVnode *pVnode) {
vInfo
(
"vgId:%d, start to commit, commit ID:%"
PRId64
" version:%"
PRId64
,
TD_VID
(
pVnode
),
pVnode
->
state
.
commitID
,
vInfo
(
"vgId:%d, start to commit, commit ID:%"
PRId64
" version:%"
PRId64
,
TD_VID
(
pVnode
),
pVnode
->
state
.
commitID
,
pVnode
->
state
.
applied
);
pVnode
->
state
.
applied
);
// preCommit
// smaSyncPreCommit(pVnode->pSma);
smaAsyncPreCommit
(
pVnode
->
pSma
);
vnodeBufPoolUnRef
(
pVnode
->
inUse
);
vnodeBufPoolUnRef
(
pVnode
->
inUse
);
pVnode
->
inUse
=
NULL
;
pVnode
->
inUse
=
NULL
;
...
@@ -237,10 +241,6 @@ int vnodeCommit(SVnode *pVnode) {
...
@@ -237,10 +241,6 @@ int vnodeCommit(SVnode *pVnode) {
}
}
walBeginSnapshot
(
pVnode
->
pWal
,
pVnode
->
state
.
applied
);
walBeginSnapshot
(
pVnode
->
pWal
,
pVnode
->
state
.
applied
);
// preCommit
// smaSyncPreCommit(pVnode->pSma);
smaAsyncPreCommit
(
pVnode
->
pSma
);
// commit each sub-system
// commit each sub-system
if
(
metaCommit
(
pVnode
->
pMeta
)
<
0
)
{
if
(
metaCommit
(
pVnode
->
pMeta
)
<
0
)
{
ASSERT
(
0
);
ASSERT
(
0
);
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
fbc69a10
...
@@ -424,6 +424,25 @@ int32_t vnodeGetCtbIdList(SVnode *pVnode, int64_t suid, SArray *list) {
...
@@ -424,6 +424,25 @@ int32_t vnodeGetCtbIdList(SVnode *pVnode, int64_t suid, SArray *list) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
vnodeGetStbIdList
(
SVnode
*
pVnode
,
int64_t
suid
,
SArray
*
list
)
{
SMStbCursor
*
pCur
=
metaOpenStbCursor
(
pVnode
->
pMeta
,
suid
);
if
(
!
pCur
)
{
return
TSDB_CODE_FAILED
;
}
while
(
1
)
{
tb_uid_t
id
=
metaStbCursorNext
(
pCur
);
if
(
id
==
0
)
{
break
;
}
taosArrayPush
(
list
,
&
id
);
}
metaCloseStbCursor
(
pCur
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
vnodeGetCtbNum
(
SVnode
*
pVnode
,
int64_t
suid
,
int64_t
*
num
)
{
int32_t
vnodeGetCtbNum
(
SVnode
*
pVnode
,
int64_t
suid
,
int64_t
*
num
)
{
SMCtbCursor
*
pCur
=
metaOpenCtbCursor
(
pVnode
->
pMeta
,
suid
);
SMCtbCursor
*
pCur
=
metaOpenCtbCursor
(
pVnode
->
pMeta
,
suid
);
if
(
!
pCur
)
{
if
(
!
pCur
)
{
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
fbc69a10
...
@@ -303,6 +303,8 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -303,6 +303,8 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) {
return
qWorkerProcessCQueryMsg
(
&
handle
,
pVnode
->
pQuery
,
pMsg
,
0
);
return
qWorkerProcessCQueryMsg
(
&
handle
,
pVnode
->
pQuery
,
pMsg
,
0
);
case
TDMT_VND_FETCH_RSMA
:
case
TDMT_VND_FETCH_RSMA
:
return
smaProcessFetch
(
pVnode
->
pSma
,
pMsg
);
return
smaProcessFetch
(
pVnode
->
pSma
,
pMsg
);
case
TDMT_VND_EXEC_RSMA
:
return
smaProcessExec
(
pVnode
->
pSma
,
pMsg
);
default:
default:
vError
(
"unknown msg type:%d in query queue"
,
pMsg
->
msgType
);
vError
(
"unknown msg type:%d in query queue"
,
pMsg
->
msgType
);
return
TSDB_CODE_VND_APP_ERROR
;
return
TSDB_CODE_VND_APP_ERROR
;
...
@@ -530,7 +532,9 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR
...
@@ -530,7 +532,9 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR
}
}
tqUpdateTbUidList
(
pVnode
->
pTq
,
tbUids
,
true
);
tqUpdateTbUidList
(
pVnode
->
pTq
,
tbUids
,
true
);
tdUpdateTbUidList
(
pVnode
->
pSma
,
pStore
);
if
(
tdUpdateTbUidList
(
pVnode
->
pSma
,
pStore
)
<
0
)
{
goto
_exit
;
}
tdUidStoreFree
(
pStore
);
tdUidStoreFree
(
pStore
);
// prepare rsp
// prepare rsp
...
...
source/libs/executor/inc/tsimplehash.h
浏览文件 @
fbc69a10
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
#define TDENGINE_TSIMPLEHASH_H
#define TDENGINE_TSIMPLEHASH_H
#include "tarray.h"
#include "tarray.h"
#include "tlockfree.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -27,6 +26,10 @@ typedef uint32_t (*_hash_fn_t)(const char *, uint32_t);
...
@@ -27,6 +26,10 @@ typedef uint32_t (*_hash_fn_t)(const char *, uint32_t);
typedef
int32_t
(
*
_equal_fn_t
)(
const
void
*
,
const
void
*
,
size_t
len
);
typedef
int32_t
(
*
_equal_fn_t
)(
const
void
*
,
const
void
*
,
size_t
len
);
typedef
void
(
*
_hash_free_fn_t
)(
void
*
);
typedef
void
(
*
_hash_free_fn_t
)(
void
*
);
/**
* @brief single thread hash
*
*/
typedef
struct
SSHashObj
SSHashObj
;
typedef
struct
SSHashObj
SSHashObj
;
/**
/**
...
@@ -36,7 +39,7 @@ typedef struct SSHashObj SSHashObj;
...
@@ -36,7 +39,7 @@ typedef struct SSHashObj SSHashObj;
* @param fn hash function to generate the hash value
* @param fn hash function to generate the hash value
* @return
* @return
*/
*/
SSHashObj
*
tSimpleHashInit
(
size_t
capacity
,
_hash_fn_t
fn
,
size_t
keyLen
,
size_t
dataLen
);
SSHashObj
*
tSimpleHashInit
(
size_t
capacity
,
_hash_fn_t
fn
);
/**
/**
* return the size of hash table
* return the size of hash table
...
@@ -48,22 +51,26 @@ int32_t tSimpleHashGetSize(const SSHashObj *pHashObj);
...
@@ -48,22 +51,26 @@ int32_t tSimpleHashGetSize(const SSHashObj *pHashObj);
int32_t
tSimpleHashPrint
(
const
SSHashObj
*
pHashObj
);
int32_t
tSimpleHashPrint
(
const
SSHashObj
*
pHashObj
);
/**
/**
* put element into hash table, if the element with the same key exists, update it
* @brief put element into hash table, if the element with the same key exists, update it
* @param pHashObj
*
* @param key
* @param pHashObj
* @param data
* @param key
* @return
* @param keyLen
* @param data
* @param dataLen
* @return int32_t
*/
*/
int32_t
tSimpleHashPut
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
const
void
*
data
);
int32_t
tSimpleHashPut
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
const
void
*
data
,
size_t
dataLen
);
/**
/**
* return the payload data with the specified key
* return the payload data with the specified key
*
*
* @param pHashObj
* @param pHashObj
* @param key
* @param key
* @param keyLen
* @return
* @return
*/
*/
void
*
tSimpleHashGet
(
SSHashObj
*
pHashObj
,
const
void
*
key
);
void
*
tSimpleHashGet
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
);
/**
/**
* remove item with the specified key
* remove item with the specified key
...
@@ -71,7 +78,7 @@ void *tSimpleHashGet(SSHashObj *pHashObj, const void *key);
...
@@ -71,7 +78,7 @@ void *tSimpleHashGet(SSHashObj *pHashObj, const void *key);
* @param key
* @param key
* @param keyLen
* @param keyLen
*/
*/
int32_t
tSimpleHashRemove
(
SSHashObj
*
pHashObj
,
const
void
*
key
);
int32_t
tSimpleHashRemove
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
);
/**
/**
* Clear the hash table.
* Clear the hash table.
...
@@ -98,7 +105,7 @@ size_t tSimpleHashGetMemSize(const SSHashObj *pHashObj);
...
@@ -98,7 +105,7 @@ size_t tSimpleHashGetMemSize(const SSHashObj *pHashObj);
* @param keyLen
* @param keyLen
* @return
* @return
*/
*/
void
*
tSimpleHashGetKey
(
const
SSHashObj
*
pHashObj
,
void
*
data
,
size_t
*
keyLen
);
void
*
tSimpleHashGetKey
(
void
*
data
,
size_t
*
keyLen
);
/**
/**
* Create the hash table iterator
* Create the hash table iterator
...
@@ -109,7 +116,18 @@ void *tSimpleHashGetKey(const SSHashObj* pHashObj, void *data, size_t* keyLen);
...
@@ -109,7 +116,18 @@ void *tSimpleHashGetKey(const SSHashObj* pHashObj, void *data, size_t* keyLen);
*/
*/
void
*
tSimpleHashIterate
(
const
SSHashObj
*
pHashObj
,
void
*
data
,
int32_t
*
iter
);
void
*
tSimpleHashIterate
(
const
SSHashObj
*
pHashObj
,
void
*
data
,
int32_t
*
iter
);
/**
* Create the hash table iterator
*
* @param pHashObj
* @param data
* @param key
* @param iter
* @return void*
*/
void
*
tSimpleHashIterateKV
(
const
SSHashObj
*
pHashObj
,
void
*
data
,
void
**
key
,
int32_t
*
iter
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif // TDENGINE_TSIMPLEHASH_H
#endif // TDENGINE_TSIMPLEHASH_H
\ No newline at end of file
source/libs/executor/src/executor.c
浏览文件 @
fbc69a10
...
@@ -55,7 +55,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
...
@@ -55,7 +55,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
taosArrayClear
(
pInfo
->
pBlockLists
);
taosArrayClear
(
pInfo
->
pBlockLists
);
if
(
type
==
STREAM_INPUT__MERGED_SUBMIT
)
{
if
(
type
==
STREAM_INPUT__MERGED_SUBMIT
)
{
ASSERT
(
numOfBlocks
>
1
);
//
ASSERT(numOfBlocks > 1);
for
(
int32_t
i
=
0
;
i
<
numOfBlocks
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
numOfBlocks
;
i
++
)
{
SSubmitReq
*
pReq
=
*
(
void
**
)
POINTER_SHIFT
(
input
,
i
*
sizeof
(
void
*
));
SSubmitReq
*
pReq
=
*
(
void
**
)
POINTER_SHIFT
(
input
,
i
*
sizeof
(
void
*
));
taosArrayPush
(
pInfo
->
pBlockLists
,
&
pReq
);
taosArrayPush
(
pInfo
->
pBlockLists
,
&
pReq
);
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
fbc69a10
...
@@ -2154,7 +2154,7 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
...
@@ -2154,7 +2154,7 @@ static void doKeepLinearInfo(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlo
static
void
genInterpolationResult
(
STimeSliceOperatorInfo
*
pSliceInfo
,
SExprSupp
*
pExprSup
,
SSDataBlock
*
pResBlock
)
{
static
void
genInterpolationResult
(
STimeSliceOperatorInfo
*
pSliceInfo
,
SExprSupp
*
pExprSup
,
SSDataBlock
*
pResBlock
)
{
int32_t
rows
=
pResBlock
->
info
.
rows
;
int32_t
rows
=
pResBlock
->
info
.
rows
;
blockDataEnsureCapacity
(
pResBlock
,
rows
+
1
);
// todo set the correct primary timestamp column
// todo set the correct primary timestamp column
// output the result
// output the result
...
...
source/libs/executor/src/tsimplehash.c
浏览文件 @
fbc69a10
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
*/
*/
#include "tsimplehash.h"
#include "tsimplehash.h"
#include "os.h"
#include "taoserror.h"
#include "taoserror.h"
#include "tlog.h"
#define SHASH_DEFAULT_LOAD_FACTOR 0.75
#define SHASH_DEFAULT_LOAD_FACTOR 0.75
#define HASH_MAX_CAPACITY (1024 * 1024 * 16)
#define HASH_MAX_CAPACITY (1024 * 1024 * 16)
...
@@ -31,19 +31,21 @@
...
@@ -31,19 +31,21 @@
taosMemoryFreeClear(_n); \
taosMemoryFreeClear(_n); \
} while (0);
} while (0);
#pragma pack(push, 4)
typedef
struct
SHNode
{
typedef
struct
SHNode
{
struct
SHNode
*
next
;
struct
SHNode
*
next
;
uint32_t
keyLen
:
20
;
uint32_t
dataLen
:
12
;
char
data
[];
char
data
[];
}
SHNode
;
}
SHNode
;
#pragma pack(pop)
struct
SSHashObj
{
struct
SSHashObj
{
SHNode
**
hashList
;
SHNode
**
hashList
;
size_t
capacity
;
// number of slots
size_t
capacity
;
// number of slots
int64_t
size
;
// number of elements in hash table
int64_t
size
;
// number of elements in hash table
_hash_fn_t
hashFp
;
// hash function
_hash_fn_t
hashFp
;
// hash function
_equal_fn_t
equalFp
;
// equal function
_equal_fn_t
equalFp
;
// equal function
int32_t
keyLen
;
int32_t
dataLen
;
};
};
static
FORCE_INLINE
int32_t
taosHashCapacity
(
int32_t
length
)
{
static
FORCE_INLINE
int32_t
taosHashCapacity
(
int32_t
length
)
{
...
@@ -54,7 +56,7 @@ static FORCE_INLINE int32_t taosHashCapacity(int32_t length) {
...
@@ -54,7 +56,7 @@ static FORCE_INLINE int32_t taosHashCapacity(int32_t length) {
return
i
;
return
i
;
}
}
SSHashObj
*
tSimpleHashInit
(
size_t
capacity
,
_hash_fn_t
fn
,
size_t
keyLen
,
size_t
dataLen
)
{
SSHashObj
*
tSimpleHashInit
(
size_t
capacity
,
_hash_fn_t
fn
)
{
ASSERT
(
fn
!=
NULL
);
ASSERT
(
fn
!=
NULL
);
if
(
capacity
==
0
)
{
if
(
capacity
==
0
)
{
...
@@ -74,8 +76,6 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn, size_t keyLen, size_t
...
@@ -74,8 +76,6 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn, size_t keyLen, size_t
pHashObj
->
hashFp
=
fn
;
pHashObj
->
hashFp
=
fn
;
ASSERT
((
pHashObj
->
capacity
&
(
pHashObj
->
capacity
-
1
))
==
0
);
ASSERT
((
pHashObj
->
capacity
&
(
pHashObj
->
capacity
-
1
))
==
0
);
pHashObj
->
keyLen
=
keyLen
;
pHashObj
->
dataLen
=
dataLen
;
pHashObj
->
hashList
=
(
SHNode
**
)
taosMemoryCalloc
(
pHashObj
->
capacity
,
sizeof
(
void
*
));
pHashObj
->
hashList
=
(
SHNode
**
)
taosMemoryCalloc
(
pHashObj
->
capacity
,
sizeof
(
void
*
));
if
(
!
pHashObj
->
hashList
)
{
if
(
!
pHashObj
->
hashList
)
{
...
@@ -93,40 +93,41 @@ int32_t tSimpleHashGetSize(const SSHashObj *pHashObj) {
...
@@ -93,40 +93,41 @@ int32_t tSimpleHashGetSize(const SSHashObj *pHashObj) {
return
(
int32_t
)
atomic_load_64
((
int64_t
*
)
&
pHashObj
->
size
);
return
(
int32_t
)
atomic_load_64
((
int64_t
*
)
&
pHashObj
->
size
);
}
}
static
SHNode
*
doCreateHashNode
(
const
void
*
key
,
size_t
keyLen
,
const
void
*
pData
,
size_t
dsize
,
uint32_t
hashVal
)
{
static
SHNode
*
doCreateHashNode
(
const
void
*
key
,
size_t
keyLen
,
const
void
*
data
,
size_t
dataLen
,
uint32_t
hashVal
)
{
SHNode
*
pNewNode
=
taosMemoryMalloc
(
sizeof
(
SHNode
)
+
keyLen
+
d
size
);
SHNode
*
pNewNode
=
taosMemoryMalloc
(
sizeof
(
SHNode
)
+
keyLen
+
d
ataLen
);
if
(
!
pNewNode
)
{
if
(
!
pNewNode
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
pNewNode
->
keyLen
=
keyLen
;
pNewNode
->
dataLen
=
dataLen
;
pNewNode
->
next
=
NULL
;
pNewNode
->
next
=
NULL
;
memcpy
(
GET_SHASH_NODE_DATA
(
pNewNode
),
pData
,
dsize
);
memcpy
(
GET_SHASH_NODE_DATA
(
pNewNode
),
data
,
dataLen
);
memcpy
(
GET_SHASH_NODE_KEY
(
pNewNode
,
d
size
),
key
,
keyLen
);
memcpy
(
GET_SHASH_NODE_KEY
(
pNewNode
,
d
ataLen
),
key
,
keyLen
);
return
pNewNode
;
return
pNewNode
;
}
}
static
void
t
aos
HashTableResize
(
SSHashObj
*
pHashObj
)
{
static
void
t
Simple
HashTableResize
(
SSHashObj
*
pHashObj
)
{
if
(
!
SHASH_NEED_RESIZE
(
pHashObj
))
{
if
(
!
SHASH_NEED_RESIZE
(
pHashObj
))
{
return
;
return
;
}
}
int32_t
newCapacity
=
(
int32_t
)(
pHashObj
->
capacity
<<
1u
);
int32_t
newCapacity
=
(
int32_t
)(
pHashObj
->
capacity
<<
1u
);
if
(
newCapacity
>
HASH_MAX_CAPACITY
)
{
if
(
newCapacity
>
HASH_MAX_CAPACITY
)
{
// uDebug("current capacity:%zu, maximum capacity:%d
, no resize applied due to limitation is reached",
uDebug
(
"current capacity:%zu, maximum capacity:%"
PRIu64
"
, no resize applied due to limitation is reached"
,
//
pHashObj->capacity, HASH_MAX_CAPACITY);
pHashObj
->
capacity
,
HASH_MAX_CAPACITY
);
return
;
return
;
}
}
int64_t
st
=
taosGetTimestampUs
();
int64_t
st
=
taosGetTimestampUs
();
void
*
pNewEntryList
=
taosMemoryRealloc
(
pHashObj
->
hashList
,
sizeof
(
void
*
)
*
newCapacity
);
void
*
pNewEntryList
=
taosMemoryRealloc
(
pHashObj
->
hashList
,
sizeof
(
void
*
)
*
newCapacity
);
if
(
!
pNewEntryList
)
{
if
(
!
pNewEntryList
)
{
// q
Warn("hash resize failed due to out of memory, capacity remain:%zu", pHashObj->capacity);
u
Warn
(
"hash resize failed due to out of memory, capacity remain:%zu"
,
pHashObj
->
capacity
);
return
;
return
;
}
}
size_t
inc
=
newCapacity
-
pHashObj
->
capacity
;
size_t
inc
=
newCapacity
-
pHashObj
->
capacity
;
memset
((
char
*
)
pNewEntryList
+
pHashObj
->
capacity
*
sizeof
(
void
*
),
0
,
inc
);
memset
((
char
*
)
pNewEntryList
+
pHashObj
->
capacity
*
sizeof
(
void
*
),
0
,
inc
*
sizeof
(
void
*
)
);
pHashObj
->
hashList
=
pNewEntryList
;
pHashObj
->
hashList
=
pNewEntryList
;
pHashObj
->
capacity
=
newCapacity
;
pHashObj
->
capacity
=
newCapacity
;
...
@@ -141,8 +142,8 @@ static void taosHashTableResize(SSHashObj *pHashObj) {
...
@@ -141,8 +142,8 @@ static void taosHashTableResize(SSHashObj *pHashObj) {
SHNode
*
pPrev
=
NULL
;
SHNode
*
pPrev
=
NULL
;
while
(
pNode
!=
NULL
)
{
while
(
pNode
!=
NULL
)
{
void
*
key
=
GET_SHASH_NODE_KEY
(
pNode
,
p
HashObj
->
dataLen
);
void
*
key
=
GET_SHASH_NODE_KEY
(
pNode
,
p
Node
->
dataLen
);
uint32_t
hashVal
=
(
*
pHashObj
->
hashFp
)(
key
,
(
uint32_t
)
p
HashObj
->
keyLen
);
uint32_t
hashVal
=
(
*
pHashObj
->
hashFp
)(
key
,
(
uint32_t
)
p
Node
->
keyLen
);
int32_t
newIdx
=
HASH_INDEX
(
hashVal
,
pHashObj
->
capacity
);
int32_t
newIdx
=
HASH_INDEX
(
hashVal
,
pHashObj
->
capacity
);
pNext
=
pNode
->
next
;
pNext
=
pNode
->
next
;
...
@@ -170,23 +171,23 @@ static void taosHashTableResize(SSHashObj *pHashObj) {
...
@@ -170,23 +171,23 @@ static void taosHashTableResize(SSHashObj *pHashObj) {
// ((double)pHashObj->size) / pHashObj->capacity, (et - st) / 1000.0);
// ((double)pHashObj->size) / pHashObj->capacity, (et - st) / 1000.0);
}
}
int32_t
tSimpleHashPut
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
const
void
*
data
)
{
int32_t
tSimpleHashPut
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
const
void
*
data
,
size_t
dataLen
)
{
if
(
!
pHashObj
||
!
key
)
{
if
(
!
pHashObj
||
!
key
)
{
return
-
1
;
return
-
1
;
}
}
uint32_t
hashVal
=
(
*
pHashObj
->
hashFp
)(
key
,
(
uint32_t
)
pHashObj
->
keyLen
);
uint32_t
hashVal
=
(
*
pHashObj
->
hashFp
)(
key
,
(
uint32_t
)
keyLen
);
// need the resize process, write lock applied
// need the resize process, write lock applied
if
(
SHASH_NEED_RESIZE
(
pHashObj
))
{
if
(
SHASH_NEED_RESIZE
(
pHashObj
))
{
t
aos
HashTableResize
(
pHashObj
);
t
Simple
HashTableResize
(
pHashObj
);
}
}
int32_t
slot
=
HASH_INDEX
(
hashVal
,
pHashObj
->
capacity
);
int32_t
slot
=
HASH_INDEX
(
hashVal
,
pHashObj
->
capacity
);
SHNode
*
pNode
=
pHashObj
->
hashList
[
slot
];
SHNode
*
pNode
=
pHashObj
->
hashList
[
slot
];
if
(
!
pNode
)
{
if
(
!
pNode
)
{
SHNode
*
pNewNode
=
doCreateHashNode
(
key
,
pHashObj
->
keyLen
,
data
,
pHashObj
->
dataLen
,
hashVal
);
SHNode
*
pNewNode
=
doCreateHashNode
(
key
,
keyLen
,
data
,
dataLen
,
hashVal
);
if
(
!
pNewNode
)
{
if
(
!
pNewNode
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -197,14 +198,14 @@ int32_t tSimpleHashPut(SSHashObj *pHashObj, const void *key, const void *data) {
...
@@ -197,14 +198,14 @@ int32_t tSimpleHashPut(SSHashObj *pHashObj, const void *key, const void *data) {
}
}
while
(
pNode
)
{
while
(
pNode
)
{
if
((
*
(
pHashObj
->
equalFp
))(
GET_SHASH_NODE_KEY
(
pNode
,
p
HashObj
->
dataLen
),
key
,
pHashObj
->
keyLen
)
==
0
)
{
if
((
*
(
pHashObj
->
equalFp
))(
GET_SHASH_NODE_KEY
(
pNode
,
p
Node
->
dataLen
),
key
,
keyLen
)
==
0
)
{
break
;
break
;
}
}
pNode
=
pNode
->
next
;
pNode
=
pNode
->
next
;
}
}
if
(
!
pNode
)
{
if
(
!
pNode
)
{
SHNode
*
pNewNode
=
doCreateHashNode
(
key
,
pHashObj
->
keyLen
,
data
,
pHashObj
->
dataLen
,
hashVal
);
SHNode
*
pNewNode
=
doCreateHashNode
(
key
,
keyLen
,
data
,
dataLen
,
hashVal
);
if
(
!
pNewNode
)
{
if
(
!
pNewNode
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -212,16 +213,16 @@ int32_t tSimpleHashPut(SSHashObj *pHashObj, const void *key, const void *data) {
...
@@ -212,16 +213,16 @@ int32_t tSimpleHashPut(SSHashObj *pHashObj, const void *key, const void *data) {
pHashObj
->
hashList
[
slot
]
=
pNewNode
;
pHashObj
->
hashList
[
slot
]
=
pNewNode
;
atomic_add_fetch_64
(
&
pHashObj
->
size
,
1
);
atomic_add_fetch_64
(
&
pHashObj
->
size
,
1
);
}
else
{
// update data
}
else
{
// update data
memcpy
(
GET_SHASH_NODE_DATA
(
pNode
),
data
,
pHashObj
->
dataLen
);
memcpy
(
GET_SHASH_NODE_DATA
(
pNode
),
data
,
dataLen
);
}
}
return
0
;
return
0
;
}
}
static
FORCE_INLINE
SHNode
*
doSearchInEntryList
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
int32_t
index
)
{
static
FORCE_INLINE
SHNode
*
doSearchInEntryList
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
int32_t
index
)
{
SHNode
*
pNode
=
pHashObj
->
hashList
[
index
];
SHNode
*
pNode
=
pHashObj
->
hashList
[
index
];
while
(
pNode
)
{
while
(
pNode
)
{
if
((
*
(
pHashObj
->
equalFp
))(
GET_SHASH_NODE_KEY
(
pNode
,
p
HashObj
->
dataLen
),
key
,
pHashObj
->
keyLen
)
==
0
)
{
if
((
*
(
pHashObj
->
equalFp
))(
GET_SHASH_NODE_KEY
(
pNode
,
p
Node
->
dataLen
),
key
,
keyLen
)
==
0
)
{
break
;
break
;
}
}
...
@@ -233,12 +234,12 @@ static FORCE_INLINE SHNode *doSearchInEntryList(SSHashObj *pHashObj, const void
...
@@ -233,12 +234,12 @@ static FORCE_INLINE SHNode *doSearchInEntryList(SSHashObj *pHashObj, const void
static
FORCE_INLINE
bool
taosHashTableEmpty
(
const
SSHashObj
*
pHashObj
)
{
return
tSimpleHashGetSize
(
pHashObj
)
==
0
;
}
static
FORCE_INLINE
bool
taosHashTableEmpty
(
const
SSHashObj
*
pHashObj
)
{
return
tSimpleHashGetSize
(
pHashObj
)
==
0
;
}
void
*
tSimpleHashGet
(
SSHashObj
*
pHashObj
,
const
void
*
key
)
{
void
*
tSimpleHashGet
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
)
{
if
(
!
pHashObj
||
taosHashTableEmpty
(
pHashObj
)
||
!
key
)
{
if
(
!
pHashObj
||
taosHashTableEmpty
(
pHashObj
)
||
!
key
)
{
return
NULL
;
return
NULL
;
}
}
uint32_t
hashVal
=
(
*
pHashObj
->
hashFp
)(
key
,
(
uint32_t
)
pHashObj
->
keyLen
);
uint32_t
hashVal
=
(
*
pHashObj
->
hashFp
)(
key
,
(
uint32_t
)
keyLen
);
int32_t
slot
=
HASH_INDEX
(
hashVal
,
pHashObj
->
capacity
);
int32_t
slot
=
HASH_INDEX
(
hashVal
,
pHashObj
->
capacity
);
SHNode
*
pNode
=
pHashObj
->
hashList
[
slot
];
SHNode
*
pNode
=
pHashObj
->
hashList
[
slot
];
...
@@ -247,7 +248,7 @@ void *tSimpleHashGet(SSHashObj *pHashObj, const void *key) {
...
@@ -247,7 +248,7 @@ void *tSimpleHashGet(SSHashObj *pHashObj, const void *key) {
}
}
char
*
data
=
NULL
;
char
*
data
=
NULL
;
pNode
=
doSearchInEntryList
(
pHashObj
,
key
,
slot
);
pNode
=
doSearchInEntryList
(
pHashObj
,
key
,
keyLen
,
slot
);
if
(
pNode
!=
NULL
)
{
if
(
pNode
!=
NULL
)
{
data
=
GET_SHASH_NODE_DATA
(
pNode
);
data
=
GET_SHASH_NODE_DATA
(
pNode
);
}
}
...
@@ -255,19 +256,19 @@ void *tSimpleHashGet(SSHashObj *pHashObj, const void *key) {
...
@@ -255,19 +256,19 @@ void *tSimpleHashGet(SSHashObj *pHashObj, const void *key) {
return
data
;
return
data
;
}
}
int32_t
tSimpleHashRemove
(
SSHashObj
*
pHashObj
,
const
void
*
key
)
{
int32_t
tSimpleHashRemove
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
)
{
if
(
!
pHashObj
||
!
key
)
{
if
(
!
pHashObj
||
!
key
)
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
uint32_t
hashVal
=
(
*
pHashObj
->
hashFp
)(
key
,
(
uint32_t
)
pHashObj
->
keyLen
);
uint32_t
hashVal
=
(
*
pHashObj
->
hashFp
)(
key
,
(
uint32_t
)
keyLen
);
int32_t
slot
=
HASH_INDEX
(
hashVal
,
pHashObj
->
capacity
);
int32_t
slot
=
HASH_INDEX
(
hashVal
,
pHashObj
->
capacity
);
SHNode
*
pNode
=
pHashObj
->
hashList
[
slot
];
SHNode
*
pNode
=
pHashObj
->
hashList
[
slot
];
SHNode
*
pPrev
=
NULL
;
SHNode
*
pPrev
=
NULL
;
while
(
pNode
)
{
while
(
pNode
)
{
if
((
*
(
pHashObj
->
equalFp
))(
GET_SHASH_NODE_KEY
(
pNode
,
p
HashObj
->
dataLen
),
key
,
pHashObj
->
keyLen
)
==
0
)
{
if
((
*
(
pHashObj
->
equalFp
))(
GET_SHASH_NODE_KEY
(
pNode
,
p
Node
->
dataLen
),
key
,
keyLen
)
==
0
)
{
if
(
!
pPrev
)
{
if
(
!
pPrev
)
{
pHashObj
->
hashList
[
slot
]
=
pNode
->
next
;
pHashObj
->
hashList
[
slot
]
=
pNode
->
next
;
}
else
{
}
else
{
...
@@ -312,6 +313,7 @@ void tSimpleHashCleanup(SSHashObj *pHashObj) {
...
@@ -312,6 +313,7 @@ void tSimpleHashCleanup(SSHashObj *pHashObj) {
tSimpleHashClear
(
pHashObj
);
tSimpleHashClear
(
pHashObj
);
taosMemoryFreeClear
(
pHashObj
->
hashList
);
taosMemoryFreeClear
(
pHashObj
->
hashList
);
taosMemoryFree
(
pHashObj
);
}
}
size_t
tSimpleHashGetMemSize
(
const
SSHashObj
*
pHashObj
)
{
size_t
tSimpleHashGetMemSize
(
const
SSHashObj
*
pHashObj
)
{
...
@@ -322,26 +324,54 @@ size_t tSimpleHashGetMemSize(const SSHashObj *pHashObj) {
...
@@ -322,26 +324,54 @@ size_t tSimpleHashGetMemSize(const SSHashObj *pHashObj) {
return
(
pHashObj
->
capacity
*
sizeof
(
void
*
))
+
sizeof
(
SHNode
)
*
tSimpleHashGetSize
(
pHashObj
)
+
sizeof
(
SSHashObj
);
return
(
pHashObj
->
capacity
*
sizeof
(
void
*
))
+
sizeof
(
SHNode
)
*
tSimpleHashGetSize
(
pHashObj
)
+
sizeof
(
SSHashObj
);
}
}
void
*
tSimpleHashGetKey
(
const
SSHashObj
*
pHashObj
,
void
*
data
,
size_t
*
keyLen
)
{
void
*
tSimpleHashGetKey
(
void
*
data
,
size_t
*
keyLen
)
{
#if 0
SHNode
*
node
=
(
SHNode
*
)((
char
*
)
data
-
offsetof
(
SHNode
,
data
));
int32_t offset = offsetof(SHNode, data);
SHNode *node = ((SHNode *)(char *)data - offset);
if
(
keyLen
)
{
if
(
keyLen
)
{
*keyLen =
pHashObj
->keyLen;
*
keyLen
=
node
->
keyLen
;
}
}
return POINTER_SHIFT(data, pHashObj->dataLen);
return
POINTER_SHIFT
(
data
,
node
->
dataLen
);
}
return GET_SHASH_NODE_KEY(node, pHashObj->dataLen);
void
*
tSimpleHashIterate
(
const
SSHashObj
*
pHashObj
,
void
*
data
,
int32_t
*
iter
)
{
#endif
if
(
!
pHashObj
)
{
if
(
keyLen
)
{
return
NULL
;
*
keyLen
=
pHashObj
->
keyLen
;
}
}
return
POINTER_SHIFT
(
data
,
pHashObj
->
dataLen
);
SHNode
*
pNode
=
NULL
;
if
(
!
data
)
{
for
(
int32_t
i
=
0
;
i
<
pHashObj
->
capacity
;
++
i
)
{
pNode
=
pHashObj
->
hashList
[
i
];
if
(
!
pNode
)
{
continue
;
}
*
iter
=
i
;
return
GET_SHASH_NODE_DATA
(
pNode
);
}
return
NULL
;
}
pNode
=
(
SHNode
*
)((
char
*
)
data
-
offsetof
(
SHNode
,
data
));
if
(
pNode
->
next
)
{
return
GET_SHASH_NODE_DATA
(
pNode
->
next
);
}
++
(
*
iter
);
for
(
int32_t
i
=
*
iter
;
i
<
pHashObj
->
capacity
;
++
i
)
{
pNode
=
pHashObj
->
hashList
[
i
];
if
(
!
pNode
)
{
continue
;
}
*
iter
=
i
;
return
GET_SHASH_NODE_DATA
(
pNode
);
}
return
NULL
;
}
}
void
*
tSimpleHashIterate
(
const
SSHashObj
*
pHashObj
,
void
*
data
,
int32_t
*
iter
)
{
void
*
tSimpleHashIterate
KV
(
const
SSHashObj
*
pHashObj
,
void
*
data
,
void
**
key
,
int32_t
*
iter
)
{
if
(
!
pHashObj
)
{
if
(
!
pHashObj
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -355,6 +385,9 @@ void *tSimpleHashIterate(const SSHashObj *pHashObj, void *data, int32_t *iter) {
...
@@ -355,6 +385,9 @@ void *tSimpleHashIterate(const SSHashObj *pHashObj, void *data, int32_t *iter) {
continue
;
continue
;
}
}
*
iter
=
i
;
*
iter
=
i
;
if
(
key
)
{
*
key
=
GET_SHASH_NODE_KEY
(
pNode
,
pNode
->
dataLen
);
}
return
GET_SHASH_NODE_DATA
(
pNode
);
return
GET_SHASH_NODE_DATA
(
pNode
);
}
}
return
NULL
;
return
NULL
;
...
@@ -363,6 +396,9 @@ void *tSimpleHashIterate(const SSHashObj *pHashObj, void *data, int32_t *iter) {
...
@@ -363,6 +396,9 @@ void *tSimpleHashIterate(const SSHashObj *pHashObj, void *data, int32_t *iter) {
pNode
=
(
SHNode
*
)((
char
*
)
data
-
offsetof
(
SHNode
,
data
));
pNode
=
(
SHNode
*
)((
char
*
)
data
-
offsetof
(
SHNode
,
data
));
if
(
pNode
->
next
)
{
if
(
pNode
->
next
)
{
if
(
key
)
{
*
key
=
GET_SHASH_NODE_KEY
(
pNode
->
next
,
pNode
->
next
->
dataLen
);
}
return
GET_SHASH_NODE_DATA
(
pNode
->
next
);
return
GET_SHASH_NODE_DATA
(
pNode
->
next
);
}
}
...
@@ -373,6 +409,9 @@ void *tSimpleHashIterate(const SSHashObj *pHashObj, void *data, int32_t *iter) {
...
@@ -373,6 +409,9 @@ void *tSimpleHashIterate(const SSHashObj *pHashObj, void *data, int32_t *iter) {
continue
;
continue
;
}
}
*
iter
=
i
;
*
iter
=
i
;
if
(
key
)
{
*
key
=
GET_SHASH_NODE_KEY
(
pNode
,
pNode
->
dataLen
);
}
return
GET_SHASH_NODE_DATA
(
pNode
);
return
GET_SHASH_NODE_DATA
(
pNode
);
}
}
...
...
source/libs/executor/test/tSimpleHashTests.cpp
浏览文件 @
fbc69a10
...
@@ -32,31 +32,33 @@
...
@@ -32,31 +32,33 @@
TEST
(
testCase
,
tSimpleHashTest
)
{
TEST
(
testCase
,
tSimpleHashTest
)
{
SSHashObj
*
pHashObj
=
SSHashObj
*
pHashObj
=
tSimpleHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
)
,
sizeof
(
int64_t
),
sizeof
(
int64_t
)
);
tSimpleHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
));
assert
(
pHashObj
!=
nullptr
);
assert
(
pHashObj
!=
nullptr
);
ASSERT_EQ
(
0
,
tSimpleHashGetSize
(
pHashObj
));
ASSERT_EQ
(
0
,
tSimpleHashGetSize
(
pHashObj
));
size_t
keyLen
=
sizeof
(
int64_t
);
size_t
dataLen
=
sizeof
(
int64_t
);
int64_t
originKeySum
=
0
;
int64_t
originKeySum
=
0
;
for
(
int64_t
i
=
1
;
i
<=
100
;
++
i
)
{
for
(
int64_t
i
=
1
;
i
<=
100
;
++
i
)
{
originKeySum
+=
i
;
originKeySum
+=
i
;
tSimpleHashPut
(
pHashObj
,
(
const
void
*
)
&
i
,
(
const
void
*
)
&
i
);
tSimpleHashPut
(
pHashObj
,
(
const
void
*
)
&
i
,
keyLen
,
(
const
void
*
)
&
i
,
dataLen
);
ASSERT_EQ
(
i
,
tSimpleHashGetSize
(
pHashObj
));
ASSERT_EQ
(
i
,
tSimpleHashGetSize
(
pHashObj
));
}
}
for
(
int64_t
i
=
1
;
i
<=
100
;
++
i
)
{
for
(
int64_t
i
=
1
;
i
<=
100
;
++
i
)
{
void
*
data
=
tSimpleHashGet
(
pHashObj
,
(
const
void
*
)
&
i
);
void
*
data
=
tSimpleHashGet
(
pHashObj
,
(
const
void
*
)
&
i
,
keyLen
);
ASSERT_EQ
(
i
,
*
(
int64_t
*
)
data
);
ASSERT_EQ
(
i
,
*
(
int64_t
*
)
data
);
}
}
void
*
data
=
NULL
;
void
*
data
=
NULL
;
int32_t
iter
=
0
;
int32_t
iter
=
0
;
int64_t
keySum
=
0
;
int64_t
keySum
=
0
;
int64_t
dataSum
=
0
;
int64_t
dataSum
=
0
;
while
((
data
=
tSimpleHashIterate
(
pHashObj
,
data
,
&
iter
)))
{
while
((
data
=
tSimpleHashIterate
(
pHashObj
,
data
,
&
iter
)))
{
void
*
key
=
tSimpleHashGetKey
(
pHashObj
,
data
,
NULL
);
void
*
key
=
tSimpleHashGetKey
(
data
,
NULL
);
keySum
+=
*
(
int64_t
*
)
key
;
keySum
+=
*
(
int64_t
*
)
key
;
dataSum
+=
*
(
int64_t
*
)
data
;
dataSum
+=
*
(
int64_t
*
)
data
;
}
}
...
@@ -65,7 +67,7 @@ TEST(testCase, tSimpleHashTest) {
...
@@ -65,7 +67,7 @@ TEST(testCase, tSimpleHashTest) {
ASSERT_EQ
(
keySum
,
originKeySum
);
ASSERT_EQ
(
keySum
,
originKeySum
);
for
(
int64_t
i
=
1
;
i
<=
100
;
++
i
)
{
for
(
int64_t
i
=
1
;
i
<=
100
;
++
i
)
{
tSimpleHashRemove
(
pHashObj
,
(
const
void
*
)
&
i
);
tSimpleHashRemove
(
pHashObj
,
(
const
void
*
)
&
i
,
keyLen
);
ASSERT_EQ
(
100
-
i
,
tSimpleHashGetSize
(
pHashObj
));
ASSERT_EQ
(
100
-
i
,
tSimpleHashGetSize
(
pHashObj
));
}
}
...
...
source/libs/stream/inc/streamInc.h
浏览文件 @
fbc69a10
...
@@ -32,7 +32,6 @@ typedef struct {
...
@@ -32,7 +32,6 @@ typedef struct {
static
SStreamGlobalEnv
streamEnv
;
static
SStreamGlobalEnv
streamEnv
;
int32_t
streamExec
(
SStreamTask
*
pTask
);
int32_t
streamPipelineExec
(
SStreamTask
*
pTask
,
int32_t
batchNum
,
bool
dispatch
);
int32_t
streamPipelineExec
(
SStreamTask
*
pTask
,
int32_t
batchNum
,
bool
dispatch
);
int32_t
streamDispatch
(
SStreamTask
*
pTask
);
int32_t
streamDispatch
(
SStreamTask
*
pTask
);
...
...
source/libs/stream/src/stream.c
浏览文件 @
fbc69a10
...
@@ -185,7 +185,9 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S
...
@@ -185,7 +185,9 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S
tFreeStreamDispatchReq
(
pReq
);
tFreeStreamDispatchReq
(
pReq
);
if
(
exec
)
{
if
(
exec
)
{
streamTryExec
(
pTask
);
if
(
streamTryExec
(
pTask
)
<
0
)
{
return
-
1
;
}
if
(
pTask
->
outputType
==
TASK_OUTPUT__FIXED_DISPATCH
||
pTask
->
outputType
==
TASK_OUTPUT__SHUFFLE_DISPATCH
)
{
if
(
pTask
->
outputType
==
TASK_OUTPUT__FIXED_DISPATCH
||
pTask
->
outputType
==
TASK_OUTPUT__SHUFFLE_DISPATCH
)
{
streamDispatch
(
pTask
);
streamDispatch
(
pTask
);
...
@@ -221,7 +223,9 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp) {
...
@@ -221,7 +223,9 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp) {
}
}
int32_t
streamProcessRunReq
(
SStreamTask
*
pTask
)
{
int32_t
streamProcessRunReq
(
SStreamTask
*
pTask
)
{
streamTryExec
(
pTask
);
if
(
streamTryExec
(
pTask
)
<
0
)
{
return
-
1
;
}
if
(
pTask
->
outputType
==
TASK_OUTPUT__FIXED_DISPATCH
||
pTask
->
outputType
==
TASK_OUTPUT__SHUFFLE_DISPATCH
)
{
if
(
pTask
->
outputType
==
TASK_OUTPUT__FIXED_DISPATCH
||
pTask
->
outputType
==
TASK_OUTPUT__SHUFFLE_DISPATCH
)
{
streamDispatch
(
pTask
);
streamDispatch
(
pTask
);
...
...
source/libs/stream/src/streamMeta.c
浏览文件 @
fbc69a10
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include "executor.h"
#include "executor.h"
#include "tstream.h"
#include "tstream.h"
#include "ttimer.h"
SStreamMeta
*
streamMetaOpen
(
const
char
*
path
,
void
*
ahandle
,
FTaskExpand
expandFunc
)
{
SStreamMeta
*
streamMetaOpen
(
const
char
*
path
,
void
*
ahandle
,
FTaskExpand
expandFunc
)
{
SStreamMeta
*
pMeta
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamMeta
));
SStreamMeta
*
pMeta
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamMeta
));
...
@@ -99,16 +100,19 @@ int32_t streamMetaAddSerializedTask(SStreamMeta* pMeta, int64_t startVer, char*
...
@@ -99,16 +100,19 @@ int32_t streamMetaAddSerializedTask(SStreamMeta* pMeta, int64_t startVer, char*
goto
FAIL
;
goto
FAIL
;
}
}
taosHashPut
(
pMeta
->
pTasks
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
&
pTask
,
sizeof
(
void
*
));
if
(
taosHashPut
(
pMeta
->
pTasks
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
&
pTask
,
sizeof
(
void
*
))
<
0
)
{
goto
FAIL
;
}
if
(
tdbTbUpsert
(
pMeta
->
pTaskDb
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
msg
,
msgLen
,
&
pMeta
->
txn
)
<
0
)
{
if
(
tdbTbUpsert
(
pMeta
->
pTaskDb
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
msg
,
msgLen
,
&
pMeta
->
txn
)
<
0
)
{
taosHashRemove
(
pMeta
->
pTasks
,
&
pTask
->
taskId
,
sizeof
(
int32_t
));
ASSERT
(
0
);
ASSERT
(
0
);
return
-
1
;
goto
FAIL
;
}
}
return
0
;
return
0
;
FAIL:
FAIL:
if
(
pTask
)
t
aosMemoryFree
(
pTask
);
if
(
pTask
)
t
FreeSStreamTask
(
pTask
);
return
-
1
;
return
-
1
;
}
}
...
@@ -158,11 +162,28 @@ int32_t streamMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId) {
...
@@ -158,11 +162,28 @@ int32_t streamMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId) {
SStreamTask
*
pTask
=
*
ppTask
;
SStreamTask
*
pTask
=
*
ppTask
;
taosHashRemove
(
pMeta
->
pTasks
,
&
taskId
,
sizeof
(
int32_t
));
taosHashRemove
(
pMeta
->
pTasks
,
&
taskId
,
sizeof
(
int32_t
));
atomic_store_8
(
&
pTask
->
taskStatus
,
TASK_STATUS__DROPPING
);
atomic_store_8
(
&
pTask
->
taskStatus
,
TASK_STATUS__DROPPING
);
}
if
(
tdbTbDelete
(
pMeta
->
pTaskDb
,
&
taskId
,
sizeof
(
int32_t
),
&
pMeta
->
txn
)
<
0
)
{
if
(
tdbTbDelete
(
pMeta
->
pTaskDb
,
&
taskId
,
sizeof
(
int32_t
),
&
pMeta
->
txn
)
<
0
)
{
/*return -1;*/
/*return -1;*/
}
if
(
pTask
->
triggerParam
!=
0
)
{
taosTmrStop
(
pTask
->
timer
);
}
while
(
1
)
{
int8_t
schedStatus
=
atomic_val_compare_exchange_8
(
&
pTask
->
schedStatus
,
TASK_SCHED_STATUS__INACTIVE
,
TASK_SCHED_STATUS__DROPPING
);
if
(
schedStatus
==
TASK_SCHED_STATUS__INACTIVE
)
{
tFreeSStreamTask
(
pTask
);
break
;
}
else
if
(
schedStatus
==
TASK_SCHED_STATUS__DROPPING
)
{
break
;
}
taosMsleep
(
10
);
}
}
}
return
0
;
return
0
;
}
}
...
...
source/libs/stream/src/streamQueue.c
浏览文件 @
fbc69a10
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +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/>.
*/
*/
#include "
tstream
.h"
#include "
streamInc
.h"
SStreamQueue
*
streamQueueOpen
()
{
SStreamQueue
*
streamQueueOpen
()
{
SStreamQueue
*
pQueue
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamQueue
));
SStreamQueue
*
pQueue
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamQueue
));
...
@@ -36,9 +36,12 @@ void streamQueueClose(SStreamQueue* queue) {
...
@@ -36,9 +36,12 @@ void streamQueueClose(SStreamQueue* queue) {
while
(
1
)
{
while
(
1
)
{
void
*
qItem
=
streamQueueNextItem
(
queue
);
void
*
qItem
=
streamQueueNextItem
(
queue
);
if
(
qItem
)
{
if
(
qItem
)
{
taos
FreeQitem
(
qItem
);
stream
FreeQitem
(
qItem
);
}
else
{
}
else
{
return
;
break
;
}
}
}
}
taosFreeQall
(
queue
->
qall
);
taosCloseQueue
(
queue
->
queue
);
taosMemoryFree
(
queue
);
}
}
source/libs/stream/src/streamTask.c
浏览文件 @
fbc69a10
...
@@ -152,9 +152,17 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
...
@@ -152,9 +152,17 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) {
}
}
void
tFreeSStreamTask
(
SStreamTask
*
pTask
)
{
void
tFreeSStreamTask
(
SStreamTask
*
pTask
)
{
streamQueueClose
(
pTask
->
inputQueue
);
if
(
pTask
->
inputQueue
)
streamQueueClose
(
pTask
->
inputQueue
);
streamQueueClose
(
pTask
->
outputQueue
);
if
(
pTask
->
outputQueue
)
streamQueueClose
(
pTask
->
outputQueue
);
if
(
pTask
->
exec
.
qmsg
)
taosMemoryFree
(
pTask
->
exec
.
qmsg
);
if
(
pTask
->
exec
.
qmsg
)
taosMemoryFree
(
pTask
->
exec
.
qmsg
);
if
(
pTask
->
exec
.
executor
)
qDestroyTask
(
pTask
->
exec
.
executor
);
if
(
pTask
->
exec
.
executor
)
qDestroyTask
(
pTask
->
exec
.
executor
);
taosArrayDestroy
(
pTask
->
childEpInfo
);
if
(
pTask
->
outputType
==
TASK_OUTPUT__TABLE
)
{
tDeleteSSchemaWrapper
(
pTask
->
tbSink
.
pSchemaWrapper
);
taosMemoryFree
(
pTask
->
tbSink
.
pTSchema
);
}
if
(
pTask
->
outputType
==
TASK_OUTPUT__SHUFFLE_DISPATCH
)
{
taosArrayDestroy
(
pTask
->
shuffleDispatcher
.
dbInfo
.
pVgroupInfos
);
}
taosMemoryFree
(
pTask
);
taosMemoryFree
(
pTask
);
}
}
source/libs/sync/inc/syncInt.h
浏览文件 @
fbc69a10
...
@@ -237,7 +237,7 @@ void syncNodeVoteForSelf(SSyncNode* pSyncNode);
...
@@ -237,7 +237,7 @@ void syncNodeVoteForSelf(SSyncNode* pSyncNode);
bool
syncNodeHasSnapshot
(
SSyncNode
*
pSyncNode
);
bool
syncNodeHasSnapshot
(
SSyncNode
*
pSyncNode
);
void
syncNodeMaybeUpdateCommitBySnapshot
(
SSyncNode
*
pSyncNode
);
void
syncNodeMaybeUpdateCommitBySnapshot
(
SSyncNode
*
pSyncNode
);
SyncIndex
syncNodeGetLastIndex
(
SSyncNode
*
pSyncNode
);
SyncIndex
syncNodeGetLastIndex
(
const
SSyncNode
*
pSyncNode
);
SyncTerm
syncNodeGetLastTerm
(
SSyncNode
*
pSyncNode
);
SyncTerm
syncNodeGetLastTerm
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeGetLastIndexTerm
(
SSyncNode
*
pSyncNode
,
SyncIndex
*
pLastIndex
,
SyncTerm
*
pLastTerm
);
int32_t
syncNodeGetLastIndexTerm
(
SSyncNode
*
pSyncNode
,
SyncIndex
*
pLastIndex
,
SyncTerm
*
pLastTerm
);
...
...
source/libs/sync/src/syncCommit.c
浏览文件 @
fbc69a10
...
@@ -146,23 +146,47 @@ int32_t syncNodeDynamicQuorum(const SSyncNode* pSyncNode) {
...
@@ -146,23 +146,47 @@ int32_t syncNodeDynamicQuorum(const SSyncNode* pSyncNode) {
int64_t
timeNow
=
taosGetTimestampMs
();
int64_t
timeNow
=
taosGetTimestampMs
();
for
(
int
i
=
0
;
i
<
pSyncNode
->
peersNum
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pSyncNode
->
peersNum
;
++
i
)
{
int64_t
peerStartTime
=
syncIndexMgrGetStartTime
(
pSyncNode
->
pNextIndex
,
&
(
pSyncNode
->
peersId
)[
i
]);
int64_t
peerStartTime
=
syncIndexMgrGetStartTime
(
pSyncNode
->
pNextIndex
,
&
(
pSyncNode
->
peersId
)[
i
]);
int64_t
peerRecvTime
=
syncIndexMgrGetRecvTime
(
pSyncNode
->
pNextIndex
,
&
(
pSyncNode
->
peersId
)[
i
]);
int64_t
peerRecvTime
=
syncIndexMgrGetRecvTime
(
pSyncNode
->
pNextIndex
,
&
(
pSyncNode
->
peersId
)[
i
]);
SyncIndex
peerMatchIndex
=
syncIndexMgrGetIndex
(
pSyncNode
->
pMatchIndex
,
&
(
pSyncNode
->
peersId
)[
i
]);
int64_t
recvTimeDiff
=
syncNodeAbs64
(
peerRecvTime
,
timeNow
);
int64_t
recvTimeDiff
=
TABS
(
peerRecvTime
-
timeNow
);
int64_t
startTimeDiff
=
syncNodeAbs64
(
peerStartTime
,
pSyncNode
->
startTime
);
int64_t
startTimeDiff
=
TABS
(
peerStartTime
-
pSyncNode
->
startTime
);
int64_t
logDiff
=
TABS
(
peerMatchIndex
-
syncNodeGetLastIndex
(
pSyncNode
));
/*
int64_t recvTimeDiff = syncNodeAbs64(peerRecvTime, timeNow);
int64_t startTimeDiff = syncNodeAbs64(peerStartTime, pSyncNode->startTime);
int64_t logDiff = syncNodeAbs64(peerMatchIndex, syncNodeGetLastIndex(pSyncNode));
*/
int32_t
addQuorum
=
0
;
int32_t
addQuorum
=
0
;
if
(
recvTimeDiff
<
SYNC_MAX_RECV_TIME_RANGE_MS
)
{
if
(
recvTimeDiff
<
SYNC_MAX_RECV_TIME_RANGE_MS
)
{
addQuorum
=
1
;
if
(
startTimeDiff
<
SYNC_MAX_START_TIME_RANGE_MS
)
{
addQuorum
=
1
;
}
else
{
if
(
logDiff
<
SYNC_ADD_QUORUM_COUNT
)
{
addQuorum
=
1
;
}
else
{
addQuorum
=
0
;
}
}
}
else
{
}
else
{
addQuorum
=
0
;
addQuorum
=
0
;
}
}
if
(
startTimeDiff
>
SYNC_MAX_START_TIME_RANGE_MS
)
{
/*
addQuorum
=
0
;
if (recvTimeDiff < SYNC_MAX_RECV_TIME_RANGE_MS) {
}
addQuorum = 1;
} else {
addQuorum = 0;
}
if (startTimeDiff > SYNC_MAX_START_TIME_RANGE_MS) {
addQuorum = 0;
}
*/
quorum
+=
addQuorum
;
quorum
+=
addQuorum
;
}
}
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
fbc69a10
...
@@ -2284,7 +2284,7 @@ bool syncNodeHasSnapshot(SSyncNode* pSyncNode) {
...
@@ -2284,7 +2284,7 @@ bool syncNodeHasSnapshot(SSyncNode* pSyncNode) {
// return max(logLastIndex, snapshotLastIndex)
// return max(logLastIndex, snapshotLastIndex)
// if no snapshot and log, return -1
// if no snapshot and log, return -1
SyncIndex
syncNodeGetLastIndex
(
SSyncNode
*
pSyncNode
)
{
SyncIndex
syncNodeGetLastIndex
(
const
SSyncNode
*
pSyncNode
)
{
SSnapshot
snapshot
=
{.
data
=
NULL
,
.
lastApplyIndex
=
-
1
,
.
lastApplyTerm
=
0
,
.
lastConfigIndex
=
-
1
};
SSnapshot
snapshot
=
{.
data
=
NULL
,
.
lastApplyIndex
=
-
1
,
.
lastApplyTerm
=
0
,
.
lastConfigIndex
=
-
1
};
if
(
pSyncNode
->
pFsm
->
FpGetSnapshotInfo
!=
NULL
)
{
if
(
pSyncNode
->
pFsm
->
FpGetSnapshotInfo
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpGetSnapshotInfo
(
pSyncNode
->
pFsm
,
&
snapshot
);
pSyncNode
->
pFsm
->
FpGetSnapshotInfo
(
pSyncNode
->
pFsm
,
&
snapshot
);
...
@@ -2773,11 +2773,27 @@ int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* p
...
@@ -2773,11 +2773,27 @@ int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* p
return
0
;
return
0
;
}
}
if
(
ths
->
vgId
>
1
)
{
if
(
pEntry
->
term
<
ths
->
pRaftStore
->
currentTerm
)
{
syncNodeEventLog
(
ths
,
"I am vnode, can not do leader transfer"
);
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"little term:%lu, can not do leader transfer"
,
pEntry
->
term
);
syncNodeEventLog
(
ths
,
logBuf
);
return
0
;
}
if
(
pEntry
->
index
<
syncNodeGetLastIndex
(
ths
))
{
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"little index:%ld, can not do leader transfer"
,
pEntry
->
index
);
syncNodeEventLog
(
ths
,
logBuf
);
return
0
;
return
0
;
}
}
/*
if (ths->vgId > 1) {
syncNodeEventLog(ths, "I am vnode, can not do leader transfer");
return 0;
}
*/
do
{
do
{
char
logBuf
[
128
];
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"do leader transfer, index:%ld"
,
pEntry
->
index
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"do leader transfer, index:%ld"
,
pEntry
->
index
);
...
...
source/util/src/terror.c
浏览文件 @
fbc69a10
...
@@ -293,6 +293,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_CGROUP_USED, "Consumer group being
...
@@ -293,6 +293,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_CGROUP_USED, "Consumer group being
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_STREAM_ALREADY_EXIST
,
"Stream already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_STREAM_ALREADY_EXIST
,
"Stream already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_STREAM_NOT_EXIST
,
"Stream not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_STREAM_NOT_EXIST
,
"Stream not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_STREAM_OPTION
,
"Invalid stream option"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_STREAM_OPTION
,
"Invalid stream option"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_STREAM_MUST_BE_DELETED
,
"Stream must be dropped first"
)
// mnode-sma
// mnode-sma
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_SMA_ALREADY_EXIST
,
"SMA already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_SMA_ALREADY_EXIST
,
"SMA already exists"
)
...
@@ -616,6 +617,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_FILE_CORRUPTED, "Rsma file corrupted
...
@@ -616,6 +617,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_FILE_CORRUPTED, "Rsma file corrupted
TAOS_DEFINE_ERROR
(
TSDB_CODE_RSMA_REMOVE_EXISTS
,
"Rsma remove exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RSMA_REMOVE_EXISTS
,
"Rsma remove exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP
,
"Rsma fetch msg is messed up"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP
,
"Rsma fetch msg is messed up"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RSMA_EMPTY_INFO
,
"Rsma info is empty"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RSMA_EMPTY_INFO
,
"Rsma info is empty"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_RSMA_INVALID_SCHEMA
,
"Rsma invalid schema"
)
//index
//index
TAOS_DEFINE_ERROR
(
TSDB_CODE_INDEX_REBUILDING
,
"Index is rebuilding"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INDEX_REBUILDING
,
"Index is rebuilding"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录