Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
df7866e9
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看板
提交
df7866e9
编写于
7月 05, 2023
作者:
K
kailixu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: refactor
上级
59e83fca
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
59 addition
and
56 deletion
+59
-56
source/dnode/vnode/src/inc/sma.h
source/dnode/vnode/src/inc/sma.h
+12
-12
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-1
source/dnode/vnode/src/sma/smaCommit.c
source/dnode/vnode/src/sma/smaCommit.c
+7
-7
source/dnode/vnode/src/sma/smaEnv.c
source/dnode/vnode/src/sma/smaEnv.c
+1
-1
source/dnode/vnode/src/sma/smaFS.c
source/dnode/vnode/src/sma/smaFS.c
+2
-1
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+5
-5
source/dnode/vnode/src/sma/smaSnapshot.c
source/dnode/vnode/src/sma/smaSnapshot.c
+30
-28
tests/script/tsim/sma/rsmaCreateInsertQuery.sim
tests/script/tsim/sma/rsmaCreateInsertQuery.sim
+1
-1
未找到文件。
source/dnode/vnode/src/inc/sma.h
浏览文件 @
df7866e9
...
...
@@ -223,21 +223,21 @@ int32_t smaPreClose(SSma *pSma);
// rsma
void
*
tdFreeRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pInfo
,
bool
isDeepFree
);
int32_t
tdRSmaFSOpen
(
SSma
*
pSma
,
int64_t
version
,
int8_t
rollback
);
void
tdRSmaFSClose
(
SRSmaFS
*
fs
);
int32_t
tdRSmaFSPrepareCommit
(
SSma
*
pSma
,
SRSmaFS
*
pFSNew
);
int32_t
tdRSmaFSCommit
(
SSma
*
pSma
);
int32_t
tdRSmaFSFinishCommit
(
SSma
*
pSma
);
int32_t
tdRSmaFSCopy
(
SSma
*
pSma
,
SRSmaFS
*
pFS
);
int32_t
tdRSmaFSTakeSnapshot
(
SSma
*
pSma
,
SRSmaFS
*
pFS
);
int32_t
tdRSmaFSRef
(
SSma
*
pSma
,
SRSmaFS
*
pFS
);
void
tdRSmaFSUnRef
(
SSma
*
pSma
,
SRSmaFS
*
pFS
);
int32_t
tdRSmaFSUpsertQTaskFile
(
SSma
*
pSma
,
SRSmaFS
*
pFS
,
SQTaskFile
*
qTaskFile
,
int32_t
nSize
);
int32_t
tdRSmaFSRollback
(
SSma
*
pSma
);
//
int32_t tdRSmaFSOpen(SSma *pSma, int64_t version, int8_t rollback);
//
void tdRSmaFSClose(SRSmaFS *fs);
//
int32_t tdRSmaFSPrepareCommit(SSma *pSma, SRSmaFS *pFSNew);
//
int32_t tdRSmaFSCommit(SSma *pSma);
//
int32_t tdRSmaFSFinishCommit(SSma *pSma);
//
int32_t tdRSmaFSCopy(SSma *pSma, SRSmaFS *pFS);
//
int32_t tdRSmaFSTakeSnapshot(SSma *pSma, SRSmaFS *pFS);
//
int32_t tdRSmaFSRef(SSma *pSma, SRSmaFS *pFS);
//
void tdRSmaFSUnRef(SSma *pSma, SRSmaFS *pFS);
//
int32_t tdRSmaFSUpsertQTaskFile(SSma *pSma, SRSmaFS *pFS, SQTaskFile *qTaskFile, int32_t nSize);
//
int32_t tdRSmaFSRollback(SSma *pSma);
int32_t
tdRSmaRestore
(
SSma
*
pSma
,
int8_t
type
,
int64_t
committedVer
,
int8_t
rollback
);
int32_t
tdRSmaProcessCreateImpl
(
SSma
*
pSma
,
SRSmaParam
*
param
,
int64_t
suid
,
const
char
*
tbName
);
int32_t
tdRSmaProcessExecImpl
(
SSma
*
pSma
,
ERsmaExecType
type
);
int32_t
tdRSmaPersistExecImpl
(
SRSmaStat
*
pRSmaStat
,
SHashObj
*
pInfoHash
);
//
int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash);
int32_t
tdRSmaProcessRestoreImpl
(
SSma
*
pSma
,
int8_t
type
,
int64_t
qtaskFileVer
,
int8_t
rollback
);
void
tdRSmaQTaskInfoGetFileName
(
int32_t
vgId
,
int64_t
suid
,
int8_t
level
,
int64_t
version
,
char
*
outputName
);
void
tdRSmaQTaskInfoGetFullName
(
int32_t
vgId
,
int64_t
suid
,
int8_t
level
,
int64_t
version
,
const
char
*
path
,
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
df7866e9
...
...
@@ -318,7 +318,7 @@ int32_t rsmaSnapRead(SRSmaSnapReader* pReader, uint8_t** ppData);
// SRSmaSnapWriter ========================================
int32_t
rsmaSnapWriterOpen
(
SSma
*
pSma
,
int64_t
sver
,
int64_t
ever
,
SRSmaSnapWriter
**
ppWriter
);
int32_t
rsmaSnapWrite
(
SRSmaSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
);
int32_t
rsmaSnapWriterPrepareClose
(
SRSmaSnapWriter
*
pWriter
);
//
int32_t rsmaSnapWriterPrepareClose(SRSmaSnapWriter* pWriter);
int32_t
rsmaSnapWriterClose
(
SRSmaSnapWriter
**
ppWriter
,
int8_t
rollback
);
typedef
struct
{
...
...
source/dnode/vnode/src/sma/smaCommit.c
浏览文件 @
df7866e9
...
...
@@ -108,8 +108,8 @@ int32_t smaFinishCommit(SSma *pSma) {
int32_t
lino
=
0
;
SVnode
*
pVnode
=
pSma
->
pVnode
;
code
=
tdRSmaFSFinishCommit
(
pSma
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
//
code = tdRSmaFSFinishCommit(pSma);
//
TSDB_CHECK_CODE(code, lino, _exit);
if
(
VND_RSMA1
(
pVnode
)
&&
(
code
=
tsdbFinishCommit
(
VND_RSMA1
(
pVnode
)))
<
0
)
{
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
...
@@ -187,10 +187,10 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma, bool isCommit) {
if
(
!
isCommit
)
goto
_exit
;
smaInfo
(
"vgId:%d, rsma commit, all items are consumed, TID:%p"
,
SMA_VID
(
pSma
),
(
void
*
)
taosGetSelfPthreadId
());
code
=
tdRSmaPersistExecImpl
(
pRSmaStat
,
RSMA_INFO_HASH
(
pRSmaStat
));
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
//
code = tdRSmaPersistExecImpl(pRSmaStat, RSMA_INFO_HASH(pRSmaStat));
//
TSDB_CHECK_CODE(code, lino, _exit);
smaInfo
(
"vgId:%d, rsma commit, operator state committed, TID:%p"
,
SMA_VID
(
pSma
),
(
void
*
)
taosGetSelfPthreadId
());
//
smaInfo("vgId:%d, rsma commit, operator state committed, TID:%p", SMA_VID(pSma), (void *)taosGetSelfPthreadId());
#if 0 // consuming task of qTaskInfo clone
// step 4: swap queue/qall and iQueue/iQall
...
...
@@ -246,8 +246,8 @@ static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma, SCommitInfo *pInfo) {
goto
_exit
;
}
code
=
tdRSmaFSCommit
(
pSma
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
//
code = tdRSmaFSCommit(pSma);
//
TSDB_CHECK_CODE(code, lino, _exit);
code
=
tsdbCommit
(
VND_RSMA1
(
pVnode
),
pInfo
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
...
source/dnode/vnode/src/sma/smaEnv.c
浏览文件 @
df7866e9
...
...
@@ -288,7 +288,7 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
taosHashCleanup
(
RSMA_INFO_HASH
(
pStat
));
// step 5:
tdRSmaFSClose
(
RSMA_FS
(
pStat
));
//
tdRSmaFSClose(RSMA_FS(pStat));
// step 6: free pStat
tsem_destroy
(
&
(
pStat
->
notEmpty
));
...
...
source/dnode/vnode/src/sma/smaFS.c
浏览文件 @
df7866e9
...
...
@@ -16,7 +16,7 @@
#include "sma.h"
// =================================================================================================
#if 0
// static int32_t tdFetchQTaskInfoFiles(SSma *pSma, int64_t version, SArray **output);
static int32_t tdQTaskInfCmprFn1(const void *p1, const void *p2);
...
...
@@ -640,3 +640,4 @@ _exit:
}
return code;
}
#endif
\ No newline at end of file
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
df7866e9
...
...
@@ -1185,9 +1185,9 @@ int32_t tdRSmaProcessRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer,
}
// step 2: open SRSmaFS for qTaskFiles
if
((
code
=
tdRSmaFSOpen
(
pSma
,
qtaskFileVer
,
rollback
))
<
0
)
{
goto
_err
;
}
//
if ((code = tdRSmaFSOpen(pSma, qtaskFileVer, rollback)) < 0) {
//
goto _err;
//
}
// step 3: iterate all stables to restore the rsma env
if
((
code
=
tdRSmaRestoreQTaskInfoInit
(
pSma
,
&
nTables
))
<
0
)
{
...
...
@@ -1205,7 +1205,7 @@ _err:
return
code
;
}
#if 0
int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) {
int32_t code = 0;
int32_t lino = 0;
...
...
@@ -1315,7 +1315,7 @@ _exit:
terrno = code;
return code;
}
#endif
/**
* @brief trigger to get rsma result in async mode
*
...
...
source/dnode/vnode/src/sma/smaSnapshot.c
浏览文件 @
df7866e9
...
...
@@ -15,8 +15,8 @@
#include "sma.h"
static
int32_t
rsmaSnapReadQTaskInfo
(
SRSmaSnapReader
*
pReader
,
uint8_t
**
ppData
);
static
int32_t
rsmaSnapWriteQTaskInfo
(
SRSmaSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
);
//
static int32_t rsmaSnapReadQTaskInfo(SRSmaSnapReader* pReader, uint8_t** ppData);
//
static int32_t rsmaSnapWriteQTaskInfo(SRSmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData);
// SRSmaSnapReader ========================================
struct
SRSmaSnapReader
{
...
...
@@ -63,10 +63,10 @@ int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapRead
}
// open qtaskinfo
taosRLockLatch
(
RSMA_FS_LOCK
(
pStat
));
code
=
tdRSmaFSRef
(
pSma
,
&
pReader
->
fs
);
taosRUnLockLatch
(
RSMA_FS_LOCK
(
pStat
));
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
//
taosRLockLatch(RSMA_FS_LOCK(pStat));
//
code = tdRSmaFSRef(pSma, &pReader->fs);
//
taosRUnLockLatch(RSMA_FS_LOCK(pStat));
//
TSDB_CHECK_CODE(code, lino, _exit);
if
(
taosArrayGetSize
(
pReader
->
fs
.
aQTaskInf
)
>
0
)
{
pReader
->
pQTaskFReader
=
taosMemoryCalloc
(
1
,
sizeof
(
SQTaskFReader
));
...
...
@@ -249,7 +249,7 @@ int32_t rsmaSnapReaderClose(SRSmaSnapReader** ppReader) {
int32_t
code
=
0
;
SRSmaSnapReader
*
pReader
=
*
ppReader
;
tdRSmaFSUnRef
(
pReader
->
pSma
,
&
pReader
->
fs
);
//
tdRSmaFSUnRef(pReader->pSma, &pReader->fs);
taosMemoryFreeClear
(
pReader
->
pQTaskFReader
);
for
(
int32_t
i
=
0
;
i
<
TSDB_RETENTION_L2
;
++
i
)
{
...
...
@@ -300,8 +300,8 @@ int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapWrit
}
// qtaskinfo
code
=
tdRSmaFSCopy
(
pSma
,
&
pWriter
->
fs
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
//
code = tdRSmaFSCopy(pSma, &pWriter->fs);
//
TSDB_CHECK_CODE(code, lino, _exit);
// snapWriter
*
ppWriter
=
pWriter
;
...
...
@@ -316,21 +316,21 @@ _exit:
return
code
;
}
int32_t
rsmaSnapWriterPrepareClose
(
SRSmaSnapWriter
*
pWriter
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
//
int32_t rsmaSnapWriterPrepareClose(SRSmaSnapWriter* pWriter) {
//
int32_t code = 0;
//
int32_t lino = 0;
if
(
pWriter
)
{
code
=
tdRSmaFSPrepareCommit
(
pWriter
->
pSma
,
&
pWriter
->
fs
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
//
if (pWriter) {
//
code = tdRSmaFSPrepareCommit(pWriter->pSma, &pWriter->fs);
//
TSDB_CHECK_CODE(code, lino, _exit);
//
}
_exit:
if
(
code
)
{
smaError
(
"vgId:%d, %s failed at line %d since %s"
,
SMA_VID
(
pWriter
->
pSma
),
__func__
,
lino
,
tstrerror
(
code
));
}
return
code
;
}
//
_exit:
//
if (code) {
//
smaError("vgId:%d, %s failed at line %d since %s", SMA_VID(pWriter->pSma), __func__, lino, tstrerror(code));
//
}
//
return code;
//
}
int32_t
rsmaSnapWriterClose
(
SRSmaSnapWriter
**
ppWriter
,
int8_t
rollback
)
{
int32_t
code
=
0
;
...
...
@@ -364,9 +364,10 @@ int32_t rsmaSnapWriterClose(SRSmaSnapWriter** ppWriter, int8_t rollback) {
}
}
#if 0
// qtaskinfo
if (rollback) {
tdRSmaFSRollback
(
pSma
);
//
tdRSmaFSRollback(pSma);
// remove qTaskFiles
} else {
// sendFile from fname.Ver to fname
...
...
@@ -418,7 +419,7 @@ int32_t rsmaSnapWriterClose(SRSmaSnapWriter** ppWriter, int8_t rollback) {
// unlock
taosWUnLockLatch(RSMA_FS_LOCK(pStat));
}
#endif
// rsma restore
code
=
tdRSmaRestore
(
pWriter
->
pSma
,
RSMA_RESTORE_SYNC
,
pWriter
->
ever
,
rollback
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
...
@@ -451,7 +452,7 @@ int32_t rsmaSnapWrite(SRSmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData)
pHdr
->
type
=
SNAP_DATA_TSDB
;
code
=
tsdbSnapWrite
(
pWriter
->
pDataWriter
[
1
],
pHdr
);
}
else
if
(
pHdr
->
type
==
SNAP_DATA_QTASK
)
{
code
=
rsmaSnapWriteQTaskInfo
(
pWriter
,
pData
,
nData
);
//
code = rsmaSnapWriteQTaskInfo(pWriter, pData, nData);
}
else
{
code
=
TSDB_CODE_RSMA_FS_SYNC
;
}
...
...
@@ -466,7 +467,7 @@ _exit:
}
return
code
;
}
#if 0
static int32_t rsmaSnapWriteQTaskInfo(SRSmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
int32_t code = 0;
int32_t lino = 0;
...
...
@@ -516,8 +517,8 @@ static int32_t rsmaSnapWriteQTaskInfo(SRSmaSnapWriter* pWriter, uint8_t* pData,
taosCloseFile(&fp);
code
=
tdRSmaFSUpsertQTaskFile
(
pSma
,
&
pWriter
->
fs
,
&
qTaskFile
,
1
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
//
code = tdRSmaFSUpsertQTaskFile(pSma, &pWriter->fs, &qTaskFile, 1);
//
TSDB_CHECK_CODE(code, lino, _exit);
_exit:
if (code) {
...
...
@@ -531,3 +532,4 @@ _exit:
return code;
}
#endif
\ No newline at end of file
tests/script/tsim/sma/rsmaCreateInsertQuery.sim
浏览文件 @
df7866e9
...
...
@@ -5,7 +5,7 @@ sleep 50
sql connect
#todo xukaili sma should use rocksdb.
return 1
#
return 1
print =============== create database with retentions
sql create database d0 retentions 5s:7d,10s:21d,15s:365d;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录