Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
eedaeda8
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
eedaeda8
编写于
7月 05, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: rsma level 1/2 utilize separated version
上级
a12f04b2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
84 addition
and
14 deletion
+84
-14
source/dnode/vnode/src/inc/sma.h
source/dnode/vnode/src/inc/sma.h
+7
-1
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-0
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+45
-4
source/dnode/vnode/src/sma/smaUtil.c
source/dnode/vnode/src/sma/smaUtil.c
+8
-0
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+23
-9
未找到文件。
source/dnode/vnode/src/inc/sma.h
浏览文件 @
eedaeda8
...
...
@@ -62,6 +62,7 @@ struct STSmaStat {
struct
SRSmaStat
{
SSma
*
pSma
;
int64_t
submitVer
;
int64_t
refId
;
// shared by fetch tasks
void
*
tmrHandle
;
// shared by fetch tasks
int8_t
triggerStat
;
// shared by fetch tasks
...
...
@@ -84,6 +85,7 @@ struct SSmaStat {
#define RSMA_TRIGGER_STAT(r) (&(r)->triggerStat)
#define RSMA_RUNNING_STAT(r) (&(r)->runningStat)
#define RSMA_REF_ID(r) ((r)->refId)
#define RSMA_SUBMIT_VER(r) ((r)->submitVer)
enum
{
TASK_TRIGGER_STAT_INIT
=
0
,
...
...
@@ -208,11 +210,15 @@ struct STFInfo {
// specific fields
union
{
struct
{
int64_t
applyVer
[
2
]
;
int64_t
submitVer
;
}
qTaskInfo
;
};
};
enum
{
TD_FTYPE_RSMA_QTASKINFO
=
0
,
};
struct
STFile
{
uint8_t
state
;
STFInfo
info
;
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
eedaeda8
...
...
@@ -172,6 +172,7 @@ int32_t smaPostCommit(SSma* pSma);
int32_t
tdProcessTSmaCreate
(
SSma
*
pSma
,
int64_t
version
,
const
char
*
msg
);
int32_t
tdProcessTSmaInsert
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
);
int64_t
tdRSmaGetMaxSubmitVer
(
SSma
*
pSma
,
int8_t
level
);
int32_t
tdProcessRSmaCreate
(
SVnode
*
pVnode
,
SVCreateStbReq
*
pReq
);
int32_t
tdProcessRSmaSubmit
(
SSma
*
pSma
,
void
*
pMsg
,
int32_t
inputType
);
...
...
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
eedaeda8
...
...
@@ -523,6 +523,17 @@ static void tdDestroySDataBlockArray(SArray *pArray) {
taosArrayDestroy
(
pArray
);
}
int64_t
tdRSmaGetMaxSubmitVer
(
SSma
*
pSma
,
int8_t
level
)
{
if
(
level
==
TSDB_RETENTION_L0
)
{
return
pSma
->
pVnode
->
state
.
applied
;
}
SSmaEnv
*
pRSmaEnv
=
SMA_RSMA_ENV
(
pSma
);
SRSmaStat
*
pRSmaStat
=
(
SRSmaStat
*
)(
SMA_ENV_STAT
(
pRSmaEnv
));
return
atomic_load_64
(
&
pRSmaStat
->
submitVer
);
}
static
int32_t
tdFetchAndSubmitRSmaResult
(
SRSmaInfoItem
*
pItem
,
int8_t
blkType
)
{
SArray
*
pResult
=
NULL
;
SRSmaInfo
*
pRSmaInfo
=
pItem
->
pRsmaInfo
;
...
...
@@ -562,7 +573,7 @@ static int32_t tdFetchAndSubmitRSmaResult(SRSmaInfoItem *pItem, int8_t blkType)
goto
_err
;
}
if
(
pReq
&&
tdProcessSubmitReq
(
sinkTsdb
,
1
,
pReq
)
<
0
)
{
if
(
pReq
&&
tdProcessSubmitReq
(
sinkTsdb
,
atomic_add_fetch_64
(
&
pRSmaInfo
->
pStat
->
submitVer
,
1
)
,
pReq
)
<
0
)
{
taosMemoryFreeClear
(
pReq
);
goto
_err
;
}
...
...
@@ -814,6 +825,7 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int64_t *committed) {
}
if
(
!
taosCheckExistFile
(
TD_TFILE_FULL_NAME
(
&
tFile
)))
{
*
committed
=
0
;
if
(
pVnode
->
state
.
committed
>
0
)
{
smaWarn
(
"vgId:%d, rsma restore for version %"
PRIi64
", not start as %s not exist"
,
TD_VID
(
pVnode
),
pVnode
->
state
.
committed
,
TD_TFILE_FULL_NAME
(
&
tFile
));
...
...
@@ -828,6 +840,18 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int64_t *committed) {
goto
_err
;
}
STFInfo
tFileInfo
=
{
0
};
if
(
tdLoadTFileHeader
(
&
tFile
,
&
tFileInfo
)
<
0
)
{
goto
_err
;
}
ASSERT
(
tFileInfo
.
qTaskInfo
.
submitVer
>
0
);
SSmaEnv
*
pRSmaEnv
=
pSma
->
pRSmaEnv
;
SRSmaStat
*
pRSmaStat
=
(
SRSmaStat
*
)
SMA_ENV_STAT
(
pRSmaEnv
);
atomic_store_64
(
&
pRSmaStat
->
submitVer
,
tFileInfo
.
qTaskInfo
.
submitVer
);
smaDebug
(
"%s:%d tFileInfo.qTaskInfo.submitVer = %"
PRIi64
,
__func__
,
__LINE__
,
tFileInfo
.
qTaskInfo
.
submitVer
);
SRSmaQTaskInfoIter
fIter
=
{
0
};
if
(
tdRSmaQTaskInfoIterInit
(
&
fIter
,
&
tFile
)
<
0
)
{
tdRSmaQTaskInfoIterDestroy
(
&
fIter
);
...
...
@@ -1094,6 +1118,22 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat) {
}
STFile
tFile
=
{
0
};
if
(
RSMA_SUBMIT_VER
(
pRSmaStat
)
>
0
)
{
char
qTaskInfoFName
[
TSDB_FILENAME_LEN
];
tdRSmaQTaskInfoGetFName
(
vid
,
pSma
->
pVnode
->
state
.
applied
,
qTaskInfoFName
);
if
(
tdInitTFile
(
&
tFile
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
qTaskInfoFName
)
<
0
)
{
smaError
(
"vgId:%d, rsma persit, init %s failed since %s"
,
vid
,
qTaskInfoFName
,
terrstr
());
goto
_err
;
}
if
(
tdCreateTFile
(
&
tFile
,
true
,
TD_FTYPE_RSMA_QTASKINFO
)
<
0
)
{
smaError
(
"vgId:%d, rsma persit, create %s failed since %s"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
),
terrstr
());
goto
_err
;
}
smaDebug
(
"vgId:%d, rsma, serialize qTaskInfo, file %s created"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
));
isFileCreated
=
true
;
}
while
(
infoHash
)
{
SRSmaInfo
*
pRSmaInfo
=
*
(
SRSmaInfo
**
)
infoHash
;
for
(
int32_t
i
=
0
;
i
<
TSDB_RETENTION_L2
;
++
i
)
{
...
...
@@ -1129,12 +1169,12 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat) {
smaError
(
"vgId:%d, rsma persit, init %s failed since %s"
,
vid
,
qTaskInfoFName
,
terrstr
());
goto
_err
;
}
if
(
tdCreateTFile
(
&
tFile
,
true
,
-
1
)
<
0
)
{
if
(
tdCreateTFile
(
&
tFile
,
true
,
TD_FTYPE_RSMA_QTASKINFO
)
<
0
)
{
smaError
(
"vgId:%d, rsma persit, create %s failed since %s"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
),
terrstr
());
goto
_err
;
}
smaDebug
(
"vgId:%d, rsma, table %"
PRIi64
"
level %d
serialize qTaskInfo, file %s created"
,
vid
,
pRSmaInfo
->
suid
,
i
+
1
,
TD_TFILE_FULL_NAME
(
&
tFile
));
smaDebug
(
"vgId:%d, rsma, table %"
PRIi64
" serialize qTaskInfo, file %s created"
,
vid
,
pRSmaInfo
->
suid
,
TD_TFILE_FULL_NAME
(
&
tFile
));
isFileCreated
=
true
;
}
...
...
@@ -1161,6 +1201,7 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat) {
}
if
(
isFileCreated
)
{
tFile
.
info
.
qTaskInfo
.
submitVer
=
atomic_load_64
(
&
pRSmaStat
->
submitVer
);
if
(
tdUpdateTFileHeader
(
&
tFile
)
<
0
)
{
smaError
(
"vgId:%d, rsma, failed to update tfile %s header since %s"
,
vid
,
TD_TFILE_FULL_NAME
(
&
tFile
),
tstrerror
(
terrno
));
...
...
source/dnode/vnode/src/sma/smaUtil.c
浏览文件 @
eedaeda8
...
...
@@ -32,6 +32,9 @@ static int32_t tdEncodeTFInfo(void **buf, STFInfo *pInfo) {
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
ftype
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
fver
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pInfo
->
fsize
);
if
(
pInfo
->
ftype
==
TD_FTYPE_RSMA_QTASKINFO
)
{
tlen
+=
taosEncodeFixedI64
(
buf
,
pInfo
->
qTaskInfo
.
submitVer
);
}
return
tlen
;
}
...
...
@@ -41,6 +44,11 @@ static void *tdDecodeTFInfo(void *buf, STFInfo *pInfo) {
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
ftype
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
fver
));
buf
=
taosDecodeFixedI64
(
buf
,
&
(
pInfo
->
fsize
));
// specific
if
(
pInfo
->
ftype
==
TD_FTYPE_RSMA_QTASKINFO
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
(
pInfo
->
qTaskInfo
.
submitVer
));
}
return
buf
;
}
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
eedaeda8
...
...
@@ -154,7 +154,8 @@ static void doMergeMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo *pIter, SArr
static
void
doMergeMemIMemRows
(
TSDBROW
*
pRow
,
TSDBROW
*
piRow
,
STableBlockScanInfo
*
pBlockScanInfo
,
STsdbReader
*
pReader
,
STSRow
**
pTSRow
);
static
int32_t
initDelSkylineIterator
(
STableBlockScanInfo
*
pBlockScanInfo
,
STsdbReader
*
pReader
,
STbData
*
pMemTbData
,
STbData
*
piMemTbData
);
static
STsdb
*
getTsdbByRetentions
(
SVnode
*
pVnode
,
TSKEY
winSKey
,
SRetention
*
retentions
,
const
char
*
idstr
);
static
STsdb
*
getTsdbByRetentions
(
SVnode
*
pVnode
,
TSKEY
winSKey
,
SRetention
*
retentions
,
const
char
*
idstr
,
int8_t
*
pLevel
);
static
SVersionRange
getQueryVerRange
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
int8_t
level
);
static
int32_t
setColumnIdSlotList
(
STsdbReader
*
pReader
,
SSDataBlock
*
pBlock
)
{
SBlockLoadSuppInfo
*
pSupInfo
=
&
pReader
->
suppInfo
;
...
...
@@ -366,6 +367,7 @@ static SSDataBlock* createResBlock(SQueryTableDataCond* pCond, int32_t capacity)
static
int32_t
tsdbReaderCreate
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STsdbReader
**
ppReader
,
const
char
*
idstr
)
{
int32_t
code
=
0
;
int8_t
level
=
0
;
STsdbReader
*
pReader
=
(
STsdbReader
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pReader
));
if
(
pReader
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -374,13 +376,13 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd
initReaderStatus
(
&
pReader
->
status
);
pReader
->
pTsdb
=
getTsdbByRetentions
(
pVnode
,
pCond
->
twindows
[
0
].
skey
,
pVnode
->
config
.
tsdbCfg
.
retentions
,
idstr
);
pReader
->
pTsdb
=
getTsdbByRetentions
(
pVnode
,
pCond
->
twindows
[
0
].
skey
,
pVnode
->
config
.
tsdbCfg
.
retentions
,
idstr
,
&
level
);
pReader
->
suid
=
pCond
->
suid
;
pReader
->
order
=
pCond
->
order
;
pReader
->
capacity
=
4096
;
pReader
->
idStr
=
(
idstr
!=
NULL
)
?
strdup
(
idstr
)
:
NULL
;
pReader
->
verRange
=
(
SVersionRange
)
{.
minVer
=
pCond
->
startVersion
,
.
maxVer
=
10000
}
;
pReader
->
type
=
pCond
->
type
;
pReader
->
verRange
=
getQueryVerRange
(
pVnode
,
pCond
,
level
)
;
pReader
->
type
=
pCond
->
type
;
pReader
->
window
=
updateQueryTimeWindow
(
pVnode
->
pTsdb
,
pCond
->
twindows
);
// todo remove this
...
...
@@ -2379,12 +2381,13 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) {
}
}
STsdb
*
getTsdbByRetentions
(
SVnode
*
pVnode
,
TSKEY
winSKey
,
SRetention
*
retentions
,
const
char
*
idStr
)
{
static
STsdb
*
getTsdbByRetentions
(
SVnode
*
pVnode
,
TSKEY
winSKey
,
SRetention
*
retentions
,
const
char
*
idStr
,
int8_t
*
pLevel
)
{
if
(
VND_IS_RSMA
(
pVnode
))
{
int
level
=
0
;
int
8_t
level
=
0
;
int64_t
now
=
taosGetTimestamp
(
pVnode
->
config
.
tsdbCfg
.
precision
);
for
(
int
i
=
0
;
i
<
TSDB_RETENTION_MAX
;
++
i
)
{
for
(
int
8_t
i
=
0
;
i
<
TSDB_RETENTION_MAX
;
++
i
)
{
SRetention
*
pRetention
=
retentions
+
level
;
if
(
pRetention
->
keep
<=
0
)
{
if
(
level
>
0
)
{
...
...
@@ -2398,16 +2401,19 @@ STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* retentions
++
level
;
}
int32_t
vgId
=
TD_VID
(
pVnode
);
const
char
*
str
=
(
idStr
!=
NULL
)
?
idStr
:
""
;
int32_t
vgId
=
TD_VID
(
pVnode
);
const
char
*
str
=
(
idStr
!=
NULL
)
?
idStr
:
""
;
if
(
level
==
TSDB_RETENTION_L0
)
{
*
pLevel
=
TSDB_RETENTION_L0
;
tsdbDebug
(
"vgId:%d, read handle %p rsma level %d is selected to query %s"
,
vgId
,
TSDB_RETENTION_L0
,
str
);
return
VND_RSMA0
(
pVnode
);
}
else
if
(
level
==
TSDB_RETENTION_L1
)
{
*
pLevel
=
TSDB_RETENTION_L1
;
tsdbDebug
(
"vgId:%d, read handle %p rsma level %d is selected to query %s"
,
vgId
,
TSDB_RETENTION_L1
,
str
);
return
VND_RSMA1
(
pVnode
);
}
else
{
*
pLevel
=
TSDB_RETENTION_L2
;
tsdbDebug
(
"vgId:%d, read handle %p rsma level %d is selected to query %s"
,
vgId
,
TSDB_RETENTION_L2
,
str
);
return
VND_RSMA2
(
pVnode
);
}
...
...
@@ -2416,6 +2422,14 @@ STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* retentions
return
VND_TSDB
(
pVnode
);
}
static
SVersionRange
getQueryVerRange
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
int8_t
level
)
{
if
(
VND_IS_RSMA
(
pVnode
))
{
return
(
SVersionRange
){.
minVer
=
pCond
->
startVersion
,
.
maxVer
=
tdRSmaGetMaxSubmitVer
(
pVnode
->
pSma
,
level
)};
}
return
(
SVersionRange
){.
minVer
=
pCond
->
startVersion
,
.
maxVer
=
pVnode
->
state
.
applied
};
}
// // todo not unref yet, since it is not support multi-group interpolation query
// static UNUSED_FUNC void changeQueryHandleForInterpQuery(STsdbReader* pHandle) {
// // filter the queried time stamp in the first place
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录