Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
eeb5e918
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看板
未验证
提交
eeb5e918
编写于
6月 26, 2022
作者:
C
Cary Xu
提交者:
GitHub
6月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14268 from taosdata/feature/TD-11274-3.0
refactor: rsma resource release
上级
ef84dcbe
0597f3b9
变更
18
展开全部
隐藏空白更改
内联
并排
Showing
18 changed file
with
524 addition
and
196 deletion
+524
-196
source/common/src/tmsg.c
source/common/src/tmsg.c
+3
-7
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+1
-0
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+1
-0
source/dnode/vnode/src/inc/sma.h
source/dnode/vnode/src/inc/sma.h
+20
-12
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+6
-0
source/dnode/vnode/src/meta/metaOpen.c
source/dnode/vnode/src/meta/metaOpen.c
+9
-0
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+64
-0
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+12
-0
source/dnode/vnode/src/sma/smaEnv.c
source/dnode/vnode/src/sma/smaEnv.c
+84
-55
source/dnode/vnode/src/sma/smaOpen.c
source/dnode/vnode/src/sma/smaOpen.c
+15
-3
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+255
-110
source/dnode/vnode/src/sma/smaUtil.c
source/dnode/vnode/src/sma/smaUtil.c
+8
-3
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+24
-0
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+6
-1
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+4
-2
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-0
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+9
-1
source/os/src/osFile.c
source/os/src/osFile.c
+2
-2
未找到文件。
source/common/src/tmsg.c
浏览文件 @
eeb5e918
...
...
@@ -3696,7 +3696,7 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
isTsma
)
<
0
)
return
-
1
;
if
(
pReq
->
isTsma
)
{
if
(
tDecodeBinary
Alloc
(
&
decoder
,
&
pReq
->
pTsma
,
NULL
)
<
0
)
return
-
1
;
if
(
tDecodeBinary
(
&
decoder
,
(
uint8_t
**
)
&
pReq
->
pTsma
,
NULL
)
<
0
)
return
-
1
;
}
tEndDecode
(
&
decoder
);
...
...
@@ -3707,9 +3707,6 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
int32_t
tFreeSCreateVnodeReq
(
SCreateVnodeReq
*
pReq
)
{
taosArrayDestroy
(
pReq
->
pRetensions
);
pReq
->
pRetensions
=
NULL
;
if
(
pReq
->
isTsma
)
{
taosMemoryFreeClear
(
pReq
->
pTsma
);
}
return
0
;
}
...
...
@@ -4747,9 +4744,8 @@ int32_t tDecodeSRSmaParam(SDecoder *pCoder, SRSmaParam *pRSmaParam) {
if
(
tDecodeI64v
(
pCoder
,
&
pRSmaParam
->
watermark
[
i
])
<
0
)
return
-
1
;
if
(
tDecodeI32v
(
pCoder
,
&
pRSmaParam
->
qmsgLen
[
i
])
<
0
)
return
-
1
;
if
(
pRSmaParam
->
qmsgLen
[
i
]
>
0
)
{
uint64_t
len
;
if
(
tDecodeBinaryAlloc
(
pCoder
,
(
void
**
)
&
pRSmaParam
->
qmsg
[
i
],
&
len
)
<
0
)
return
-
1
;
// qmsgLen contains len of '\0'
tDecoderMalloc
(
pCoder
,
pRSmaParam
->
qmsgLen
[
i
]);
if
(
tDecodeBinary
(
pCoder
,
(
uint8_t
**
)
&
pRSmaParam
->
qmsg
[
i
],
NULL
)
<
0
)
return
-
1
;
// qmsgLen contains len of '\0'
}
else
{
pRSmaParam
->
qmsg
[
i
]
=
NULL
;
}
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
eeb5e918
...
...
@@ -125,6 +125,7 @@ int32_t tsdbGetFileBlocksDistInfo(tsdbReaderT *pReader, STableBlockDistInfo
bool
isTsdbCacheLastRow
(
tsdbReaderT
*
pReader
);
int32_t
tsdbGetAllTableList
(
SMeta
*
pMeta
,
uint64_t
uid
,
SArray
*
list
);
int32_t
tsdbGetCtbIdList
(
SMeta
*
pMeta
,
int64_t
suid
,
SArray
*
list
);
int32_t
tsdbGetStbIdList
(
SMeta
*
pMeta
,
int64_t
suid
,
SArray
*
list
);
void
*
tsdbGetIdx
(
SMeta
*
pMeta
);
void
*
tsdbGetIvtIdx
(
SMeta
*
pMeta
);
int64_t
tsdbGetNumOfRowsInMemTable
(
tsdbReaderT
*
pHandle
);
...
...
source/dnode/vnode/src/inc/meta.h
浏览文件 @
eeb5e918
...
...
@@ -69,6 +69,7 @@ struct SMeta {
TTB
*
pUidIdx
;
TTB
*
pNameIdx
;
TTB
*
pCtbIdx
;
TTB
*
pSuidIdx
;
// ivt idx and idx
void
*
pTagIvtIdx
;
TTB
*
pTagIdx
;
...
...
source/dnode/vnode/src/inc/sma.h
浏览文件 @
eeb5e918
...
...
@@ -60,8 +60,9 @@ struct SRSmaStat {
SSma
*
pSma
;
void
*
tmrHandle
;
tmr_h
tmrId
;
int8_t
tmrStat
;
int32_t
tmrSeconds
;
int8_t
triggerStat
;
int8_t
runningStat
;
SHashObj
*
rsmaInfoHash
;
// key: stbUid, value: SRSmaInfo;
};
...
...
@@ -72,13 +73,21 @@ struct SSmaStat {
};
T_REF_DECLARE
()
};
#define SMA_TSMA_STAT(s) (&(s)->tsmaStat)
#define SMA_RSMA_STAT(s) (&(s)->rsmaStat)
#define SMA_RSMA_INFO_HASH(s) ((s)->rsmaStat.rsmaInfoHash)
#define SMA_RSMA_TMR_HANDLE(s) ((s)->rsmaStat.tmrHandle)
#define SMA_RSMA_TMR_STAT(s) ((s)->rsmaStat.tmrStat)
#define RSMA_INFO_HASH(r) ((r)->rsmaInfoHash)
#define SMA_TSMA_STAT(s) (&(s)->tsmaStat)
#define SMA_RSMA_STAT(s) (&(s)->rsmaStat)
#define RSMA_INFO_HASH(r) ((r)->rsmaInfoHash)
#define RSMA_TMR_ID(r) ((r)->tmrId)
#define RSMA_TMR_HANDLE(r) ((r)->tmrHandle)
#define RSMA_TRIGGER_STAT(r) (&(r)->triggerStat)
#define RSMA_RUNNING_STAT(r) (&(r)->runningStat)
enum
{
TASK_TRIGGER_STAT_INIT
=
0
,
TASK_TRIGGER_STAT_ACTIVE
=
1
,
TASK_TRIGGER_STAT_INACTIVE
=
2
,
TASK_TRIGGER_STAT_CANCELLED
=
3
,
TASK_TRIGGER_STAT_FINISHED
=
4
,
};
void
tdDestroySmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
*
tdFreeSmaEnv
(
SSmaEnv
*
pSmaEnv
);
...
...
@@ -174,6 +183,8 @@ int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg);
int32_t
tdProcessTSmaInsertImpl
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
);
int32_t
tdProcessTSmaGetDaysImpl
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
);
// smaFileUtil ================
typedef
struct
STFInfo
STFInfo
;
typedef
struct
STFile
STFile
;
...
...
@@ -181,7 +192,7 @@ struct STFInfo {
uint32_t
magic
;
uint32_t
ftype
;
uint32_t
fver
;
uint64_t
fsize
;
int64_t
fsize
;
};
struct
STFile
{
...
...
@@ -199,11 +210,8 @@ struct STFile {
#define TD_FILE_OPENED(tf) (TD_FILE_PFILE(tf) != NULL)
#define TD_FILE_CLOSED(tf) (!TD_FILE_OPENED(tf))
#define TD_FILE_SET_CLOSED(f) (TD_FILE_PFILE(f) = NULL)
#define TD_FILE_STATE(tf) ((tf)->state)
#define TD_FILE_SET_STATE(tf, s) ((tf)->state = (s))
#define TD_FILE_DID(tf) (TD_FILE_F(tf)->did)
#define TD_FILE_IS_OK(tf) (TD_FILE_STATE(tf) == TD_FILE_STATE_OK)
#define TD_FILE_IS_BAD(tf) (TD_FILE_STATE(tf) == TD_FILE_STATE_BAD)
int32_t
tdInitTFile
(
STFile
*
pTFile
,
STfs
*
pTfs
,
const
char
*
fname
);
int32_t
tdCreateTFile
(
STFile
*
pTFile
,
STfs
*
pTfs
,
bool
updateHeader
,
int8_t
fType
);
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
eeb5e918
...
...
@@ -76,6 +76,7 @@ void vnodeFree(void* p);
// meta
typedef
struct
SMCtbCursor
SMCtbCursor
;
typedef
struct
SMStbCursor
SMStbCursor
;
typedef
struct
STbUidStore
STbUidStore
;
int
metaOpen
(
SVnode
*
pVnode
,
SMeta
**
ppMeta
);
...
...
@@ -97,6 +98,9 @@ int metaGetTbNum(SMeta* pMeta);
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseCtbCursor
(
SMCtbCursor
*
pCtbCur
);
tb_uid_t
metaCtbCursorNext
(
SMCtbCursor
*
pCtbCur
);
SMStbCursor
*
metaOpenStbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseStbCursor
(
SMStbCursor
*
pStbCur
);
tb_uid_t
metaStbCursorNext
(
SMStbCursor
*
pStbCur
);
STSma
*
metaGetSmaInfoByIndex
(
SMeta
*
pMeta
,
int64_t
indexUid
);
STSmaWrapper
*
metaGetSmaInfoByTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
bool
deepCopy
);
SArray
*
metaGetSmaIdsByTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
...
...
@@ -158,6 +162,8 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool
// sma
int32_t
smaOpen
(
SVnode
*
pVnode
);
int32_t
smaClose
(
SSma
*
pSma
);
int32_t
smaCloseEnv
(
SSma
*
pSma
);
int32_t
smaCloseEx
(
SSma
*
pSma
);
int32_t
tdProcessTSmaCreate
(
SSma
*
pSma
,
int64_t
version
,
const
char
*
msg
);
int32_t
tdProcessTSmaInsert
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
);
...
...
source/dnode/vnode/src/meta/metaOpen.c
浏览文件 @
eeb5e918
...
...
@@ -92,6 +92,13 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
goto
_err
;
}
// open pSuidIdx
ret
=
tdbTbOpen
(
"suid.idx"
,
sizeof
(
tb_uid_t
),
0
,
uidIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pSuidIdx
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta super table index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pTagIdx
// TODO(yihaoDeng), refactor later
char
indexFullPath
[
128
]
=
{
0
};
...
...
@@ -141,6 +148,7 @@ _err:
if
(
pMeta
->
pTagIvtIdx
)
indexClose
(
pMeta
->
pTagIvtIdx
);
if
(
pMeta
->
pTagIdx
)
tdbTbClose
(
pMeta
->
pTagIdx
);
if
(
pMeta
->
pCtbIdx
)
tdbTbClose
(
pMeta
->
pCtbIdx
);
if
(
pMeta
->
pSuidIdx
)
tdbTbClose
(
pMeta
->
pSuidIdx
);
if
(
pMeta
->
pNameIdx
)
tdbTbClose
(
pMeta
->
pNameIdx
);
if
(
pMeta
->
pUidIdx
)
tdbTbClose
(
pMeta
->
pUidIdx
);
if
(
pMeta
->
pSkmDb
)
tdbTbClose
(
pMeta
->
pSkmDb
);
...
...
@@ -162,6 +170,7 @@ int metaClose(SMeta *pMeta) {
if
(
pMeta
->
pTagIdx
)
tdbTbClose
(
pMeta
->
pTagIdx
);
#endif
if
(
pMeta
->
pCtbIdx
)
tdbTbClose
(
pMeta
->
pCtbIdx
);
if
(
pMeta
->
pSuidIdx
)
tdbTbClose
(
pMeta
->
pSuidIdx
);
if
(
pMeta
->
pNameIdx
)
tdbTbClose
(
pMeta
->
pNameIdx
);
if
(
pMeta
->
pUidIdx
)
tdbTbClose
(
pMeta
->
pUidIdx
);
if
(
pMeta
->
pSkmDb
)
tdbTbClose
(
pMeta
->
pSkmDb
);
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
eeb5e918
...
...
@@ -325,6 +325,70 @@ tb_uid_t metaCtbCursorNext(SMCtbCursor *pCtbCur) {
return
pCtbIdxKey
->
uid
;
}
struct
SMStbCursor
{
SMeta
*
pMeta
;
TBC
*
pCur
;
tb_uid_t
suid
;
void
*
pKey
;
void
*
pVal
;
int
kLen
;
int
vLen
;
};
SMStbCursor
*
metaOpenStbCursor
(
SMeta
*
pMeta
,
tb_uid_t
suid
)
{
SMStbCursor
*
pStbCur
=
NULL
;
int
ret
=
0
;
int
c
=
0
;
pStbCur
=
(
SMStbCursor
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pStbCur
));
if
(
pStbCur
==
NULL
)
{
return
NULL
;
}
pStbCur
->
pMeta
=
pMeta
;
pStbCur
->
suid
=
suid
;
metaRLock
(
pMeta
);
ret
=
tdbTbcOpen
(
pMeta
->
pSuidIdx
,
&
pStbCur
->
pCur
,
NULL
);
if
(
ret
<
0
)
{
metaULock
(
pMeta
);
taosMemoryFree
(
pStbCur
);
return
NULL
;
}
// move to the suid
tdbTbcMoveTo
(
pStbCur
->
pCur
,
&
suid
,
sizeof
(
suid
),
&
c
);
if
(
c
>
0
)
{
tdbTbcMoveToNext
(
pStbCur
->
pCur
);
}
return
pStbCur
;
}
void
metaCloseStbCursor
(
SMStbCursor
*
pStbCur
)
{
if
(
pStbCur
)
{
if
(
pStbCur
->
pMeta
)
metaULock
(
pStbCur
->
pMeta
);
if
(
pStbCur
->
pCur
)
{
tdbTbcClose
(
pStbCur
->
pCur
);
tdbFree
(
pStbCur
->
pKey
);
tdbFree
(
pStbCur
->
pVal
);
}
taosMemoryFree
(
pStbCur
);
}
}
tb_uid_t
metaStbCursorNext
(
SMStbCursor
*
pStbCur
)
{
int
ret
;
ret
=
tdbTbcNext
(
pStbCur
->
pCur
,
&
pStbCur
->
pKey
,
&
pStbCur
->
kLen
,
&
pStbCur
->
pVal
,
&
pStbCur
->
vLen
);
if
(
ret
<
0
)
{
return
0
;
}
return
*
(
tb_uid_t
*
)
pStbCur
->
pKey
;
}
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
)
{
// SMetaReader mr = {0};
STSchema
*
pTSchema
=
NULL
;
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
eeb5e918
...
...
@@ -23,6 +23,7 @@ static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME);
static
int
metaUpdateTtlIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaSaveToSkmDb
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaUpdateCtbIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaUpdateSuidIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
);
static
int
metaUpdateTagIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pCtbEntry
);
static
int
metaDropTableByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int
*
type
);
...
...
@@ -209,6 +210,7 @@ _drop_super_table:
&
pMeta
->
txn
);
tdbTbDelete
(
pMeta
->
pNameIdx
,
pReq
->
name
,
strlen
(
pReq
->
name
)
+
1
,
&
pMeta
->
txn
);
tdbTbDelete
(
pMeta
->
pUidIdx
,
&
pReq
->
suid
,
sizeof
(
tb_uid_t
),
&
pMeta
->
txn
);
tdbTbDelete
(
pMeta
->
pSuidIdx
,
&
pReq
->
suid
,
sizeof
(
tb_uid_t
),
&
pMeta
->
txn
);
metaULock
(
pMeta
);
...
...
@@ -436,11 +438,13 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
tdbTbDelete
(
pMeta
->
pUidIdx
,
&
uid
,
sizeof
(
uid
),
&
pMeta
->
txn
);
if
(
e
.
type
!=
TSDB_SUPER_TABLE
)
metaDeleteTtlIdx
(
pMeta
,
&
e
);
if
(
e
.
type
==
TSDB_CHILD_TABLE
)
{
tdbTbDelete
(
pMeta
->
pCtbIdx
,
&
(
SCtbIdxKey
){.
suid
=
e
.
ctbEntry
.
suid
,
.
uid
=
uid
},
sizeof
(
SCtbIdxKey
),
&
pMeta
->
txn
);
}
else
if
(
e
.
type
==
TSDB_NORMAL_TABLE
)
{
// drop schema.db (todo)
}
else
if
(
e
.
type
==
TSDB_SUPER_TABLE
)
{
tdbTbDelete
(
pMeta
->
pSuidIdx
,
&
e
.
uid
,
sizeof
(
tb_uid_t
),
&
pMeta
->
txn
);
// drop schema.db (todo)
}
...
...
@@ -911,6 +915,10 @@ static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) {
return
tdbTbInsert
(
pMeta
->
pUidIdx
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
&
pME
->
version
,
sizeof
(
int64_t
),
&
pMeta
->
txn
);
}
static
int
metaUpdateSuidIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
return
tdbTbInsert
(
pMeta
->
pSuidIdx
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
NULL
,
0
,
&
pMeta
->
txn
);
}
static
int
metaUpdateNameIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
return
tdbTbInsert
(
pMeta
->
pNameIdx
,
pME
->
name
,
strlen
(
pME
->
name
)
+
1
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
&
pMeta
->
txn
);
}
...
...
@@ -1081,6 +1089,10 @@ static int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) {
}
else
{
// update schema.db
if
(
metaSaveToSkmDb
(
pMeta
,
pME
)
<
0
)
goto
_err
;
if
(
pME
->
type
==
TSDB_SUPER_TABLE
)
{
if
(
metaUpdateSuidIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
}
}
if
(
pME
->
type
!=
TSDB_SUPER_TABLE
)
{
...
...
source/dnode/vnode/src/sma/smaEnv.c
浏览文件 @
eeb5e918
...
...
@@ -126,22 +126,21 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS
}
if
(
smaType
==
TSDB_SMA_TYPE_ROLLUP
)
{
SMA_RSMA_STAT
(
*
pSmaStat
)
->
pSma
=
(
SSma
*
)
pSma
;
SRSmaStat
*
pRSmaStat
=
(
SRSmaStat
*
)(
*
pSmaStat
);
pRSmaStat
->
pSma
=
(
SSma
*
)
pSma
;
// init timer
SMA_RSMA_TMR_HANDLE
(
*
pSmaStat
)
=
taosTmrInit
(
10000
,
100
,
10000
,
"RSMA_G
"
);
if
(
!
SMA_RSMA_TMR_HANDLE
(
*
p
SmaStat
))
{
RSMA_TMR_HANDLE
(
pRSmaStat
)
=
taosTmrInit
(
10000
,
100
,
10000
,
"RSMA
"
);
if
(
!
RSMA_TMR_HANDLE
(
pR
SmaStat
))
{
taosMemoryFreeClear
(
*
pSmaStat
);
return
TSDB_CODE_FAILED
;
}
atomic_store_8
(
&
SMA_RSMA_TMR_STAT
(
*
pSmaStat
),
TASK_TRIGGER_STATUS__ACTIVE
);
// init hash
SMA_RSMA_INFO_HASH
(
*
p
SmaStat
)
=
taosHashInit
(
RSMA_INFO_HASH
(
pR
SmaStat
)
=
taosHashInit
(
RSMA_TASK_INFO_HASH_SLOT
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_ENTRY_LOCK
);
if
(
!
SMA_RSMA_INFO_HASH
(
*
p
SmaStat
))
{
if
(
SMA_RSMA_TMR_HANDLE
(
*
p
SmaStat
))
{
taosTmrCleanUp
(
SMA_RSMA_TMR_HANDLE
(
*
p
SmaStat
));
if
(
!
RSMA_INFO_HASH
(
pR
SmaStat
))
{
if
(
RSMA_TMR_HANDLE
(
pR
SmaStat
))
{
taosTmrCleanUp
(
RSMA_TMR_HANDLE
(
pR
SmaStat
));
}
taosMemoryFreeClear
(
*
pSmaStat
);
return
TSDB_CODE_FAILED
;
...
...
@@ -155,12 +154,79 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS
return
TSDB_CODE_SUCCESS
;
}
static
void
*
tdFree
TSmaStat
(
STSmaStat
*
pStat
)
{
static
void
tdDestroy
TSmaStat
(
STSmaStat
*
pStat
)
{
if
(
pStat
)
{
tDestroyTSma
(
pStat
->
pTSma
);
taosMemoryFreeClear
(
pStat
->
pTSma
);
taosMemoryFreeClear
(
pStat
);
taosMemoryFreeClear
(
pStat
->
pTSchema
);
}
}
static
void
*
tdFreeTSmaStat
(
STSmaStat
*
pStat
)
{
tdDestroyTSmaStat
(
pStat
);
taosMemoryFreeClear
(
pStat
);
return
NULL
;
}
static
void
tdDestroyRSmaStat
(
SRSmaStat
*
pStat
)
{
if
(
pStat
)
{
smaDebug
(
"vgId:%d, %s:%d free rsma stat"
,
SMA_VID
(
pStat
->
pSma
),
__func__
,
__LINE__
);
// step 1: set persistence task cancelled
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pStat
),
TASK_TRIGGER_STAT_CANCELLED
);
// step 2: clean 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
;
if
(
atomic_load_8
(
RSMA_RUNNING_STAT
(
pStat
))
==
1
)
{
while
(
1
)
{
if
(
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pStat
))
==
TASK_TRIGGER_STAT_FINISHED
)
{
break
;
}
else
{
smaDebug
(
"not destroyed since rsma stat in %"
PRIi8
,
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pStat
)));
}
++
nLoops
;
if
(
nLoops
>
1000
)
{
sched_yield
();
nLoops
=
0
;
}
taosMsleep
(
1000
);
// TODO: remove this line when release
}
}
// step 4: destroy the rsma info and associated fetch tasks
// TODO: use taosHashSetFreeFp when taosHashSetFreeFp is ready.
void
*
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pStat
),
NULL
);
while
(
infoHash
)
{
SRSmaInfo
*
pSmaInfo
=
*
(
SRSmaInfo
**
)
infoHash
;
tdFreeRSmaInfo
(
pSmaInfo
);
infoHash
=
taosHashIterate
(
RSMA_INFO_HASH
(
pStat
),
infoHash
);
}
taosHashCleanup
(
RSMA_INFO_HASH
(
pStat
));
// step 5: wait all triggered fetch tasks finished
nLoops
=
0
;
while
(
1
)
{
if
(
T_REF_VAL_GET
((
SSmaStat
*
)
pStat
)
==
0
)
{
break
;
}
++
nLoops
;
if
(
nLoops
>
1000
)
{
sched_yield
();
nLoops
=
0
;
}
taosMsleep
(
1000
);
// TODO: remove this line when release
}
}
}
static
void
*
tdFreeRSmaStat
(
SRSmaStat
*
pStat
)
{
tdDestroyRSmaStat
(
pStat
);
taosMemoryFreeClear
(
pStat
);
return
NULL
;
}
...
...
@@ -179,22 +245,16 @@ void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) {
int32_t
tdDestroySmaState
(
SSmaStat
*
pSmaStat
,
int8_t
smaType
)
{
if
(
pSmaStat
)
{
if
(
smaType
==
TSDB_SMA_TYPE_TIME_RANGE
)
{
tdFreeTSmaStat
(
&
pSmaStat
->
tsmaStat
);
smaDebug
(
"%s:%d destroy tsma stat"
,
__func__
,
__LINE__
);
tdDestroyTSmaStat
(
SMA_TSMA_STAT
(
pSmaStat
));
}
else
if
(
smaType
==
TSDB_SMA_TYPE_ROLLUP
)
{
if
(
SMA_RSMA_TMR_HANDLE
(
pSmaStat
))
{
taosTmrCleanUp
(
SMA_RSMA_TMR_HANDLE
(
pSmaStat
));
}
// TODO: use taosHashSetFreeFp when taosHashSetFreeFp is ready.
void
*
infoHash
=
taosHashIterate
(
SMA_RSMA_INFO_HASH
(
pSmaStat
),
NULL
);
while
(
infoHash
)
{
SRSmaInfo
*
pInfoHash
=
*
(
SRSmaInfo
**
)
infoHash
;
tdFreeRSmaInfo
(
pInfoHash
);
infoHash
=
taosHashIterate
(
SMA_RSMA_INFO_HASH
(
pSmaStat
),
infoHash
);
}
taosHashCleanup
(
SMA_RSMA_INFO_HASH
(
pSmaStat
));
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
;
}
...
...
@@ -259,35 +319,4 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) {
tdUnLockSma
(
pSma
);
return
TSDB_CODE_SUCCESS
;
};
int32_t
smaTimerInit
(
void
**
timer
,
int8_t
*
initFlag
,
const
char
*
label
)
{
int8_t
old
;
while
(
1
)
{
old
=
atomic_val_compare_exchange_8
(
initFlag
,
0
,
2
);
if
(
old
!=
2
)
break
;
}
if
(
old
==
0
)
{
*
timer
=
taosTmrInit
(
10000
,
100
,
10000
,
label
);
if
(
!
(
*
timer
))
{
atomic_store_8
(
initFlag
,
0
);
return
-
1
;
}
atomic_store_8
(
initFlag
,
1
);
}
return
0
;
}
void
smaTimerCleanUp
(
void
*
timer
,
int8_t
*
initFlag
)
{
int8_t
old
;
while
(
1
)
{
old
=
atomic_val_compare_exchange_8
(
initFlag
,
1
,
2
);
if
(
old
!=
2
)
break
;
}
if
(
old
==
1
)
{
taosTmrCleanUp
(
timer
);
atomic_store_8
(
initFlag
,
0
);
}
}
\ No newline at end of file
};
\ No newline at end of file
source/dnode/vnode/src/sma/smaOpen.c
浏览文件 @
eeb5e918
...
...
@@ -126,19 +126,31 @@ _err:
return
-
1
;
}
int32_t
smaClose
(
SSma
*
pSma
)
{
int32_t
smaCloseEnv
(
SSma
*
pSma
)
{
if
(
pSma
)
{
SMA_TSMA_ENV
(
pSma
)
=
tdFreeSmaEnv
(
SMA_TSMA_ENV
(
pSma
));
SMA_RSMA_ENV
(
pSma
)
=
tdFreeSmaEnv
(
SMA_RSMA_ENV
(
pSma
));
}
return
0
;
}
int32_t
smaCloseEx
(
SSma
*
pSma
)
{
if
(
pSma
)
{
taosThreadMutexDestroy
(
&
pSma
->
mutex
);
if
SMA_RSMA_TSDB0
(
pSma
)
tsdbClose
(
&
SMA_RSMA_TSDB0
(
pSma
));
if
SMA_RSMA_TSDB1
(
pSma
)
tsdbClose
(
&
SMA_RSMA_TSDB1
(
pSma
));
if
SMA_RSMA_TSDB2
(
pSma
)
tsdbClose
(
&
SMA_RSMA_TSDB2
(
pSma
));
// SMA_TSMA_ENV(pSma) = tdFreeSmaEnv(SMA_TSMA_ENV(pSma));
// SMA_RSMA_ENV(pSma) = tdFreeSmaEnv(SMA_RSMA_ENV(pSma));
taosMemoryFreeClear
(
pSma
);
}
return
0
;
}
int32_t
smaClose
(
SSma
*
pSma
)
{
smaCloseEnv
(
pSma
);
smaCloseEx
(
pSma
);
return
0
;
}
/**
* @brief rsma env restore
*
...
...
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
eeb5e918
此差异已折叠。
点击以展开。
source/dnode/vnode/src/sma/smaUtil.c
浏览文件 @
eeb5e918
...
...
@@ -15,6 +15,8 @@
#include "sma.h"
// smaFileUtil ================
#define TD_FILE_HEAD_SIZE 512
#define TD_FILE_STATE_OK 0
...
...
@@ -32,7 +34,7 @@ static int32_t tdEncodeTFInfo(void **buf, STFInfo *pInfo) {
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
magic
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
ftype
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
fver
);
tlen
+=
taosEncodeFixed
U
64
(
buf
,
pInfo
->
fsize
);
tlen
+=
taosEncodeFixed
I
64
(
buf
,
pInfo
->
fsize
);
return
tlen
;
}
...
...
@@ -41,7 +43,7 @@ static void *tdDecodeTFInfo(void *buf, STFInfo *pInfo) {
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
magic
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
ftype
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
fver
));
buf
=
taosDecodeFixed
U
64
(
buf
,
&
(
pInfo
->
fsize
));
buf
=
taosDecodeFixed
I
64
(
buf
,
&
(
pInfo
->
fsize
));
return
buf
;
}
...
...
@@ -235,4 +237,7 @@ int32_t tdCreateTFile(STFile *pTFile, STfs *pTfs, bool updateHeader, int8_t fTyp
return
0
;
}
int32_t
tdRemoveTFile
(
STFile
*
pTFile
)
{
return
tfsRemoveFile
(
TD_FILE_F
(
pTFile
));
}
\ No newline at end of file
int32_t
tdRemoveTFile
(
STFile
*
pTFile
)
{
return
tfsRemoveFile
(
TD_FILE_F
(
pTFile
));
}
// smaXXXUtil ================
// ...
\ No newline at end of file
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
eeb5e918
...
...
@@ -2876,6 +2876,30 @@ int32_t tsdbGetCtbIdList(SMeta* pMeta, int64_t suid, SArray* list) {
return
TSDB_CODE_SUCCESS
;
}
/**
* @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
);
while
(
1
)
{
tb_uid_t
id
=
metaStbCursorNext
(
pCur
);
if
(
id
==
0
)
{
break
;
}
taosArrayPush
(
list
,
&
id
);
}
metaCloseStbCursor
(
pCur
);
return
TSDB_CODE_SUCCESS
;
}
static
void
destroyHelper
(
void
*
param
)
{
if
(
param
==
NULL
)
{
return
;
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
eeb5e918
...
...
@@ -72,7 +72,12 @@ int vnodeBegin(SVnode *pVnode) {
return
0
;
}
int
vnodeShouldCommit
(
SVnode
*
pVnode
)
{
return
pVnode
->
inUse
->
size
>
pVnode
->
config
.
szBuf
/
3
;
}
int
vnodeShouldCommit
(
SVnode
*
pVnode
)
{
if
(
pVnode
->
inUse
)
{
return
pVnode
->
inUse
->
size
>
pVnode
->
config
.
szBuf
/
3
;
}
return
false
;
}
int
vnodeSaveInfo
(
const
char
*
dir
,
const
SVnodeInfo
*
pInfo
)
{
char
fname
[
TSDB_FILENAME_LEN
];
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
eeb5e918
...
...
@@ -152,12 +152,13 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
return
pVnode
;
_err:
if
(
pVnode
->
pSma
)
smaClose
(
pVnode
->
pSma
);
if
(
pVnode
->
pQuery
)
vnodeQueryClose
(
pVnode
);
if
(
pVnode
->
pTq
)
tqClose
(
pVnode
->
pTq
);
if
(
pVnode
->
pWal
)
walClose
(
pVnode
->
pWal
);
if
(
pVnode
->
pTsdb
)
tsdbClose
(
&
pVnode
->
pTsdb
);
if
(
pVnode
->
pMeta
)
metaClose
(
pVnode
->
pMeta
);
if
(
pVnode
->
pSma
)
smaClose
(
pVnode
->
pSma
);
tsem_destroy
(
&
(
pVnode
->
canCommit
));
taosMemoryFree
(
pVnode
);
...
...
@@ -166,13 +167,14 @@ _err:
void
vnodeClose
(
SVnode
*
pVnode
)
{
if
(
pVnode
)
{
smaCloseEnv
(
pVnode
->
pSma
);
vnodeCommit
(
pVnode
);
vnodeSyncClose
(
pVnode
);
vnodeQueryClose
(
pVnode
);
walClose
(
pVnode
->
pWal
);
smaCloseEx
(
pVnode
->
pSma
);
tqClose
(
pVnode
->
pTq
);
if
(
pVnode
->
pTsdb
)
tsdbClose
(
&
pVnode
->
pTsdb
);
smaClose
(
pVnode
->
pSma
);
metaClose
(
pVnode
->
pMeta
);
vnodeCloseBufPool
(
pVnode
);
// destroy handle
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
eeb5e918
...
...
@@ -808,6 +808,7 @@ int32_t getMaximumIdleDurationSec();
* ops: root operator
* data: *data save the result of encode, need to be freed by caller
* length: *length save the length of *data
* 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
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
eeb5e918
...
...
@@ -2929,6 +2929,13 @@ int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* len
int32_t
totalSize
=
sizeof
(
int32_t
)
+
sizeof
(
int32_t
)
+
size
*
(
sizeof
(
int32_t
)
+
keyLen
+
sizeof
(
int32_t
)
+
pSup
->
resultRowSize
);
// no result
if
(
getTotalBufSize
(
pSup
->
pResultBuf
)
==
0
)
{
*
result
=
NULL
;
*
length
=
0
;
return
TSDB_CODE_SUCCESS
;
}
*
result
=
(
char
*
)
taosMemoryCalloc
(
1
,
totalSize
);
if
(
*
result
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -4482,6 +4489,8 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) {
}
return
code
;
}
ASSERT
(
currLength
>=
0
);
if
(
*
result
==
NULL
)
{
*
result
=
(
char
*
)
taosMemoryCalloc
(
1
,
currLength
+
sizeof
(
int32_t
));
...
...
@@ -4507,7 +4516,6 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length) {
taosMemoryFree
(
pCurrent
);
*
length
=
*
(
int32_t
*
)(
*
result
);
}
for
(
int32_t
i
=
0
;
i
<
ops
->
numOfDownstream
;
++
i
)
{
code
=
encodeOperator
(
ops
->
pDownstream
[
i
],
result
,
length
);
if
(
code
!=
TDB_CODE_SUCCESS
)
{
...
...
source/os/src/osFile.c
浏览文件 @
eeb5e918
...
...
@@ -157,14 +157,14 @@ int32_t taosRenameFile(const char *oldName, const char *newName) {
#ifdef WINDOWS
bool
code
=
MoveFileEx
(
oldName
,
newName
,
MOVEFILE_REPLACE_EXISTING
|
MOVEFILE_COPY_ALLOWED
);
if
(
!
code
)
{
printf
(
"failed to rename file %s to %s, reason:%s"
,
oldName
,
newName
,
strerror
(
errno
));
printf
(
"failed to rename file %s to %s, reason:%s
\n
"
,
oldName
,
newName
,
strerror
(
errno
));
}
return
!
code
;
#else
int32_t
code
=
rename
(
oldName
,
newName
);
if
(
code
<
0
)
{
printf
(
"failed to rename file %s to %s, reason:%s"
,
oldName
,
newName
,
strerror
(
errno
));
printf
(
"failed to rename file %s to %s, reason:%s
\n
"
,
oldName
,
newName
,
strerror
(
errno
));
}
return
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录