Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
74834aea
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
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看板
提交
74834aea
编写于
7月 28, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(stream): prepare hb to mnode from stream meta.
上级
728112ed
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
91 addition
and
48 deletion
+91
-48
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-0
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+12
-2
include/util/tencode.h
include/util/tencode.h
+1
-1
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+0
-7
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+7
-9
source/libs/stream/src/stream.c
source/libs/stream/src/stream.c
+1
-1
source/libs/stream/src/streamDispatch.c
source/libs/stream/src/streamDispatch.c
+5
-5
source/libs/stream/src/streamMeta.c
source/libs/stream/src/streamMeta.c
+64
-23
未找到文件。
include/common/tmsgdef.h
浏览文件 @
74834aea
...
...
@@ -174,6 +174,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_MND_SERVER_VERSION
,
"server-version"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_UPTIME_TIMER
,
"uptime-timer"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_TMQ_LOST_CONSUMER_CLEAR
,
"lost-consumer-clear"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_STREAM_HEARTBEAT
,
"stream-heartbeat"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MAX_MSG
,
"mnd-max"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_BALANCE_VGROUP_LEADER
,
"balance-vgroup-leader"
,
NULL
,
NULL
)
...
...
include/libs/stream/tstream.h
浏览文件 @
74834aea
...
...
@@ -14,6 +14,7 @@
*/
#include "os.h"
#include "ttimer.h"
#include "streamState.h"
#include "tdatablock.h"
#include "tdbInt.h"
...
...
@@ -369,6 +370,7 @@ typedef struct SStreamMeta {
int64_t
streamBackendRid
;
SHashObj
*
pTaskBackendUnique
;
TdThreadMutex
backendMutex
;
tmr_h
hbTmr
;
int32_t
chkptNotReadyTasks
;
SArray
*
checkpointSaved
;
...
...
@@ -515,6 +517,14 @@ typedef struct {
int32_t
tEncodeStreamCheckpointReadyMsg
(
SEncoder
*
pEncoder
,
const
SStreamCheckpointReadyMsg
*
pRsp
);
int32_t
tDecodeStreamCheckpointReadyMsg
(
SDecoder
*
pDecoder
,
SStreamCheckpointReadyMsg
*
pRsp
);
typedef
struct
{
int32_t
vgId
;
int32_t
numOfTasks
;
}
SStreamHbMsg
;
int32_t
tEncodeStreamHbMsg
(
SEncoder
*
pEncoder
,
const
SStreamHbMsg
*
pRsp
);
int32_t
tDecodeStreamHbMsg
(
SDecoder
*
pDecoder
,
SStreamHbMsg
*
pRsp
);
typedef
struct
{
int64_t
streamId
;
int32_t
upstreamTaskId
;
...
...
@@ -572,7 +582,7 @@ bool streamTaskShouldStop(const SStreamStatus* pStatus);
bool
streamTaskShouldPause
(
const
SStreamStatus
*
pStatus
);
bool
streamTaskIsIdle
(
const
SStreamTask
*
pTask
);
SStreamChildEpInfo
*
streamTaskGetUpstreamTaskEpInfo
(
SStreamTask
*
pTask
,
int32_t
taskId
);
void
initRpcMsg
(
SRpcMsg
*
pMsg
,
int32_t
msgType
,
void
*
pCont
,
int32_t
contLen
);
int32_t
streamScanExec
(
SStreamTask
*
pTask
,
int32_t
batchSz
);
char
*
createStreamTaskIdStr
(
int64_t
streamId
,
int32_t
taskId
);
...
...
@@ -637,7 +647,7 @@ void streamMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId);
int32_t
streamMetaBegin
(
SStreamMeta
*
pMeta
);
int32_t
streamMetaCommit
(
SStreamMeta
*
pMeta
);
int32_t
streamLoadTasks
(
SStreamMeta
*
pMeta
,
int64_t
ver
);
int32_t
streamLoadTasks
(
SStreamMeta
*
pMeta
);
// checkpoint
int32_t
streamProcessCheckpointSourceReq
(
SStreamTask
*
pTask
,
SStreamCheckpointSourceReq
*
pReq
);
...
...
include/util/tencode.h
浏览文件 @
74834aea
...
...
@@ -89,7 +89,7 @@ typedef struct {
RET = -1; \
} \
tEncoderClear(&coder); \
} while (0)
} while (0)
;
static
void
*
tEncoderMalloc
(
SEncoder
*
pCoder
,
int32_t
size
);
static
void
*
tDecoderMalloc
(
SDecoder
*
pCoder
,
int32_t
size
);
...
...
source/dnode/vnode/src/inc/tq.h
浏览文件 @
74834aea
...
...
@@ -112,17 +112,10 @@ struct STQ {
SStreamMeta
*
pStreamMeta
;
};
typedef
struct
{
int8_t
inited
;
tmr_h
timer
;
}
STqMgmt
;
typedef
struct
{
int32_t
size
;
}
STqOffsetHead
;
static
STqMgmt
tqMgmt
=
{
0
};
int32_t
tEncodeSTqHandle
(
SEncoder
*
pEncoder
,
const
STqHandle
*
pHandle
);
int32_t
tDecodeSTqHandle
(
SDecoder
*
pDecoder
,
STqHandle
*
pHandle
);
void
tqDestroyTqHandle
(
void
*
data
);
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
74834aea
...
...
@@ -15,6 +15,12 @@
#include "tq.h"
typedef
struct
{
int8_t
inited
;
}
STqMgmt
;
static
STqMgmt
tqMgmt
=
{
0
};
// 0: not init
// 1: already inited
// 2: wait to be inited or cleaup
...
...
@@ -32,11 +38,6 @@ int32_t tqInit() {
}
if
(
old
==
0
)
{
tqMgmt
.
timer
=
taosTmrInit
(
10000
,
100
,
10000
,
"TQ"
);
if
(
tqMgmt
.
timer
==
NULL
)
{
atomic_store_8
(
&
tqMgmt
.
inited
,
0
);
return
-
1
;
}
if
(
streamInit
()
<
0
)
{
return
-
1
;
}
...
...
@@ -54,7 +55,6 @@ void tqCleanUp() {
}
if
(
old
==
1
)
{
taosTmrCleanUp
(
tqMgmt
.
timer
);
streamCleanUp
();
atomic_store_8
(
&
tqMgmt
.
inited
,
0
);
}
...
...
@@ -132,9 +132,7 @@ int32_t tqInitialize(STQ* pTq) {
return
-
1
;
}
// the version is kept in task's meta data
// todo check if this version is required or not
if
(
streamLoadTasks
(
pTq
->
pStreamMeta
,
walGetCommittedVer
(
pTq
->
pVnode
->
pWal
))
<
0
)
{
if
(
streamLoadTasks
(
pTq
->
pStreamMeta
)
<
0
)
{
return
-
1
;
}
...
...
source/libs/stream/src/stream.c
浏览文件 @
74834aea
...
...
@@ -31,7 +31,7 @@ int32_t streamInit() {
}
if
(
old
==
0
)
{
streamEnv
.
timer
=
taosTmrInit
(
1000
0
,
100
,
10000
,
"STREAM"
);
streamEnv
.
timer
=
taosTmrInit
(
1000
,
100
,
10000
,
"STREAM"
);
if
(
streamEnv
.
timer
==
NULL
)
{
atomic_store_8
(
&
streamEnv
.
inited
,
0
);
return
-
1
;
...
...
source/libs/stream/src/streamDispatch.c
浏览文件 @
74834aea
...
...
@@ -32,7 +32,7 @@ typedef struct {
SEpSet
epset
;
}
SStreamChkptReadyInfo
;
static
void
doRetryDispatchData
(
void
*
param
,
void
*
tmrId
);
static
void
doRetryDispatchData
(
void
*
param
,
void
*
tmrId
);
static
int32_t
doSendDispatchMsg
(
SStreamTask
*
pTask
,
const
SStreamDispatchReq
*
pReq
,
int32_t
vgId
,
SEpSet
*
pEpSet
);
static
int32_t
streamAddBlockIntoDispatchMsg
(
const
SSDataBlock
*
pBlock
,
SStreamDispatchReq
*
pReq
);
static
int32_t
streamSearchAndAddBlock
(
SStreamTask
*
pTask
,
SStreamDispatchReq
*
pReqs
,
SSDataBlock
*
pDataBlock
,
...
...
@@ -40,10 +40,10 @@ static int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* p
static
int32_t
doDispatchScanHistoryFinishMsg
(
SStreamTask
*
pTask
,
const
SStreamScanHistoryFinishReq
*
pReq
,
int32_t
vgId
,
SEpSet
*
pEpSet
);
static
void
initRpcMsg
(
SRpcMsg
*
pMsg
,
int32_t
msgType
,
void
*
pCont
,
int32_t
contLen
)
{
pMsg
->
msgType
=
msgType
;
pMsg
->
pCont
=
pCont
;
pMsg
->
contLen
=
contLen
;
void
initRpcMsg
(
SRpcMsg
*
pMsg
,
int32_t
msgType
,
void
*
pCont
,
int32_t
contLen
)
{
pMsg
->
msgType
=
msgType
;
pMsg
->
pCont
=
pCont
;
pMsg
->
contLen
=
contLen
;
}
int32_t
tDecodeStreamDispatchReq
(
SDecoder
*
pDecoder
,
SStreamDispatchReq
*
pReq
)
{
...
...
source/libs/stream/src/streamMeta.c
浏览文件 @
74834aea
...
...
@@ -25,6 +25,8 @@ int32_t streamBackendCfWrapperId = 0;
int64_t
streamGetLatestCheckpointId
(
SStreamMeta
*
pMeta
);
static
void
metaHbToMnode
(
void
*
param
,
void
*
tmrId
);
static
void
streamMetaEnvInit
()
{
streamBackendId
=
taosOpenRef
(
64
,
streamBackendCleanup
);
streamBackendCfWrapperId
=
taosOpenRef
(
64
,
streamBackendHandleCleanup
);
...
...
@@ -90,13 +92,8 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
pMeta
->
ahandle
=
ahandle
;
pMeta
->
expandFunc
=
expandFunc
;
// memset(streamPath, 0, len);
// sprintf(streamPath, "%s/%s", pMeta->path, "state");
// code = taosMulModeMkDir(streamPath, 0755);
// if (code != 0) {
// terrno = TAOS_SYSTEM_ERROR(code);
// goto _err;
// }
// send heartbeat every 20sec.
// pMeta->hbTmr = taosTmrStart(metaHbToMnode, 20000, pMeta, streamEnv.timer);
pMeta
->
pTaskBackendUnique
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_ENTRY_LOCK
);
...
...
@@ -394,35 +391,24 @@ int32_t streamMetaBegin(SStreamMeta* pMeta) {
// todo add error log
int32_t
streamMetaCommit
(
SStreamMeta
*
pMeta
)
{
if
(
tdbCommit
(
pMeta
->
db
,
pMeta
->
txn
)
<
0
)
{
qError
(
"
failed to commit stream meta"
);
qError
(
"
vgId:%d failed to commit stream meta"
,
pMeta
->
vgId
);
return
-
1
;
}
if
(
tdbPostCommit
(
pMeta
->
db
,
pMeta
->
txn
)
<
0
)
{
qError
(
"
failed to commit stream meta"
);
qError
(
"
vgId:%d failed to do post-commit stream meta"
,
pMeta
->
vgId
);
return
-
1
;
}
if
(
tdbBegin
(
pMeta
->
db
,
&
pMeta
->
txn
,
tdbDefaultMalloc
,
tdbDefaultFree
,
NULL
,
TDB_TXN_WRITE
|
TDB_TXN_READ_UNCOMMITTED
)
<
0
)
{
qError
(
"vgId:%d failed to begin trans"
,
pMeta
->
vgId
);
return
-
1
;
}
return
0
;
}
int32_t
streamMetaAbort
(
SStreamMeta
*
pMeta
)
{
if
(
tdbAbort
(
pMeta
->
db
,
pMeta
->
txn
)
<
0
)
{
return
-
1
;
}
if
(
tdbBegin
(
pMeta
->
db
,
&
pMeta
->
txn
,
tdbDefaultMalloc
,
tdbDefaultFree
,
NULL
,
TDB_TXN_WRITE
|
TDB_TXN_READ_UNCOMMITTED
)
<
0
)
{
return
-
1
;
}
return
0
;
}
int64_t
streamGetLatestCheckpointId
(
SStreamMeta
*
pMeta
)
{
int64_t
chkpId
=
0
;
...
...
@@ -430,6 +416,7 @@ int64_t streamGetLatestCheckpointId(SStreamMeta* pMeta) {
if
(
tdbTbcOpen
(
pMeta
->
pTaskDb
,
&
pCur
,
NULL
)
<
0
)
{
return
chkpId
;
}
void
*
pKey
=
NULL
;
int32_t
kLen
=
0
;
void
*
pVal
=
NULL
;
...
...
@@ -448,14 +435,14 @@ int64_t streamGetLatestCheckpointId(SStreamMeta* pMeta) {
chkpId
=
TMAX
(
chkpId
,
info
.
checkpointId
);
}
_err:
tdbFree
(
pKey
);
tdbFree
(
pVal
);
tdbTbcClose
(
pCur
);
return
chkpId
;
}
int32_t
streamLoadTasks
(
SStreamMeta
*
pMeta
,
int64_t
ver
)
{
int32_t
streamLoadTasks
(
SStreamMeta
*
pMeta
)
{
TBC
*
pCur
=
NULL
;
if
(
tdbTbcOpen
(
pMeta
->
pTaskDb
,
&
pCur
,
NULL
)
<
0
)
{
return
-
1
;
...
...
@@ -519,3 +506,57 @@ int32_t streamLoadTasks(SStreamMeta* pMeta, int64_t ver) {
return
0
;
}
int32_t
tEncodeStreamHbMsg
(
SEncoder
*
pEncoder
,
const
SStreamHbMsg
*
pReq
)
{
if
(
tStartEncode
(
pEncoder
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pReq
->
vgId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pReq
->
numOfTasks
)
<
0
)
return
-
1
;
tEndEncode
(
pEncoder
);
return
pEncoder
->
pos
;
}
int32_t
tDecodeStreamHbMsg
(
SDecoder
*
pDecoder
,
SStreamHbMsg
*
pRsp
)
{
if
(
tStartDecode
(
pDecoder
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pRsp
->
vgId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pRsp
->
numOfTasks
)
<
0
)
return
-
1
;
tEndDecode
(
pDecoder
);
return
0
;
}
void
metaHbToMnode
(
void
*
param
,
void
*
tmrId
)
{
SStreamMeta
*
pMeta
=
param
;
SStreamHbMsg
hbMsg
=
{
0
};
int32_t
code
=
0
;
int32_t
tlen
=
0
;
tEncodeSize
(
tEncodeStreamHbMsg
,
&
hbMsg
,
tlen
,
code
);
if
(
code
<
0
)
{
qError
(
"vgId:%d encode stream hb msg failed, code:%s"
,
pMeta
->
vgId
,
tstrerror
(
code
));
return
;
}
void
*
buf
=
rpcMallocCont
(
sizeof
(
SMsgHead
)
+
tlen
);
if
(
buf
==
NULL
)
{
qError
(
"vgId:%d encode stream hb msg failed, code:%s"
,
pMeta
->
vgId
,
tstrerror
(
TSDB_CODE_OUT_OF_MEMORY
));
return
;
}
// ((SMsgHead*)buf)->vgId = htonl(nodeId);
// void* pBuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
//
// SEncoder encoder;
// tEncoderInit(&encoder, pBuf, tlen);
// if ((code = tEncodeStreamHbMsg(&encoder, &hbMsg)) < 0) {
// rpcFreeCont(buf);
// qError("vgId:%d encode stream hb msg failed, code:%s", pMeta->vgId, tstrerror(code));
// return;
// }
// tEncoderClear(&encoder);
//
// SRpcMsg msg = {0};
// initRpcMsg(&msg, TDMT_MND_STREAM_HEARTBEAT, buf, tlen + sizeof(SMsgHead));
// qDebug("vgId:%d, send hb to mnode", nodeId);
//
// tmsgSendReq(pEpSet, &msg);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录