Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cf6f7516
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
未验证
提交
cf6f7516
编写于
6月 27, 2022
作者:
C
Cary Xu
提交者:
GitHub
6月 27, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14278 from taosdata/feature/TD-11274-3.0
refactor: rsma restore
上级
fb50977b
8281176b
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
135 addition
and
93 deletion
+135
-93
include/common/tdataformat.h
include/common/tdataformat.h
+0
-1
include/common/tmsg.h
include/common/tmsg.h
+1
-1
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+0
-16
source/common/src/tmsg.c
source/common/src/tmsg.c
+2
-2
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+10
-10
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+5
-0
source/dnode/vnode/src/meta/metaEntry.c
source/dnode/vnode/src/meta/metaEntry.c
+12
-6
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+2
-0
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+4
-0
source/dnode/vnode/src/sma/smaEnv.c
source/dnode/vnode/src/sma/smaEnv.c
+8
-11
source/dnode/vnode/src/sma/smaOpen.c
source/dnode/vnode/src/sma/smaOpen.c
+46
-8
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+22
-31
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+3
-0
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+1
-1
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-1
source/libs/executor/src/executorMain.c
source/libs/executor/src/executorMain.c
+7
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+11
-4
未找到文件。
include/common/tdataformat.h
浏览文件 @
cf6f7516
...
...
@@ -78,7 +78,6 @@ int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag);
int32_t
tDecodeTag
(
SDecoder
*
pDecoder
,
STag
**
ppTag
);
int32_t
tTagToValArray
(
const
STag
*
pTag
,
SArray
**
ppArray
);
void
debugPrintSTag
(
STag
*
pTag
,
const
char
*
tag
,
int32_t
ln
);
// TODO: remove
void
debugCheckTags
(
STag
*
pTag
);
// TODO: remove
// STRUCT =================
struct
STColumn
{
...
...
include/common/tmsg.h
浏览文件 @
cf6f7516
...
...
@@ -1886,7 +1886,7 @@ typedef struct SVCreateStbReq {
int8_t
rollup
;
SSchemaWrapper
schemaRow
;
SSchemaWrapper
schemaTag
;
SRSmaParam
pRS
maParam
;
SRSmaParam
rs
maParam
;
}
SVCreateStbReq
;
int
tEncodeSVCreateStbReq
(
SEncoder
*
pCoder
,
const
SVCreateStbReq
*
pReq
);
...
...
source/common/src/tdataformat.c
浏览文件 @
cf6f7516
...
...
@@ -862,21 +862,6 @@ void debugPrintSTag(STag *pTag, const char *tag, int32_t ln) {
printf
(
"
\n
"
);
}
void
debugCheckTags
(
STag
*
pTag
)
{
switch
(
pTag
->
flags
)
{
case
0x0
:
case
0x20
:
case
0x40
:
case
0x60
:
break
;
default:
ASSERT
(
0
);
}
ASSERT
(
pTag
->
nTag
<=
128
&&
pTag
->
nTag
>=
0
);
ASSERT
(
pTag
->
ver
<=
512
&&
pTag
->
ver
>=
0
);
// temp condition for pTag->ver
}
static
int32_t
tPutTagVal
(
uint8_t
*
p
,
STagVal
*
pTagVal
,
int8_t
isJson
)
{
int32_t
n
=
0
;
...
...
@@ -999,7 +984,6 @@ int32_t tTagNew(SArray *pArray, int32_t version, int8_t isJson, STag **ppTag) {
debugPrintSTag
(
*
ppTag
,
__func__
,
__LINE__
);
#endif
debugCheckTags
(
*
ppTag
);
// TODO: remove this line after debug
return
code
;
_err:
...
...
source/common/src/tmsg.c
浏览文件 @
cf6f7516
...
...
@@ -4763,7 +4763,7 @@ int tEncodeSVCreateStbReq(SEncoder *pCoder, const SVCreateStbReq *pReq) {
if
(
tEncodeSSchemaWrapper
(
pCoder
,
&
pReq
->
schemaRow
)
<
0
)
return
-
1
;
if
(
tEncodeSSchemaWrapper
(
pCoder
,
&
pReq
->
schemaTag
)
<
0
)
return
-
1
;
if
(
pReq
->
rollup
)
{
if
(
tEncodeSRSmaParam
(
pCoder
,
&
pReq
->
pRS
maParam
)
<
0
)
return
-
1
;
if
(
tEncodeSRSmaParam
(
pCoder
,
&
pReq
->
rs
maParam
)
<
0
)
return
-
1
;
}
tEndEncode
(
pCoder
);
...
...
@@ -4779,7 +4779,7 @@ int tDecodeSVCreateStbReq(SDecoder *pCoder, SVCreateStbReq *pReq) {
if
(
tDecodeSSchemaWrapper
(
pCoder
,
&
pReq
->
schemaRow
)
<
0
)
return
-
1
;
if
(
tDecodeSSchemaWrapper
(
pCoder
,
&
pReq
->
schemaTag
)
<
0
)
return
-
1
;
if
(
pReq
->
rollup
)
{
if
(
tDecodeSRSmaParam
(
pCoder
,
&
pReq
->
pRS
maParam
)
<
0
)
return
-
1
;
if
(
tDecodeSRSmaParam
(
pCoder
,
&
pReq
->
rs
maParam
)
<
0
)
return
-
1
;
}
tEndDecode
(
pCoder
);
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
cf6f7516
...
...
@@ -427,17 +427,17 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
req
.
schemaTag
.
pSchema
=
pStb
->
pTags
;
if
(
req
.
rollup
)
{
req
.
pRS
maParam
.
maxdelay
[
0
]
=
pStb
->
maxdelay
[
0
];
req
.
pRS
maParam
.
maxdelay
[
1
]
=
pStb
->
maxdelay
[
1
];
req
.
rs
maParam
.
maxdelay
[
0
]
=
pStb
->
maxdelay
[
0
];
req
.
rs
maParam
.
maxdelay
[
1
]
=
pStb
->
maxdelay
[
1
];
if
(
pStb
->
ast1Len
>
0
)
{
if
(
mndConvertRsmaTask
(
&
req
.
pRSmaParam
.
qmsg
[
0
],
&
req
.
pRS
maParam
.
qmsgLen
[
0
],
pStb
->
pAst1
,
pStb
->
uid
,
STREAM_TRIGGER_WINDOW_CLOSE
,
req
.
pRS
maParam
.
watermark
[
0
])
<
0
)
{
if
(
mndConvertRsmaTask
(
&
req
.
rsmaParam
.
qmsg
[
0
],
&
req
.
rs
maParam
.
qmsgLen
[
0
],
pStb
->
pAst1
,
pStb
->
uid
,
STREAM_TRIGGER_WINDOW_CLOSE
,
req
.
rs
maParam
.
watermark
[
0
])
<
0
)
{
goto
_err
;
}
}
if
(
pStb
->
ast2Len
>
0
)
{
if
(
mndConvertRsmaTask
(
&
req
.
pRSmaParam
.
qmsg
[
1
],
&
req
.
pRS
maParam
.
qmsgLen
[
1
],
pStb
->
pAst2
,
pStb
->
uid
,
STREAM_TRIGGER_WINDOW_CLOSE
,
req
.
pRS
maParam
.
watermark
[
1
])
<
0
)
{
if
(
mndConvertRsmaTask
(
&
req
.
rsmaParam
.
qmsg
[
1
],
&
req
.
rs
maParam
.
qmsgLen
[
1
],
pStb
->
pAst2
,
pStb
->
uid
,
STREAM_TRIGGER_WINDOW_CLOSE
,
req
.
rs
maParam
.
watermark
[
1
])
<
0
)
{
goto
_err
;
}
}
...
...
@@ -470,12 +470,12 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
tEncoderClear
(
&
encoder
);
*
pContLen
=
contLen
;
taosMemoryFreeClear
(
req
.
pRS
maParam
.
qmsg
[
0
]);
taosMemoryFreeClear
(
req
.
pRS
maParam
.
qmsg
[
1
]);
taosMemoryFreeClear
(
req
.
rs
maParam
.
qmsg
[
0
]);
taosMemoryFreeClear
(
req
.
rs
maParam
.
qmsg
[
1
]);
return
pHead
;
_err:
taosMemoryFreeClear
(
req
.
pRS
maParam
.
qmsg
[
0
]);
taosMemoryFreeClear
(
req
.
pRS
maParam
.
qmsg
[
1
]);
taosMemoryFreeClear
(
req
.
rs
maParam
.
qmsg
[
0
]);
taosMemoryFreeClear
(
req
.
rs
maParam
.
qmsg
[
1
]);
return
NULL
;
}
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
cf6f7516
...
...
@@ -199,15 +199,20 @@ typedef struct {
uint64_t
groupId
;
}
STableKeyInfo
;
#define TABLE_ROLLUP_ON ((int8_t)0x1)
#define TABLE_IS_ROLLUP(FLG) (((FLG) & (TABLE_ROLLUP_ON)) != 0)
#define TABLE_SET_ROLLUP(FLG) ((FLG) |= TABLE_ROLLUP_ON)
struct
SMetaEntry
{
int64_t
version
;
int8_t
type
;
int8_t
flags
;
// TODO: need refactor?
tb_uid_t
uid
;
char
*
name
;
union
{
struct
{
SSchemaWrapper
schemaRow
;
SSchemaWrapper
schemaTag
;
SRSmaParam
rsmaParam
;
}
stbEntry
;
struct
{
int64_t
ctime
;
...
...
source/dnode/vnode/src/meta/metaEntry.c
浏览文件 @
cf6f7516
...
...
@@ -24,22 +24,25 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
if
(
tEncodeCStr
(
pCoder
,
pME
->
name
)
<
0
)
return
-
1
;
if
(
pME
->
type
==
TSDB_SUPER_TABLE
)
{
if
(
tEncodeI8
(
pCoder
,
pME
->
flags
)
<
0
)
return
-
1
;
// TODO: need refactor?
if
(
tEncodeSSchemaWrapper
(
pCoder
,
&
pME
->
stbEntry
.
schemaRow
)
<
0
)
return
-
1
;
if
(
tEncodeSSchemaWrapper
(
pCoder
,
&
pME
->
stbEntry
.
schemaTag
)
<
0
)
return
-
1
;
if
(
TABLE_IS_ROLLUP
(
pME
->
flags
))
{
if
(
tEncodeSRSmaParam
(
pCoder
,
&
pME
->
stbEntry
.
rsmaParam
)
<
0
)
return
-
1
;
}
}
else
if
(
pME
->
type
==
TSDB_CHILD_TABLE
)
{
if
(
tEncodeI64
(
pCoder
,
pME
->
ctbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pME
->
ctbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pME
->
ctbEntry
.
commentLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
v
(
pCoder
,
pME
->
ctbEntry
.
commentLen
)
<
0
)
return
-
1
;
if
(
pME
->
ctbEntry
.
commentLen
>
0
){
if
(
tEncodeCStr
(
pCoder
,
pME
->
ctbEntry
.
comment
)
<
0
)
return
-
1
;
}
if
(
tEncodeI64
(
pCoder
,
pME
->
ctbEntry
.
suid
)
<
0
)
return
-
1
;
debugCheckTags
((
STag
*
)
pME
->
ctbEntry
.
pTags
);
// TODO: remove after debug
if
(
tEncodeTag
(
pCoder
,
(
const
STag
*
)
pME
->
ctbEntry
.
pTags
)
<
0
)
return
-
1
;
}
else
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
if
(
tEncodeI64
(
pCoder
,
pME
->
ntbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pME
->
ntbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pCoder
,
pME
->
ntbEntry
.
commentLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
v
(
pCoder
,
pME
->
ntbEntry
.
commentLen
)
<
0
)
return
-
1
;
if
(
pME
->
ntbEntry
.
commentLen
>
0
){
if
(
tEncodeCStr
(
pCoder
,
pME
->
ntbEntry
.
comment
)
<
0
)
return
-
1
;
}
...
...
@@ -64,23 +67,26 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) {
if
(
tDecodeCStr
(
pCoder
,
&
pME
->
name
)
<
0
)
return
-
1
;
if
(
pME
->
type
==
TSDB_SUPER_TABLE
)
{
if
(
tDecodeI8
(
pCoder
,
&
pME
->
flags
)
<
0
)
return
-
1
;
// TODO: need refactor?
if
(
tDecodeSSchemaWrapperEx
(
pCoder
,
&
pME
->
stbEntry
.
schemaRow
)
<
0
)
return
-
1
;
if
(
tDecodeSSchemaWrapperEx
(
pCoder
,
&
pME
->
stbEntry
.
schemaTag
)
<
0
)
return
-
1
;
if
(
TABLE_IS_ROLLUP
(
pME
->
flags
))
{
if
(
tDecodeSRSmaParam
(
pCoder
,
&
pME
->
stbEntry
.
rsmaParam
)
<
0
)
return
-
1
;
}
}
else
if
(
pME
->
type
==
TSDB_CHILD_TABLE
)
{
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ctbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ctbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ctbEntry
.
commentLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
v
(
pCoder
,
&
pME
->
ctbEntry
.
commentLen
)
<
0
)
return
-
1
;
if
(
pME
->
ctbEntry
.
commentLen
>
0
){
if
(
tDecodeCStr
(
pCoder
,
&
pME
->
ctbEntry
.
comment
)
<
0
)
return
-
1
;
}
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ctbEntry
.
suid
)
<
0
)
return
-
1
;
if
(
tDecodeTag
(
pCoder
,
(
STag
**
)
&
pME
->
ctbEntry
.
pTags
)
<
0
)
return
-
1
;
// (TODO)
debugCheckTags
((
STag
*
)
pME
->
ctbEntry
.
pTags
);
// TODO: remove after debug
}
else
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
if
(
tDecodeI64
(
pCoder
,
&
pME
->
ntbEntry
.
ctime
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ntbEntry
.
ttlDays
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pCoder
,
&
pME
->
ntbEntry
.
commentLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
v
(
pCoder
,
&
pME
->
ntbEntry
.
commentLen
)
<
0
)
return
-
1
;
if
(
pME
->
ntbEntry
.
commentLen
>
0
){
if
(
tDecodeCStr
(
pCoder
,
&
pME
->
ntbEntry
.
comment
)
<
0
)
return
-
1
;
}
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
cf6f7516
...
...
@@ -342,6 +342,7 @@ SMStbCursor *metaOpenStbCursor(SMeta *pMeta, tb_uid_t suid) {
pStbCur
=
(
SMStbCursor
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pStbCur
));
if
(
pStbCur
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
...
...
@@ -351,6 +352,7 @@ SMStbCursor *metaOpenStbCursor(SMeta *pMeta, tb_uid_t suid) {
ret
=
tdbTbcOpen
(
pMeta
->
pSuidIdx
,
&
pStbCur
->
pCur
,
NULL
);
if
(
ret
<
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
metaULock
(
pMeta
);
taosMemoryFree
(
pStbCur
);
return
NULL
;
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
cf6f7516
...
...
@@ -139,6 +139,10 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
me
.
name
=
pReq
->
name
;
me
.
stbEntry
.
schemaRow
=
pReq
->
schemaRow
;
me
.
stbEntry
.
schemaTag
=
pReq
->
schemaTag
;
if
(
pReq
->
rollup
)
{
TABLE_SET_ROLLUP
(
me
.
flags
);
me
.
stbEntry
.
rsmaParam
=
pReq
->
rsmaParam
;
}
if
(
metaHandleEntry
(
pMeta
,
&
me
)
<
0
)
goto
_err
;
...
...
source/dnode/vnode/src/sma/smaEnv.c
浏览文件 @
cf6f7516
...
...
@@ -156,6 +156,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS
static
void
tdDestroyTSmaStat
(
STSmaStat
*
pStat
)
{
if
(
pStat
)
{
smaDebug
(
"destroy tsma stat"
);
tDestroyTSma
(
pStat
->
pTSma
);
taosMemoryFreeClear
(
pStat
->
pTSma
);
taosMemoryFreeClear
(
pStat
->
pTSchema
);
...
...
@@ -170,15 +171,12 @@ static void *tdFreeTSmaStat(STSmaStat *pStat) {
static
void
tdDestroyRSmaStat
(
SRSmaStat
*
pStat
)
{
if
(
pStat
)
{
smaDebug
(
"vgId:%d
, %s:%d free rsma stat"
,
SMA_VID
(
pStat
->
pSma
),
__func__
,
__LINE__
);
smaDebug
(
"vgId:%d
destroy rsma stat"
,
SMA_VID
(
pStat
->
pSma
)
);
// step 1: set persistence task cancelled
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pStat
),
TASK_TRIGGER_STAT_CANCELLED
);
// step 2:
clean
timer
// step 2:
stop the persistence
timer
taosTmrStopA
(
&
RSMA_TMR_ID
(
pStat
));
if
(
RSMA_TMR_HANDLE
(
pStat
))
{
taosTmrCleanUp
(
RSMA_TMR_HANDLE
(
pStat
));
}
// step 3: wait the persistence thread to finish
int32_t
nLoops
=
0
;
...
...
@@ -194,7 +192,6 @@ static void tdDestroyRSmaStat(SRSmaStat *pStat) {
sched_yield
();
nLoops
=
0
;
}
taosMsleep
(
1000
);
// TODO: remove this line when release
}
}
...
...
@@ -219,7 +216,11 @@ static void tdDestroyRSmaStat(SRSmaStat *pStat) {
sched_yield
();
nLoops
=
0
;
}
taosMsleep
(
1000
);
// TODO: remove this line when release
}
// step 6: cleanup the timer handle
if
(
RSMA_TMR_HANDLE
(
pStat
))
{
taosTmrCleanUp
(
RSMA_TMR_HANDLE
(
pStat
));
}
}
}
...
...
@@ -245,16 +246,12 @@ void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) {
int32_t
tdDestroySmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
)
{
if
(
pSmaStat
)
{
if
(
smaType
==
TSDB_SMA_TYPE_TIME_RANGE
)
{
smaDebug
(
"%s:%d destroy tsma stat"
,
__func__
,
__LINE__
);
tdDestroyTSmaStat
(
SMA_TSMA_STAT
(
pSmaStat
));
}
else
if
(
smaType
==
TSDB_SMA_TYPE_ROLLUP
)
{
smaDebug
(
"%s:%d destroy rsma stat"
,
__func__
,
__LINE__
);
tdDestroyRSmaStat
(
SMA_RSMA_STAT
(
pSmaStat
));
}
else
{
ASSERT
(
0
);
}
}
else
{
smaDebug
(
"%s:%d no need to destroy rsma stat"
,
__func__
,
__LINE__
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
source/dnode/vnode/src/sma/smaOpen.c
浏览文件 @
cf6f7516
...
...
@@ -18,6 +18,7 @@
static
int32_t
smaEvalDays
(
SRetention
*
r
,
int8_t
precision
);
static
int32_t
smaSetKeepCfg
(
STsdbKeepCfg
*
pKeepCfg
,
STsdbCfg
*
pCfg
,
int
type
);
static
int32_t
rsmaRestore
(
SSma
*
pSma
);
#define SMA_SET_KEEP_CFG(l) \
do { \
...
...
@@ -100,6 +101,9 @@ int32_t smaOpen(SVnode *pVnode) {
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pVnode
->
pSma
=
pSma
;
pSma
->
pVnode
=
pVnode
;
taosThreadMutexInit
(
&
pSma
->
mutex
,
NULL
);
pSma
->
locked
=
false
;
...
...
@@ -117,9 +121,13 @@ int32_t smaOpen(SVnode *pVnode) {
ASSERT
(
0
);
}
}
// restore the rsma
if
(
rsmaRestore
(
pSma
)
<
0
)
{
goto
_err
;
}
}
pVnode
->
pSma
=
pSma
;
return
0
;
_err:
taosMemoryFreeClear
(
pSma
);
...
...
@@ -127,7 +135,7 @@ _err:
}
int32_t
smaCloseEnv
(
SSma
*
pSma
)
{
if
(
pSma
)
{
if
(
pSma
)
{
SMA_TSMA_ENV
(
pSma
)
=
tdFreeSmaEnv
(
SMA_TSMA_ENV
(
pSma
));
SMA_RSMA_ENV
(
pSma
)
=
tdFreeSmaEnv
(
SMA_RSMA_ENV
(
pSma
));
}
...
...
@@ -153,13 +161,43 @@ int32_t smaClose(SSma *pSma) {
/**
* @brief rsma env restore
*
* @param pSma
* @return int32_t
*
* @param pSma
* @return int32_t
*/
int32_t
smaRestore
(
SSma
*
pSma
)
{
if
(
!
pSma
)
return
0
;
static
int32_t
rsmaRestore
(
SSma
*
pSma
)
{
ASSERT
(
VND_IS_RSMA
(
pSma
->
pVnode
));
// iterate all stables to restore the rsma env
SArray
*
suidList
=
taosArrayInit
(
1
,
sizeof
(
tb_uid_t
));
if
(
tsdbGetStbIdList
(
SMA_META
(
pSma
),
0
,
suidList
)
<
0
)
{
smaError
(
"failed to restore rsma since get stb id list error: %s"
,
terrstr
());
return
TSDB_CODE_FAILED
;
}
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
SMA_META
(
pSma
),
0
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
suidList
);
++
i
)
{
tb_uid_t
suid
=
*
(
tb_uid_t
*
)
taosArrayGet
(
suidList
,
i
);
smaDebug
(
"suid [%d] is %"
PRIi64
,
i
,
suid
);
if
(
metaGetTableEntryByUid
(
&
mr
,
suid
)
<
0
)
{
metaReaderClear
(
&
mr
);
taosArrayDestroy
(
suidList
);
smaError
(
"failed to get table meta for %"
PRIi64
" since %s"
,
suid
,
terrstr
());
return
TSDB_CODE_FAILED
;
}
ASSERT
(
mr
.
me
.
type
==
TSDB_SUPER_TABLE
);
if
(
TABLE_IS_ROLLUP
(
mr
.
me
.
flags
))
{
SRSmaParam
*
param
=
&
mr
.
me
.
stbEntry
.
rsmaParam
;
for
(
int
i
=
0
;
i
<
2
;
++
i
)
{
smaDebug
(
"vgId: %d table:%"
PRIi64
" maxdelay[%d]:%"
PRIi64
" watermark[%d]:%"
PRIi64
,
TD_VID
(
pSma
->
pVnode
),
suid
,
i
,
param
->
maxdelay
[
i
],
i
,
param
->
watermark
[
i
]);
}
}
}
metaReaderClear
(
&
mr
);
taosArrayDestroy
(
suidList
);
return
TSDB_CODE_SUCCESS
;
}
\ No newline at end of file
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
cf6f7516
...
...
@@ -49,10 +49,10 @@ static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle, int32_t vgId,
// Note: free/kill may in RC
qTaskInfo_t
otaskHandle
=
atomic_load_ptr
(
taskHandle
);
if
(
otaskHandle
&&
atomic_val_compare_exchange_ptr
(
taskHandle
,
otaskHandle
,
NULL
))
{
smaDebug
(
"vgId:%d,
%s:%d free qTaskInfo_t %p of level %d"
,
vgId
,
__func__
,
__LINE__
,
otaskHandle
,
level
);
smaDebug
(
"vgId:%d,
free qTaskInfo_t %p of level %d"
,
vgId
,
otaskHandle
,
level
);
qDestroyTask
(
otaskHandle
);
}
else
{
smaDebug
(
"vgId:%d,
%s:%d not free qTaskInfo_t %p of level %d"
,
vgId
,
__func__
,
__LINE__
,
otaskHandle
,
level
);
smaDebug
(
"vgId:%d,
not free qTaskInfo_t %p of level %d"
,
vgId
,
otaskHandle
,
level
);
}
}
...
...
@@ -89,7 +89,7 @@ static FORCE_INLINE int32_t tdUidStoreInit(STbUidStore **pStore) {
return
TSDB_CODE_SUCCESS
;
}
static
FORCE_INLINE
int32_t
tdUpdateTbUidListImpl
(
SSma
*
pSma
,
tb_uid_t
*
suid
,
SArray
*
tbUids
)
{
static
int32_t
tdUpdateTbUidListImpl
(
SSma
*
pSma
,
tb_uid_t
*
suid
,
SArray
*
tbUids
)
{
SSmaEnv
*
pEnv
=
SMA_RSMA_ENV
(
pSma
);
SRSmaStat
*
pStat
=
(
SRSmaStat
*
)
SMA_ENV_STAT
(
pEnv
);
SRSmaInfo
*
pRSmaInfo
=
NULL
;
...
...
@@ -246,7 +246,7 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) {
SMeta
*
pMeta
=
pVnode
->
pMeta
;
SMsgCb
*
pMsgCb
=
&
pVnode
->
msgCb
;
SRSmaParam
*
param
=
&
pReq
->
pRS
maParam
;
SRSmaParam
*
param
=
&
pReq
->
rs
maParam
;
if
((
param
->
qmsgLen
[
0
]
==
0
)
&&
(
param
->
qmsgLen
[
1
]
==
0
))
{
smaWarn
(
"vgId:%d, no qmsg1/qmsg2 for rollup stable %s %"
PRIi64
,
SMA_VID
(
pSma
),
pReq
->
name
,
pReq
->
suid
);
...
...
@@ -502,8 +502,10 @@ static int32_t tdFetchAndSubmitRSmaResult(SRSmaInfoItem *pItem, int8_t blkType)
}
taosMemoryFreeClear
(
pReq
);
}
else
if
(
terrno
==
0
)
{
smaDebug
(
"vgId:%d, no rsma %"
PRIi8
" data fetched yet"
,
SMA_VID
(
pSma
),
pItem
->
level
);
}
else
{
smaDebug
(
"vgId:%d, no rsma %"
PRIi8
" data
generat
ed since %s"
,
SMA_VID
(
pSma
),
pItem
->
level
,
tstrerror
(
terrno
));
smaDebug
(
"vgId:%d, no rsma %"
PRIi8
" data
fetch
ed since %s"
,
SMA_VID
(
pSma
),
pItem
->
level
,
tstrerror
(
terrno
));
}
tdDestroySDataBlockArray
(
pResult
);
...
...
@@ -526,16 +528,16 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
int8_t
rsmaTriggerStat
=
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pStat
));
if
(
rsmaTriggerStat
==
TASK_TRIGGER_STAT_CANCELLED
||
rsmaTriggerStat
==
TASK_TRIGGER_STAT_FINISHED
)
{
smaDebug
(
"vgId:%d,
%s:%d
level %"
PRIi8
" not fetch since stat is cancelled for table suid:%"
PRIi64
,
SMA_VID
(
pSma
),
__func__
,
__LINE__
,
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
smaDebug
(
"vgId:%d, level %"
PRIi8
" not fetch since stat is cancelled for table suid:%"
PRIi64
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
return
;
}
int8_t
fetchTriggerStat
=
atomic_val_compare_exchange_8
(
&
pItem
->
triggerStat
,
TASK_TRIGGER_STAT_ACTIVE
,
TASK_TRIGGER_STAT_INACTIVE
);
if
(
fetchTriggerStat
==
TASK_TRIGGER_STAT_ACTIVE
)
{
smaDebug
(
"vgId:%d,
%s:%d level %"
PRIi8
" stat is active for table suid:%"
PRIi64
,
SMA_VID
(
pSma
),
__func__
,
__LINE__
,
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
smaDebug
(
"vgId:%d,
level %"
PRIi8
" stat is active for table suid:%"
PRIi64
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
tdRefSmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
...
...
@@ -546,13 +548,13 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
tdUnRefSmaStat
(
pSma
,
(
SSmaStat
*
)
pStat
);
}
else
{
smaDebug
(
"vgId:%d,
%s:%d level %"
PRIi8
" stat is inactive for table suid:%"
PRIi64
,
SMA_VID
(
pSma
),
__func__
,
__LINE__
,
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
smaDebug
(
"vgId:%d,
level %"
PRIi8
" stat is inactive for table suid:%"
PRIi64
,
SMA_VID
(
pSma
),
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
}
}
static
FORCE_INLINE
int32_t
tdExecuteRSmaImpl
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
inputType
,
SRSmaInfoItem
*
pItem
,
tb_uid_t
suid
,
int8_t
level
)
{
static
int32_t
tdExecuteRSmaImpl
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
inputType
,
SRSmaInfoItem
*
pItem
,
tb_uid_t
suid
,
int8_t
level
)
{
if
(
!
pItem
||
!
pItem
->
taskInfo
)
{
smaDebug
(
"vgId:%d, no qTaskInfo to execute rsma %"
PRIi8
" task for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
level
,
suid
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -568,7 +570,7 @@ static FORCE_INLINE int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int3
tdFetchAndSubmitRSmaResult
(
pItem
,
STREAM_DATA_TYPE_SUBMIT_BLOCK
);
atomic_store_8
(
&
pItem
->
triggerStat
,
TASK_TRIGGER_STAT_ACTIVE
);
smaDebug
(
"vgId:%d,
%s:%d process rsma insert"
,
SMA_VID
(
pSma
),
__func__
,
__LINE__
);
smaDebug
(
"vgId:%d,
process rsma insert"
,
SMA_VID
(
pSma
)
);
SSmaEnv
*
pEnv
=
SMA_RSMA_ENV
(
pSma
);
SRSmaStat
*
pStat
=
SMA_RSMA_STAT
(
pEnv
->
pStat
);
...
...
@@ -661,18 +663,6 @@ static void *tdRSmaPersistExec(void *param) {
goto
_end
;
}
#if 0
SArray *suidList = taosArrayInit(1, sizeof(tb_uid_t));
if (tsdbGetStbIdList(SMA_META(pSma), 0, suidList) < 0) {
ASSERT(0);
} else {
for (int32_t i = 0; i < taosArrayGetSize(suidList); ++i) {
tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i);
smaDebug("suid [%d] is %" PRIi64, i, suid);
}
}
#endif
void
*
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
NULL
);
if
(
!
infoHash
)
{
goto
_end
;
...
...
@@ -833,7 +823,7 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) {
if
(
TASK_TRIGGER_STAT_CANCELLED
!=
atomic_val_compare_exchange_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_CANCELLED
,
TASK_TRIGGER_STAT_FINISHED
))
{
smaDebug
(
"
%s:%d rsma persistence start since active"
,
__func__
,
__LINE__
);
smaDebug
(
"
rsma persistence start since active"
);
tdRSmaPersistTask
(
pRSmaStat
);
taosTmrReset
(
tdRSmaPersistTrigger
,
RSMA_QTASK_PERSIST_MS
,
pRSmaStat
,
pRSmaStat
->
tmrHandle
,
&
pRSmaStat
->
tmrId
);
}
else
{
...
...
@@ -842,16 +832,17 @@ static void tdRSmaPersistTrigger(void *param, void *tmrId) {
}
break
;
case
TASK_TRIGGER_STAT_CANCELLED
:
{
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_FINISHED
);
smaDebug
(
"
%s:%d rsma persistence not start since cancelled and finished"
,
__func__
,
__LINE__
);
smaDebug
(
"
rsma persistence not start since cancelled and finished"
);
}
break
;
case
TASK_TRIGGER_STAT_INACTIVE
:
{
smaDebug
(
"
%s:%d rsma persistence not start since inactive"
,
__func__
,
__LINE__
);
smaDebug
(
"
rsma persistence not start since inactive"
);
}
break
;
case
TASK_TRIGGER_STAT_INIT
:
{
smaDebug
(
"
%s:%d rsma persistence not start since init"
,
__func__
,
__LINE__
);
smaDebug
(
"
rsma persistence not start since init"
);
}
break
;
default:
{
smaWarn
(
"%s:%d rsma persistence not start since unknown stat %"
PRIi8
,
__func__
,
__LINE__
,
tmrStat
);
smaWarn
(
"rsma persistence not start since unknown stat %"
PRIi8
,
tmrStat
);
ASSERT
(
0
);
}
break
;
}
}
\ No newline at end of file
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
cf6f7516
...
...
@@ -2886,6 +2886,9 @@ int32_t tsdbGetCtbIdList(SMeta* pMeta, int64_t suid, SArray* list) {
*/
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
);
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
cf6f7516
...
...
@@ -172,9 +172,9 @@ void vnodeClose(SVnode *pVnode) {
vnodeSyncClose
(
pVnode
);
vnodeQueryClose
(
pVnode
);
walClose
(
pVnode
->
pWal
);
smaCloseEx
(
pVnode
->
pSma
);
tqClose
(
pVnode
->
pTq
);
if
(
pVnode
->
pTsdb
)
tsdbClose
(
&
pVnode
->
pTsdb
);
smaCloseEx
(
pVnode
->
pSma
);
metaClose
(
pVnode
->
pMeta
);
vnodeCloseBufPool
(
pVnode
);
// destroy handle
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
cf6f7516
...
...
@@ -811,7 +811,7 @@ int32_t getMaximumIdleDurationSec();
* nOptrWithVal: *nOptrWithVal save the number of optr with value
* return: result code, 0 means success
*/
int32_t
encodeOperator
(
SOperatorInfo
*
ops
,
char
**
data
,
int32_t
*
length
);
int32_t
encodeOperator
(
SOperatorInfo
*
ops
,
char
**
data
,
int32_t
*
length
,
int32_t
*
nOptrWithVal
);
/*
* ops: root operator, created by caller
...
...
source/libs/executor/src/executorMain.c
浏览文件 @
cf6f7516
...
...
@@ -222,7 +222,13 @@ int32_t qSerializeTaskStatus(qTaskInfo_t tinfo, char** pOutput, int32_t* len) {
return
TSDB_CODE_INVALID_PARA
;
}
return
encodeOperator
(
pTaskInfo
->
pRoot
,
pOutput
,
len
);
int32_t
nOptrWithVal
=
0
;
int32_t
code
=
encodeOperator
(
pTaskInfo
->
pRoot
,
pOutput
,
len
,
&
nOptrWithVal
);
if
((
code
==
TSDB_CODE_SUCCESS
)
&&
(
nOptrWithVal
=
0
))
{
taosMemoryFreeClear
(
*
pOutput
);
*
len
=
0
;
}
return
code
;
}
int32_t
qDeserializeTaskStatus
(
qTaskInfo_t
tinfo
,
const
char
*
pInput
,
int32_t
len
)
{
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
cf6f7516
...
...
@@ -4472,12 +4472,12 @@ int32_t rebuildReader(SOperatorInfo* pOperator, SSubplan* plan, SReadHandle* pHa
return
0
;
}
int32_t
encodeOperator
(
SOperatorInfo
*
ops
,
char
**
result
,
int32_t
*
length
)
{
int32_t
encodeOperator
(
SOperatorInfo
*
ops
,
char
**
result
,
int32_t
*
length
,
int32_t
*
nOptrWithVal
)
{
int32_t
code
=
TDB_CODE_SUCCESS
;
char
*
pCurrent
=
NULL
;
int32_t
currLength
=
0
;
if
(
ops
->
fpSet
.
encodeResultRow
)
{
if
(
result
==
NULL
||
length
==
NULL
)
{
if
(
result
==
NULL
||
length
==
NULL
||
nOptrWithVal
==
NULL
)
{
return
TSDB_CODE_TSC_INVALID_INPUT
;
}
code
=
ops
->
fpSet
.
encodeResultRow
(
ops
,
&
pCurrent
,
&
currLength
);
...
...
@@ -4488,8 +4488,13 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) {
*
result
=
NULL
;
}
return
code
;
}
else
if
(
currLength
==
0
)
{
ASSERT
(
!
pCurrent
);
goto
_downstream
;
}
++
(
*
nOptrWithVal
);
ASSERT
(
currLength
>=
0
);
if
(
*
result
==
NULL
)
{
...
...
@@ -4516,8 +4521,10 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) {
taosMemoryFree
(
pCurrent
);
*
length
=
*
(
int32_t
*
)(
*
result
);
}
_downstream:
for
(
int32_t
i
=
0
;
i
<
ops
->
numOfDownstream
;
++
i
)
{
code
=
encodeOperator
(
ops
->
pDownstream
[
i
],
result
,
length
);
code
=
encodeOperator
(
ops
->
pDownstream
[
i
],
result
,
length
,
nOptrWithVal
);
if
(
code
!=
TDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录