Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
43a029e3
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看板
提交
43a029e3
编写于
3月 15, 2023
作者:
K
kailixu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: coverity scan for sma
上级
77435185
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
41 addition
and
60 deletion
+41
-60
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+1
-1
source/dnode/vnode/src/sma/smaTimeRange.c
source/dnode/vnode/src/sma/smaTimeRange.c
+31
-49
source/dnode/vnode/src/sma/smaUtil.c
source/dnode/vnode/src/sma/smaUtil.c
+9
-10
未找到文件。
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
43a029e3
...
...
@@ -1352,7 +1352,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
}
if
(
!
(
pStat
=
(
SRSmaStat
*
)
tdAcquireSmaRef
(
smaMgmt
.
rsetId
,
pRSmaRef
->
refId
)))
{
sma
Debug
(
"rsma fetch task not start since rsma stat already destroyed, rsetId:%d refId:%"
PRIi64
")"
,
sma
Warn
(
"rsma fetch task not start since rsma stat already destroyed, rsetId:%d refId:%"
PRIi64
")"
,
smaMgmt
.
rsetId
,
pRSmaRef
->
refId
);
// pRSmaRef freed in taosHashRemove
taosHashRemove
(
smaMgmt
.
refHash
,
&
param
,
POINTER_BYTES
);
return
;
...
...
source/dnode/vnode/src/sma/smaTimeRange.c
浏览文件 @
43a029e3
...
...
@@ -29,7 +29,7 @@ int32_t tdProcessTSmaInsert(SSma *pSma, int64_t indexUid, const char *msg) {
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tdProcessTSmaInsertImpl
(
pSma
,
indexUid
,
msg
))
<
0
)
{
sma
Warn
(
"vgId:%d, insert tsma data failed since %s"
,
SMA_VID
(
pSma
),
tstrerror
(
terrno
));
sma
Error
(
"vgId:%d, insert tsma data failed since %s"
,
SMA_VID
(
pSma
),
tstrerror
(
terrno
));
}
return
code
;
...
...
@@ -194,6 +194,7 @@ int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema *
}
if
(
!
(
pCreateTbReq
=
taosMemoryCalloc
(
1
,
sizeof
(
SVCreateStbReq
))))
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_end
;
};
...
...
@@ -339,7 +340,7 @@ _end:
if
(
terrno
!=
0
)
{
rpcFreeCont
(
pBuf
);
taosArrayDestroy
(
pDeleteReq
->
deleteReqs
);
return
TSDB_CODE_FAILED
;
return
terrno
;
}
if
(
ppData
)
*
ppData
=
pBuf
;
if
(
pLen
)
*
pLen
=
len
;
...
...
@@ -354,23 +355,18 @@ _end:
* @return int32_t
*/
static
int32_t
tdProcessTSmaInsertImpl
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
const
SArray
*
pDataBlocks
=
(
const
SArray
*
)
msg
;
// TODO: destroy SSDataBlocks(msg)
if
(
!
pDataBlocks
)
{
terrno
=
TSDB_CODE_TSMA_INVALID_PTR
;
smaWarn
(
"vgId:%d, insert tsma data failed since pDataBlocks is NULL"
,
SMA_VID
(
pSma
));
return
TSDB_CODE_FAILED
;
}
if
(
taosArrayGetSize
(
pDataBlocks
)
<=
0
)
{
terrno
=
TSDB_CODE_TSMA_INVALID_PARA
;
smaWarn
(
"vgId:%d, insert tsma data failed since pDataBlocks is empty"
,
SMA_VID
(
pSma
));
return
TSDB_CODE_FAILED
;
code
=
TSDB_CODE_TSMA_INVALID_PARA
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
tdCheckAndInitSmaEnv
(
pSma
,
TSDB_SMA_TYPE_TIME_RANGE
)
!=
0
)
{
terrno
=
TSDB_CODE_TSMA_INIT_FAILED
;
return
TSDB_CODE_FAILED
;
code
=
TSDB_CODE_TSMA_INIT_FAILED
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
)
;
}
SSmaEnv
*
pEnv
=
SMA_TSMA_ENV
(
pSma
);
...
...
@@ -378,57 +374,43 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char
STSmaStat
*
pTsmaStat
=
NULL
;
if
(
!
pEnv
||
!
(
pStat
=
SMA_ENV_STAT
(
pEnv
)))
{
terrno
=
TSDB_CODE_TSMA_INVALID_ENV
;
return
TSDB_CODE_FAILED
;
code
=
TSDB_CODE_TSMA_INVALID_ENV
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
)
;
}
pTsmaStat
=
SMA_STAT_TSMA
(
pStat
);
if
(
!
pTsmaStat
->
pTSma
)
{
terrno
=
0
;
STSma
*
pTSma
=
metaGetSmaInfoByIndex
(
SMA_META
(
pSma
),
indexUid
);
if
(
!
pTSma
)
{
smaError
(
"vgId:%d, failed to get STSma while tsma insert for smaIndex %"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
indexUid
,
tstrerror
(
terrno
));
goto
_err
;
code
=
terrno
?
code
:
TSDB_CODE_TSMA_INVALID_PTR
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
pTsmaStat
->
pTSma
=
pTSma
;
pTsmaStat
->
pTSchema
=
metaGetTbTSchema
(
SMA_META
(
pSma
),
pTSma
->
dstTbUid
,
-
1
,
1
);
if
(
!
pTsmaStat
->
pTSchema
)
{
smaError
(
"vgId:%d, failed to get STSchema while tsma insert for smaIndex %"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
indexUid
,
tstrerror
(
terrno
));
goto
_err
;
code
=
terrno
?
code
:
TSDB_CODE_TSMA_INVALID_PTR
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
if
(
pTsmaStat
->
pTSma
->
indexUid
!=
indexUid
)
{
terrno
=
TSDB_CODE_APP_ERROR
;
smaError
(
"vgId:%d, tsma insert for smaIndex %"
PRIi64
"(!=%"
PRIi64
") failed since %s"
,
SMA_VID
(
pSma
),
indexUid
,
pTsmaStat
->
pTSma
->
indexUid
,
tstrerror
(
terrno
));
goto
_err
;
if
(
ASSERTS
(
pTsmaStat
->
pTSma
->
indexUid
==
indexUid
,
"indexUid:%"
PRIi64
" != %"
PRIi64
,
pTsmaStat
->
pTSma
->
indexUid
,
indexUid
))
{
code
=
TSDB_CODE_APP_ERROR
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
SBatchDeleteReq
deleteReq
=
{
0
};
void
*
pSubmitReq
=
NULL
;
int32_t
contLen
=
0
;
if
(
smaBlockToSubmit
(
pSma
->
pVnode
,
(
const
SArray
*
)
msg
,
pTsmaStat
->
pTSchema
,
&
pTsmaStat
->
pTSma
->
schemaTag
,
true
,
pTsmaStat
->
pTSma
->
dstTbUid
,
pTsmaStat
->
pTSma
->
dstTbName
,
&
deleteReq
,
&
pSubmitReq
,
&
contLen
)
<
0
)
{
smaError
(
"vgId:%d, failed to gen submit msg while tsma insert for smaIndex %"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
indexUid
,
tstrerror
(
terrno
));
goto
_err
;
}
code
=
smaBlockToSubmit
(
pSma
->
pVnode
,
(
const
SArray
*
)
msg
,
pTsmaStat
->
pTSchema
,
&
pTsmaStat
->
pTSma
->
schemaTag
,
true
,
pTsmaStat
->
pTSma
->
dstTbUid
,
pTsmaStat
->
pTSma
->
dstTbName
,
&
deleteReq
,
&
pSubmitReq
,
&
contLen
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// TODO deleteReq
taosArrayDestroy
(
deleteReq
.
deleteReqs
);
#if 0
if (!strncasecmp("td.tsma.rst.tb", pTsmaStat->pTSma->dstTbName, 14)) {
terrno = TSDB_CODE_APP_ERROR;
smaError("vgId:%d, tsma insert for smaIndex %" PRIi64 " failed since %s, %s", SMA_VID(pSma), indexUid,
pTsmaStat->pTSma->indexUid, tstrerror(terrno), pTsmaStat->pTSma->dstTbName);
goto _err;
}
#endif
SRpcMsg
submitReqMsg
=
{
.
msgType
=
TDMT_VND_SUBMIT
,
...
...
@@ -436,13 +418,13 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char
.
contLen
=
contLen
,
};
if
(
tmsgPutToQueue
(
&
pSma
->
pVnode
->
msgCb
,
WRITE_QUEUE
,
&
submitReqMsg
)
<
0
)
{
smaError
(
"vgId:%d, failed to put SubmitReq msg while tsma insert for smaIndex %"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
indexUid
,
tstrerror
(
terrno
));
goto
_err
;
}
code
=
tmsgPutToQueue
(
&
pSma
->
pVnode
->
msgCb
,
WRITE_QUEUE
,
&
submitReqMsg
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
return
TSDB_CODE_SUCCESS
;
_err:
return
TSDB_CODE_FAILED
;
_exit:
if
(
code
)
{
smaError
(
"vgId:%d, %s failed at line %d since %s, smaIndex:%PRIi64"
,
SMA_VID
(
pSma
),
__func__
,
lino
,
tstrerror
(
code
),
indexUid
);
}
return
code
;
}
source/dnode/vnode/src/sma/smaUtil.c
浏览文件 @
43a029e3
...
...
@@ -17,20 +17,24 @@
#define TD_QTASKINFO_FNAME_PREFIX "main.tdb"
#if 0
void tdRSmaQTaskInfoGetFileName(int32_t vgId, int64_t suid, int8_t level, int64_t version, char *outputName) {
tdRSmaGetFileName(vgId, NULL, VNODE_RSMA_DIR, TD_QTASKINFO_FNAME_PREFIX, suid, level, version, outputName);
}
#endif
void
tdRSmaQTaskInfoGetFullName
(
int32_t
vgId
,
int64_t
suid
,
int8_t
level
,
int64_t
version
,
const
char
*
path
,
char
*
outputName
)
{
tdRSmaGetFileName
(
vgId
,
path
,
VNODE_RSMA_DIR
,
TD_QTASKINFO_FNAME_PREFIX
,
suid
,
level
,
version
,
outputName
);
}
#if 0
void tdRSmaQTaskInfoGetFullPath(int32_t vgId, int8_t level, const char *path, char *outputName) {
tdRSmaGetDirName(vgId, path, VNODE_RSMA_DIR, true, outputName);
int32_t rsmaLen = strlen(outputName);
snprintf(outputName + rsmaLen, TSDB_FILENAME_LEN - rsmaLen, "%" PRIi8, level);
}
#endif
void
tdRSmaQTaskInfoGetFullPathEx
(
int32_t
vgId
,
tb_uid_t
suid
,
int8_t
level
,
const
char
*
path
,
char
*
outputName
)
{
tdRSmaGetDirName
(
vgId
,
path
,
VNODE_RSMA_DIR
,
true
,
outputName
);
...
...
@@ -60,6 +64,7 @@ void tdRSmaGetFileName(int32_t vgId, const char *pdname, const char *dname, cons
}
}
}
else
{
#if 0
if (version >= 0) {
if (pdname) {
snprintf(outputName, TSDB_FILENAME_LEN, "%s%svnode%svnode%d%s%s%sv%d%s%" PRIi64, pdname, TD_DIRSEP, TD_DIRSEP,
...
...
@@ -77,6 +82,7 @@ void tdRSmaGetFileName(int32_t vgId, const char *pdname, const char *dname, cons
TD_DIRSEP, vgId, fname);
}
}
#endif
}
}
...
...
@@ -90,31 +96,24 @@ void tdRSmaGetDirName(int32_t vgId, const char *pdname, const char *dname, bool
dname
);
}
}
else
{
#if 0
if (endWithSep) {
snprintf(outputName, TSDB_FILENAME_LEN, "vnode%svnode%d%s%s%s", TD_DIRSEP, vgId, TD_DIRSEP, dname, TD_DIRSEP);
} else {
snprintf(outputName, TSDB_FILENAME_LEN, "vnode%svnode%d%s%s", TD_DIRSEP, vgId, TD_DIRSEP, dname);
}
#endif
}
}
// smaXXXUtil ================
void
*
tdAcquireSmaRef
(
int32_t
rsetId
,
int64_t
refId
)
{
void
*
pResult
=
taosAcquireRef
(
rsetId
,
refId
);
if
(
!
pResult
)
{
smaWarn
(
"rsma acquire ref for rsetId:%d refId:%"
PRIi64
" failed since %s"
,
rsetId
,
refId
,
terrstr
());
}
else
{
smaTrace
(
"rsma acquire ref for rsetId:%d refId:%"
PRIi64
" success"
,
rsetId
,
refId
);
}
return
pResult
;
}
void
*
tdAcquireSmaRef
(
int32_t
rsetId
,
int64_t
refId
)
{
return
taosAcquireRef
(
rsetId
,
refId
);
}
int32_t
tdReleaseSmaRef
(
int32_t
rsetId
,
int64_t
refId
)
{
if
(
taosReleaseRef
(
rsetId
,
refId
)
<
0
)
{
smaWarn
(
"rsma release ref for rsetId:%d refId:%"
PRIi64
" failed since %s"
,
rsetId
,
refId
,
terrstr
());
return
TSDB_CODE_FAILED
;
}
smaTrace
(
"rsma release ref for rsetId:%d refId:%"
PRIi64
" success"
,
rsetId
,
refId
);
return
TSDB_CODE_SUCCESS
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录