Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2de465b6
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
2de465b6
编写于
2月 13, 2023
作者:
H
Haojun Liao
提交者:
GitHub
2月 13, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19947 from taosdata/enh/stream_buffer_param1
Enh/stream buffer param1
上级
df496761
7a4c8f30
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
1373 addition
and
1259 deletion
+1373
-1259
include/common/tmsg.h
include/common/tmsg.h
+1
-0
include/libs/stream/streamState.h
include/libs/stream/streamState.h
+1
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+2
-0
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+2
-0
source/dnode/vnode/src/tq/tqOffset.c
source/dnode/vnode/src/tq/tqOffset.c
+2
-1
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+24
-2
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+4
-1
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+11
-5
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+1
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+20
-10
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+1240
-1237
source/libs/stream/src/streamMeta.c
source/libs/stream/src/streamMeta.c
+0
-1
source/libs/stream/src/streamState.c
source/libs/stream/src/streamState.c
+65
-2
未找到文件。
include/common/tmsg.h
浏览文件 @
2de465b6
...
...
@@ -1772,6 +1772,7 @@ typedef struct {
SArray
*
pTags
;
// array of SField
// 3.0.20
int64_t
checkpointFreq
;
// ms
int64_t
deleteMark
;
int8_t
igUpdate
;
}
SCMCreateStreamReq
;
...
...
include/libs/stream/streamState.h
浏览文件 @
2de465b6
...
...
@@ -110,6 +110,7 @@ int32_t streamStateGetParName(SStreamState* pState, int64_t groupId, void** pVal
#if 0
char* streamStateSessionDump(SStreamState* pState);
char* streamStateIntervalDump(SStreamState* pState);
#endif
#ifdef __cplusplus
...
...
source/common/src/tmsg.c
浏览文件 @
2de465b6
...
...
@@ -5425,6 +5425,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
}
if
(
tEncodeI64
(
&
encoder
,
pReq
->
deleteMark
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igUpdate
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
...
...
@@ -5487,6 +5488,7 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
}
}
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
deleteMark
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igUpdate
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
2de465b6
...
...
@@ -297,6 +297,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
pObj
->
triggerParam
=
pCreate
->
maxDelay
;
pObj
->
watermark
=
pCreate
->
watermark
;
pObj
->
fillHistory
=
pCreate
->
fillHistory
;
pObj
->
deleteMark
=
pCreate
->
deleteMark
;
pObj
->
igCheckUpdate
=
pCreate
->
igUpdate
;
memcpy
(
pObj
->
sourceDb
,
pCreate
->
sourceDB
,
TSDB_DB_FNAME_LEN
);
...
...
@@ -346,6 +347,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj,
.
triggerType
=
pObj
->
trigger
==
STREAM_TRIGGER_MAX_DELAY
?
STREAM_TRIGGER_WINDOW_CLOSE
:
pObj
->
trigger
,
.
watermark
=
pObj
->
watermark
,
.
igExpired
=
pObj
->
igExpired
,
.
deleteMark
=
pObj
->
deleteMark
,
.
igCheckUpdate
=
pObj
->
igCheckUpdate
,
};
...
...
source/dnode/vnode/src/tq/tqOffset.c
浏览文件 @
2de465b6
...
...
@@ -101,7 +101,8 @@ STqOffsetStore* tqOffsetOpen(STQ* pTq) {
}
char
*
fname
=
tqOffsetBuildFName
(
pStore
->
pTq
->
path
,
0
);
if
(
tqOffsetRestoreFromFile
(
pStore
,
fname
)
<
0
)
{
ASSERT
(
0
);
taosMemoryFree
(
fname
);
return
NULL
;
}
taosMemoryFree
(
fname
);
return
pStore
;
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
2de465b6
...
...
@@ -21,12 +21,34 @@
static
int
vnodeEncodeInfo
(
const
SVnodeInfo
*
pInfo
,
char
**
ppData
);
static
int
vnodeCommitImpl
(
SCommitInfo
*
pInfo
);
#define WAIT_TIME_MILI_SEC 50
int
vnodeBegin
(
SVnode
*
pVnode
)
{
// alloc buffer pool
int32_t
nTry
=
0
;
taosThreadMutexLock
(
&
pVnode
->
mutex
);
while
(
pVnode
->
pPool
==
NULL
)
{
taosThreadCondWait
(
&
pVnode
->
poolNotEmpty
,
&
pVnode
->
mutex
);
vInfo
(
"vgId:%d no free buffer pool on %d try, wait %d ms..."
,
TD_VID
(
pVnode
),
++
nTry
,
WAIT_TIME_MILI_SEC
);
struct
timeval
tv
;
struct
timespec
ts
;
taosGetTimeOfDay
(
&
tv
);
ts
.
tv_nsec
=
tv
.
tv_usec
*
1000
+
WAIT_TIME_MILI_SEC
*
1000000
;
if
(
ts
.
tv_nsec
>
999999999l
)
{
ts
.
tv_sec
=
tv
.
tv_sec
+
1
;
ts
.
tv_nsec
-=
1000000000l
;
}
else
{
ts
.
tv_sec
=
tv
.
tv_sec
;
}
int32_t
rc
=
taosThreadCondTimedWait
(
&
pVnode
->
poolNotEmpty
,
&
pVnode
->
mutex
,
&
ts
);
if
(
rc
&&
rc
!=
ETIMEDOUT
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
rc
);
taosThreadMutexUnlock
(
&
pVnode
->
mutex
);
return
-
1
;
}
}
pVnode
->
inUse
=
pVnode
->
pPool
;
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
2de465b6
...
...
@@ -312,10 +312,13 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
walApplyVer
(
pVnode
->
pWal
,
version
);
/*vInfo("vgId:%d, push msg begin", pVnode->config.vgId);*/
if
(
tqPushMsg
(
pVnode
->
pTq
,
pMsg
->
pCont
,
pMsg
->
contLen
,
pMsg
->
msgType
,
version
)
<
0
)
{
/*vInfo("vgId:%d, push msg end", pVnode->config.vgId);*/
vError
(
"vgId:%d, failed to push msg to TQ since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
return
-
1
;
}
/*vInfo("vgId:%d, push msg end", pVnode->config.vgId);*/
// commit if need
if
(
needCommit
)
{
...
...
@@ -1019,7 +1022,7 @@ _exit:
atomic_add_fetch_64
(
&
pVnode
->
statis
.
nBatchInsert
,
statis
.
nBatchInsert
);
atomic_add_fetch_64
(
&
pVnode
->
statis
.
nBatchInsertSuccess
,
statis
.
nBatchInsertSuccess
);
vDebug
(
"vgId:%d
, submit success, index:%"
PRId64
,
pVnode
->
config
.
vgId
,
version
);
vDebug
(
"vgId:%d
%s done, index:%"
PRId64
,
TD_VID
(
pVnode
),
__func__
,
version
);
return
0
;
}
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
2de465b6
...
...
@@ -119,8 +119,8 @@ static void doKeepNewWindowStartInfo(SWindowRowsSup* pRowSup, const int64_t* tsL
pRowSup
->
groupId
=
groupId
;
}
FORCE_INLINE
int32_t
getForwardStepsInBlock
(
int32_t
numOfRows
,
__block_search_fn_t
searchFn
,
TSKEY
ekey
,
int32_t
pos
,
int32_t
order
,
int64_t
*
pData
)
{
FORCE_INLINE
int32_t
getForwardStepsInBlock
(
int32_t
numOfRows
,
__block_search_fn_t
searchFn
,
TSKEY
ekey
,
int32_t
pos
,
int32_t
order
,
int64_t
*
pData
)
{
int32_t
forwardRows
=
0
;
if
(
order
==
TSDB_ORDER_ASC
)
{
...
...
@@ -4815,6 +4815,12 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
blockDataEnsureCapacity
(
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
);
taosHashCleanup
(
pUpdatedMap
);
#if 0
char* pBuf = streamStateIntervalDump(pInfo->pState);
qDebug("===stream===interval state%s", pBuf);
taosMemoryFree(pBuf);
#endif
doBuildDeleteResult
(
pInfo
,
pInfo
->
pDelWins
,
&
pInfo
->
delIndex
,
pInfo
->
pDelRes
);
if
(
pInfo
->
pDelRes
->
info
.
rows
>
0
)
{
printDataBlock
(
pInfo
->
pDelRes
,
"single interval delete"
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
2de465b6
...
...
@@ -544,6 +544,7 @@ stream_options(A) ::= stream_options(B) TRIGGER MAX_DELAY duration_literal(C).
stream_options(A) ::= stream_options(B) WATERMARK duration_literal(C). { ((SStreamOptions*)B)->pWatermark = releaseRawExprNode(pCxt, C); A = B; }
stream_options(A) ::= stream_options(B) IGNORE EXPIRED NK_INTEGER(C). { ((SStreamOptions*)B)->ignoreExpired = taosStr2Int8(C.z, NULL, 10); A = B; }
stream_options(A) ::= stream_options(B) FILL_HISTORY NK_INTEGER(C). { ((SStreamOptions*)B)->fillHistory = taosStr2Int8(C.z, NULL, 10); A = B; }
stream_options(A) ::= stream_options(B) DELETE_MARK duration_literal(C). { ((SStreamOptions*)B)->pDeleteMark = releaseRawExprNode(pCxt, C); A = B; }
stream_options(A) ::= stream_options(B) IGNORE UPDATE NK_INTEGER(C). { ((SStreamOptions*)B)->ignoreUpdate = taosStr2Int8(C.z, NULL, 10); A = B; }
subtable_opt(A) ::= . { A = NULL; }
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
2de465b6
...
...
@@ -666,6 +666,9 @@ static uint8_t getPrecisionFromCurrStmt(SNode* pCurrStmt, uint8_t defaultVal) {
if
(
isSetOperator
(
pCurrStmt
))
{
return
((
SSetOperator
*
)
pCurrStmt
)
->
precision
;
}
if
(
NULL
!=
pCurrStmt
&&
QUERY_NODE_CREATE_STREAM_STMT
==
nodeType
(
pCurrStmt
))
{
return
getPrecisionFromCurrStmt
(((
SCreateStreamStmt
*
)
pCurrStmt
)
->
pQuery
,
defaultVal
);
}
return
defaultVal
;
}
...
...
@@ -5512,16 +5515,6 @@ static bool crossTableWithUdaf(SSelectStmt* pSelect) {
}
static
int32_t
checkCreateStream
(
STranslateContext
*
pCxt
,
SCreateStreamStmt
*
pStmt
)
{
if
(
NULL
!=
pStmt
->
pOptions
->
pWatermark
&&
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pWatermark
)))
{
return
pCxt
->
errCode
;
}
if
(
NULL
!=
pStmt
->
pOptions
->
pDelay
&&
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pDelay
)))
{
return
pCxt
->
errCode
;
}
if
(
NULL
==
pStmt
->
pQuery
)
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -5714,6 +5707,17 @@ static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt
return
code
;
}
static
int32_t
translateStreamOptions
(
STranslateContext
*
pCxt
,
SCreateStreamStmt
*
pStmt
)
{
pCxt
->
pCurrStmt
=
(
SNode
*
)
pStmt
;
SStreamOptions
*
pOptions
=
pStmt
->
pOptions
;
if
((
NULL
!=
pOptions
->
pWatermark
&&
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pOptions
->
pWatermark
)))
||
(
NULL
!=
pOptions
->
pDeleteMark
&&
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pOptions
->
pDeleteMark
)))
||
(
NULL
!=
pOptions
->
pDelay
&&
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pOptions
->
pDelay
))))
{
return
pCxt
->
errCode
;
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
buildCreateStreamReq
(
STranslateContext
*
pCxt
,
SCreateStreamStmt
*
pStmt
,
SCMCreateStreamReq
*
pReq
)
{
pReq
->
igExists
=
pStmt
->
ignoreExists
;
...
...
@@ -5735,10 +5739,16 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt*
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateStreamOptions
(
pCxt
,
pStmt
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pReq
->
triggerType
=
pStmt
->
pOptions
->
triggerType
;
pReq
->
maxDelay
=
(
NULL
!=
pStmt
->
pOptions
->
pDelay
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pDelay
)
->
datum
.
i
:
0
);
pReq
->
watermark
=
(
NULL
!=
pStmt
->
pOptions
->
pWatermark
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pWatermark
)
->
datum
.
i
:
0
);
pReq
->
deleteMark
=
(
NULL
!=
pStmt
->
pOptions
->
pDeleteMark
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pDeleteMark
)
->
datum
.
i
:
0
);
pReq
->
fillHistory
=
pStmt
->
pOptions
->
fillHistory
;
pReq
->
igExpired
=
pStmt
->
pOptions
->
ignoreExpired
;
pReq
->
igUpdate
=
pStmt
->
pOptions
->
ignoreUpdate
;
...
...
source/libs/parser/src/sql.c
浏览文件 @
2de465b6
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
source/libs/stream/src/streamMeta.c
浏览文件 @
2de465b6
...
...
@@ -258,7 +258,6 @@ int32_t streamMetaAbort(SStreamMeta* pMeta) {
int32_t
streamLoadTasks
(
SStreamMeta
*
pMeta
)
{
TBC
*
pCur
=
NULL
;
if
(
tdbTbcOpen
(
pMeta
->
pTaskDb
,
&
pCur
,
NULL
)
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
...
...
source/libs/stream/src/streamState.c
浏览文件 @
2de465b6
...
...
@@ -107,8 +107,6 @@ static inline int stateKeyCmpr(const void* pKey1, int kLen1, const void* pKey2,
}
SStreamState
*
streamStateOpen
(
char
*
path
,
SStreamTask
*
pTask
,
bool
specPath
,
int32_t
szPage
,
int32_t
pages
)
{
szPage
=
szPage
<
0
?
4096
:
szPage
;
pages
=
pages
<
0
?
256
:
pages
;
SStreamState
*
pState
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamState
));
if
(
pState
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -128,6 +126,28 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int
memset
(
statePath
,
0
,
1024
);
tstrncpy
(
statePath
,
path
,
1024
);
}
char
cfgPath
[
1030
];
sprintf
(
cfgPath
,
"%s/cfg"
,
statePath
);
char
cfg
[
1024
];
memset
(
cfg
,
0
,
1024
);
TdFilePtr
pCfgFile
=
taosOpenFile
(
cfgPath
,
TD_FILE_READ
);
if
(
pCfgFile
!=
NULL
)
{
int64_t
size
;
taosFStatFile
(
pCfgFile
,
&
size
,
NULL
);
taosReadFile
(
pCfgFile
,
cfg
,
size
);
sscanf
(
cfg
,
"%d
\n
%d
\n
"
,
&
szPage
,
&
pages
);
}
else
{
taosMulModeMkDir
(
statePath
,
0755
);
pCfgFile
=
taosOpenFile
(
cfgPath
,
TD_FILE_WRITE
|
TD_FILE_CREATE
);
szPage
=
szPage
<
0
?
4096
:
szPage
;
pages
=
pages
<
0
?
256
:
pages
;
sprintf
(
cfg
,
"%d
\n
%d
\n
"
,
szPage
,
pages
);
taosWriteFile
(
pCfgFile
,
cfg
,
strlen
(
cfg
));
}
taosCloseFile
(
&
pCfgFile
);
if
(
tdbOpen
(
statePath
,
szPage
,
pages
,
&
pState
->
pTdbState
->
db
,
1
)
<
0
)
{
goto
_err
;
}
...
...
@@ -879,4 +899,47 @@ char* streamStateSessionDump(SStreamState* pState) {
streamStateFreeCur(pCur);
return dumpBuf;
}
char* streamStateIntervalDump(SStreamState* pState) {
SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur));
if (pCur == NULL) {
return NULL;
}
pCur->number = pState->number;
if (tdbTbcOpen(pState->pTdbState->pStateDb, &pCur->pCur, NULL) < 0) {
streamStateFreeCur(pCur);
return NULL;
}
tdbTbcMoveToFirst(pCur->pCur);
SWinKey key = {0};
void* buf = NULL;
int32_t bufSize = 0;
int32_t code = streamStateGetKVByCur(pCur, &key, (const void **)&buf, &bufSize);
if (code != 0) {
streamStateFreeCur(pCur);
return NULL;
}
int32_t size = 2048;
char* dumpBuf = taosMemoryCalloc(size, 1);
int64_t len = 0;
len += snprintf(dumpBuf + len, size - len, "||s:%15" PRId64 ",", key.ts);
// len += snprintf(dumpBuf + len, size - len, "e:%15" PRId64 ",", key.win.ekey);
len += snprintf(dumpBuf + len, size - len, "g:%15" PRId64 "||", key.groupId);
while (1) {
tdbTbcMoveToNext(pCur->pCur);
key = (SWinKey){0};
code = streamStateGetKVByCur(pCur, &key, NULL, 0);
if (code != 0) {
streamStateFreeCur(pCur);
return dumpBuf;
}
len += snprintf(dumpBuf + len, size - len, "||s:%15" PRId64 ",", key.ts);
// len += snprintf(dumpBuf + len, size - len, "e:%15" PRId64 ",", key.win.ekey);
len += snprintf(dumpBuf + len, size - len, "g:%15" PRId64 "||", key.groupId);
}
streamStateFreeCur(pCur);
return dumpBuf;
}
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录