Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
deb017fc
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看板
未验证
提交
deb017fc
编写于
9月 12, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
9月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16775 from taosdata/feature/3.0_interval_hash_optimize
enh: sma optimization for query and reboot restore
上级
ce91f705
8403f4ab
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
102 addition
and
108 deletion
+102
-108
source/dnode/vnode/src/inc/sma.h
source/dnode/vnode/src/inc/sma.h
+23
-9
source/dnode/vnode/src/sma/smaCommit.c
source/dnode/vnode/src/sma/smaCommit.c
+35
-30
source/dnode/vnode/src/sma/smaEnv.c
source/dnode/vnode/src/sma/smaEnv.c
+2
-33
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+40
-32
source/dnode/vnode/src/sma/smaTimeRange.c
source/dnode/vnode/src/sma/smaTimeRange.c
+0
-3
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+2
-1
未找到文件。
source/dnode/vnode/src/inc/sma.h
浏览文件 @
deb017fc
...
@@ -113,8 +113,9 @@ struct SRSmaStat {
...
@@ -113,8 +113,9 @@ struct SRSmaStat {
volatile
int64_t
nBufItems
;
// number of items in queue buffer
volatile
int64_t
nBufItems
;
// number of items in queue buffer
SRWLatch
lock
;
// r/w lock for rsma fs(e.g. qtaskinfo)
SRWLatch
lock
;
// r/w lock for rsma fs(e.g. qtaskinfo)
volatile
int32_t
nFetchAll
;
// active number of fetch all
volatile
int32_t
nFetchAll
;
// active number of fetch all
int8_t
triggerStat
;
// shared by fetch tasks
volatile
int8_t
triggerStat
;
// shared by fetch tasks
int8_t
commitStat
;
// 0 not in committing, 1 in committing
volatile
int8_t
commitStat
;
// 0 not in committing, 1 in committing
volatile
int8_t
delFlag
;
// 0 no deleted SRSmaInfo, 1 has deleted SRSmaInfo
SRSmaFS
fs
;
// for recovery/snapshot r/w
SRSmaFS
fs
;
// for recovery/snapshot r/w
SHashObj
*
infoHash
;
// key: suid, value: SRSmaInfo
SHashObj
*
infoHash
;
// key: suid, value: SRSmaInfo
tsem_t
notEmpty
;
// has items in queue buffer
tsem_t
notEmpty
;
// has items in queue buffer
...
@@ -142,7 +143,7 @@ struct SRSmaInfoItem {
...
@@ -142,7 +143,7 @@ struct SRSmaInfoItem {
int8_t
level
:
4
;
int8_t
level
:
4
;
int8_t
fetchLevel
:
4
;
int8_t
fetchLevel
:
4
;
int8_t
triggerStat
;
int8_t
triggerStat
;
uint16_t
nS
kipp
ed
;
uint16_t
nS
cann
ed
;
int32_t
maxDelay
;
// ms
int32_t
maxDelay
;
// ms
tmr_h
tmrId
;
tmr_h
tmrId
;
};
};
...
@@ -196,16 +197,21 @@ typedef enum {
...
@@ -196,16 +197,21 @@ typedef enum {
int32_t
tdCheckAndInitSmaEnv
(
SSma
*
pSma
,
int8_t
smaType
);
int32_t
tdCheckAndInitSmaEnv
(
SSma
*
pSma
,
int8_t
smaType
);
void
tdDestroySmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
tdDestroySmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
*
tdFreeSmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
*
tdFreeSmaEnv
(
SSmaEnv
*
pSmaEnv
);
int32_t
tdRefSmaStat
(
SSma
*
pSma
,
SSmaStat
*
pStat
);
int32_t
tdUnRefSmaStat
(
SSma
*
pSma
,
SSmaStat
*
pStat
);
int32_t
tdLockSma
(
SSma
*
pSma
);
int32_t
tdLockSma
(
SSma
*
pSma
);
int32_t
tdUnLockSma
(
SSma
*
pSma
);
int32_t
tdUnLockSma
(
SSma
*
pSma
);
void
*
tdAcquireSmaRef
(
int32_t
rsetId
,
int64_t
refId
);
void
*
tdAcquireSmaRef
(
int32_t
rsetId
,
int64_t
refId
);
int32_t
tdReleaseSmaRef
(
int32_t
rsetId
,
int64_t
refId
);
int32_t
tdReleaseSmaRef
(
int32_t
rsetId
,
int64_t
refId
);
static
FORCE_INLINE
void
tdRefSmaStat
(
SSma
*
pSma
,
SSmaStat
*
pStat
)
{
int32_t
ref
=
T_REF_INC
(
pStat
);
smaDebug
(
"vgId:%d, ref sma stat:%p, val:%d"
,
SMA_VID
(
pSma
),
pStat
,
ref
);
}
static
FORCE_INLINE
void
tdUnRefSmaStat
(
SSma
*
pSma
,
SSmaStat
*
pStat
)
{
int32_t
ref
=
T_REF_DEC
(
pStat
);
smaDebug
(
"vgId:%d, unref sma stat:%p, val:%d"
,
SMA_VID
(
pSma
),
pStat
,
ref
);
}
// rsma
// rsma
int32_t
tdRefRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pRSmaInfo
);
int32_t
tdUnRefRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pRSmaInfo
);
void
*
tdFreeRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pInfo
,
bool
isDeepFree
);
void
*
tdFreeRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pInfo
,
bool
isDeepFree
);
int32_t
tdRSmaFSOpen
(
SSma
*
pSma
,
int64_t
version
);
int32_t
tdRSmaFSOpen
(
SSma
*
pSma
,
int64_t
version
);
void
tdRSmaFSClose
(
SRSmaFS
*
fs
);
void
tdRSmaFSClose
(
SRSmaFS
*
fs
);
...
@@ -218,9 +224,17 @@ int32_t tdRSmaProcessCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
...
@@ -218,9 +224,17 @@ int32_t tdRSmaProcessCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
int32_t
tdRSmaProcessExecImpl
(
SSma
*
pSma
,
ERsmaExecType
type
);
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
);
int32_t
tdRSmaProcessRestoreImpl
(
SSma
*
pSma
,
int8_t
type
,
int64_t
qtaskFileVer
);
void
tdRSmaQTaskInfoGetFileName
(
int32_t
vid
,
int64_t
version
,
char
*
outputName
);
void
tdRSmaQTaskInfoGetFullName
(
int32_t
vid
,
int64_t
version
,
const
char
*
path
,
char
*
outputName
);
void
tdRSmaQTaskInfoGetFileName
(
int32_t
vid
,
int64_t
version
,
char
*
outputName
);
static
FORCE_INLINE
void
tdRefRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pRSmaInfo
)
{
void
tdRSmaQTaskInfoGetFullName
(
int32_t
vid
,
int64_t
version
,
const
char
*
path
,
char
*
outputName
);
int32_t
ref
=
T_REF_INC
(
pRSmaInfo
);
smaDebug
(
"vgId:%d, ref rsma info:%p, val:%d"
,
SMA_VID
(
pSma
),
pRSmaInfo
,
ref
);
}
static
FORCE_INLINE
void
tdUnRefRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pRSmaInfo
)
{
int32_t
ref
=
T_REF_DEC
(
pRSmaInfo
);
smaDebug
(
"vgId:%d, unref rsma info:%p, val:%d"
,
SMA_VID
(
pSma
),
pRSmaInfo
,
ref
);
}
// smaFileUtil ================
// smaFileUtil ================
...
...
source/dnode/vnode/src/sma/smaCommit.c
浏览文件 @
deb017fc
...
@@ -210,15 +210,18 @@ static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pStat) {
...
@@ -210,15 +210,18 @@ static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pStat) {
}
}
if
(
fsMaxVer
<
committed
)
{
if
(
fsMaxVer
<
committed
)
{
SQTaskFile
qFile
=
{.
nRef
=
1
,
.
padding
=
0
,
.
version
=
committed
,
.
size
=
0
};
tdRSmaQTaskInfoGetFullName
(
TD_VID
(
pVnode
),
committed
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
qTaskInfoFullName
);
if
(
taosArrayPush
(
pFS
->
aQTaskInf
,
&
qFile
)
<
0
)
{
if
(
taosCheckExistFile
(
qTaskInfoFullName
))
{
taosWUnLockLatch
(
RSMA_FS_LOCK
(
pStat
));
SQTaskFile
qFile
=
{.
nRef
=
1
,
.
padding
=
0
,
.
version
=
committed
,
.
size
=
0
};
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
if
(
taosArrayPush
(
pFS
->
aQTaskInf
,
&
qFile
)
<
0
)
{
return
TSDB_CODE_FAILED
;
taosWUnLockLatch
(
RSMA_FS_LOCK
(
pStat
));
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_FAILED
;
}
}
}
}
else
{
}
else
{
smaDebug
(
"vgId:%d, update qinf, no need as committed %"
PRIi64
" not larger than fsMaxVer %"
PRIi64
,
TD_VID
(
pVnode
),
smaDebug
(
"vgId:%d, update qinf, no need as committed %"
PRIi64
" not larger than fsMaxVer %"
PRIi64
,
TD_VID
(
pVnode
),
committed
,
fsMaxVer
);
committed
,
fsMaxVer
);
}
}
taosWUnLockLatch
(
RSMA_FS_LOCK
(
pStat
));
taosWUnLockLatch
(
RSMA_FS_LOCK
(
pStat
));
...
@@ -314,12 +317,12 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
...
@@ -314,12 +317,12 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
if
(
tdRSmaPersistExecImpl
(
pRSmaStat
,
RSMA_INFO_HASH
(
pRSmaStat
))
<
0
)
{
if
(
tdRSmaPersistExecImpl
(
pRSmaStat
,
RSMA_INFO_HASH
(
pRSmaStat
))
<
0
)
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
smaInfo
(
"vgId:%d, rsma commit, operator state commited, TID:%p"
,
SMA_VID
(
pSma
),
(
void
*
)
taosGetSelfPthreadId
());
smaInfo
(
"vgId:%d, rsma commit, operator state commit
t
ed, TID:%p"
,
SMA_VID
(
pSma
),
(
void
*
)
taosGetSelfPthreadId
());
#if 0 // consuming task of qTaskInfo clone
#if 0 // consuming task of qTaskInfo clone
// step 4: swap queue/qall and iQueue/iQall
// step 4: swap queue/qall and iQueue/iQall
// lock
// lock
//
taosWLockLatch(SMA_ENV_LOCK(pEnv));
taosWLockLatch(SMA_ENV_LOCK(pEnv));
ASSERT(RSMA_INFO_HASH(pRSmaStat));
ASSERT(RSMA_INFO_HASH(pRSmaStat));
...
@@ -335,7 +338,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
...
@@ -335,7 +338,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
}
}
// unlock
// unlock
//
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
#endif
#endif
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -380,25 +383,26 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) {
...
@@ -380,25 +383,26 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) {
// step 1: merge qTaskInfo and iQTaskInfo
// step 1: merge qTaskInfo and iQTaskInfo
// lock
// lock
// taosWLockLatch(SMA_ENV_LOCK(pEnv));
if
(
1
==
atomic_val_compare_exchange_8
(
&
pRSmaStat
->
delFlag
,
1
,
0
))
{
taosWLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
void
*
pIter
=
NULL
;
while
((
pIter
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
pIter
)))
{
void
*
pIter
=
NULL
;
tb_uid_t
*
pSuid
=
(
tb_uid_t
*
)
taosHashGetKey
(
pIter
,
NULL
);
while
((
pIter
=
taosHashIterate
(
RSMA_INFO_HASH
(
pRSmaStat
),
pIter
)))
{
SRSmaInfo
*
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pIter
;
tb_uid_t
*
pSuid
=
(
tb_uid_t
*
)
taosHashGetKey
(
pIter
,
NULL
);
if
(
RSMA_INFO_IS_DEL
(
pRSmaInfo
))
{
SRSmaInfo
*
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pIter
;
int32_t
refVal
=
T_REF_VAL_GET
(
pRSmaInfo
);
if
(
RSMA_INFO_IS_DEL
(
pRSmaInfo
))
{
if
(
refVal
==
0
)
{
int32_t
refVal
=
T_REF_VAL_GET
(
pRSmaInfo
);
taosHashRemove
(
RSMA_INFO_HASH
(
pRSmaStat
),
pSuid
,
sizeof
(
*
pSuid
));
if
(
refVal
==
0
)
{
}
else
{
taosHashRemove
(
RSMA_INFO_HASH
(
pRSmaStat
),
pSuid
,
sizeof
(
*
pSuid
));
smaDebug
(
}
else
{
"vgId:%d, rsma async post commit, not free rsma info since ref is %d although already deleted for "
smaDebug
(
"table:%"
PRIi64
,
"vgId:%d, rsma async post commit, not free rsma info since ref is %d although already deleted for "
SMA_VID
(
pSma
),
refVal
,
*
pSuid
);
"table:%"
PRIi64
,
SMA_VID
(
pSma
),
refVal
,
*
pSuid
);
}
continue
;
}
}
continue
;
}
#if 0
#if 0
if (pRSmaInfo->taskInfo[0]) {
if (pRSmaInfo->taskInfo[0]) {
if (pRSmaInfo->iTaskInfo[0]) {
if (pRSmaInfo->iTaskInfo[0]) {
...
@@ -413,10 +417,11 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) {
...
@@ -413,10 +417,11 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) {
taosHashPut(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(tb_uid_t), pIter, sizeof(pIter));
taosHashPut(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(tb_uid_t), pIter, sizeof(pIter));
smaDebug("vgId:%d, rsma async post commit, migrated from iRsmaInfoHash for table:%" PRIi64, SMA_VID(pSma), *pSuid);
smaDebug("vgId:%d, rsma async post commit, migrated from iRsmaInfoHash for table:%" PRIi64, SMA_VID(pSma), *pSuid);
#endif
#endif
}
}
// unlock
// unlock
// taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
taosWUnLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
}
tdUpdateQTaskInfoFiles
(
pSma
,
pRSmaStat
);
tdUpdateQTaskInfoFiles
(
pSma
,
pRSmaStat
);
...
...
source/dnode/vnode/src/sma/smaEnv.c
浏览文件 @
deb017fc
...
@@ -177,39 +177,6 @@ void *tdFreeSmaEnv(SSmaEnv *pSmaEnv) {
...
@@ -177,39 +177,6 @@ void *tdFreeSmaEnv(SSmaEnv *pSmaEnv) {
return
NULL
;
return
NULL
;
}
}
int32_t
tdRefSmaStat
(
SSma
*
pSma
,
SSmaStat
*
pStat
)
{
if
(
!
pStat
)
return
0
;
int
ref
=
T_REF_INC
(
pStat
);
smaDebug
(
"vgId:%d, ref sma stat:%p, val:%d"
,
SMA_VID
(
pSma
),
pStat
,
ref
);
return
0
;
}
int32_t
tdUnRefSmaStat
(
SSma
*
pSma
,
SSmaStat
*
pStat
)
{
if
(
!
pStat
)
return
0
;
int
ref
=
T_REF_DEC
(
pStat
);
smaDebug
(
"vgId:%d, unref sma stat:%p, val:%d"
,
SMA_VID
(
pSma
),
pStat
,
ref
);
return
0
;
}
int32_t
tdRefRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pRSmaInfo
)
{
if
(
!
pRSmaInfo
)
return
0
;
int
ref
=
T_REF_INC
(
pRSmaInfo
);
smaDebug
(
"vgId:%d, ref rsma info:%p, val:%d"
,
SMA_VID
(
pSma
),
pRSmaInfo
,
ref
);
return
0
;
}
int32_t
tdUnRefRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pRSmaInfo
)
{
if
(
!
pRSmaInfo
)
return
0
;
int
ref
=
T_REF_DEC
(
pRSmaInfo
);
smaDebug
(
"vgId:%d, unref rsma info:%p, val:%d"
,
SMA_VID
(
pSma
),
pRSmaInfo
,
ref
);
return
0
;
}
static
void
tRSmaInfoHashFreeNode
(
void
*
data
)
{
static
void
tRSmaInfoHashFreeNode
(
void
*
data
)
{
SRSmaInfo
*
pRSmaInfo
=
NULL
;
SRSmaInfo
*
pRSmaInfo
=
NULL
;
SRSmaInfoItem
*
pItem
=
NULL
;
SRSmaInfoItem
*
pItem
=
NULL
;
...
@@ -492,6 +459,8 @@ static int32_t tdRsmaStopExecutor(const SSma *pSma) {
...
@@ -492,6 +459,8 @@ static int32_t tdRsmaStopExecutor(const SSma *pSma) {
taosThreadJoin
(
pthread
[
i
],
NULL
);
taosThreadJoin
(
pthread
[
i
],
NULL
);
}
}
}
}
smaInfo
(
"vgId:%d, rsma executor stopped, number:%d"
,
SMA_VID
(
pSma
),
tsNumOfVnodeRsmaThreads
);
}
}
return
0
;
return
0
;
}
}
\ No newline at end of file
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
deb017fc
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
#define RSMA_QTASKINFO_HEAD_LEN (sizeof(int32_t) + sizeof(int8_t) + sizeof(int64_t)) // len + type + suid
#define RSMA_QTASKINFO_HEAD_LEN (sizeof(int32_t) + sizeof(int8_t) + sizeof(int64_t)) // len + type + suid
#define RSMA_QTASKEXEC_SMOOTH_SIZE (100) // cnt
#define RSMA_QTASKEXEC_SMOOTH_SIZE (100) // cnt
#define RSMA_SUBMIT_BATCH_SIZE (1024) // cnt
#define RSMA_SUBMIT_BATCH_SIZE (1024) // cnt
#define RSMA_FETCH_DELAY_MAX (
90
0000) // ms
#define RSMA_FETCH_DELAY_MAX (
12
0000) // ms
#define RSMA_FETCH_ACTIVE_MAX (1000) // ms
#define RSMA_FETCH_ACTIVE_MAX (1000) // ms
#define RSMA_FETCH_INTERVAL (5000) // ms
#define RSMA_FETCH_INTERVAL (5000) // ms
...
@@ -302,7 +302,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
...
@@ -302,7 +302,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
SRSmaInfoItem
*
pItem
=
&
(
pRSmaInfo
->
items
[
idx
]);
SRSmaInfoItem
*
pItem
=
&
(
pRSmaInfo
->
items
[
idx
]);
pItem
->
triggerStat
=
TASK_TRIGGER_STAT_
INACTIVE
;
pItem
->
triggerStat
=
TASK_TRIGGER_STAT_
ACTIVE
;
// fetch the data when reboot
if
(
param
->
maxdelay
[
idx
]
<
TSDB_MIN_ROLLUP_MAX_DELAY
)
{
if
(
param
->
maxdelay
[
idx
]
<
TSDB_MIN_ROLLUP_MAX_DELAY
)
{
int64_t
msInterval
=
int64_t
msInterval
=
convertTimeFromPrecisionToUnit
(
pRetention
[
idx
+
1
].
freq
,
pTsdbCfg
->
precision
,
TIME_UNIT_MILLISECOND
);
convertTimeFromPrecisionToUnit
(
pRetention
[
idx
+
1
].
freq
,
pTsdbCfg
->
precision
,
TIME_UNIT_MILLISECOND
);
...
@@ -320,7 +320,9 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
...
@@ -320,7 +320,9 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
SRSmaRef
rsmaRef
=
{.
refId
=
pStat
->
refId
,
.
suid
=
pRSmaInfo
->
suid
};
SRSmaRef
rsmaRef
=
{.
refId
=
pStat
->
refId
,
.
suid
=
pRSmaInfo
->
suid
};
taosHashPut
(
smaMgmt
.
refHash
,
&
pItem
,
POINTER_BYTES
,
&
rsmaRef
,
sizeof
(
rsmaRef
));
taosHashPut
(
smaMgmt
.
refHash
,
&
pItem
,
POINTER_BYTES
,
&
rsmaRef
,
sizeof
(
rsmaRef
));
taosTmrReset
(
tdRSmaFetchTrigger
,
pItem
->
maxDelay
,
pItem
,
smaMgmt
.
tmrHandle
,
&
pItem
->
tmrId
);
pItem
->
fetchLevel
=
pItem
->
level
;
taosTmrReset
(
tdRSmaFetchTrigger
,
RSMA_FETCH_INTERVAL
,
pItem
,
smaMgmt
.
tmrHandle
,
&
pItem
->
tmrId
);
smaInfo
(
"vgId:%d, item:%p table:%"
PRIi64
" level:%"
PRIi8
" maxdelay:%"
PRIi64
" watermark:%"
PRIi64
smaInfo
(
"vgId:%d, item:%p table:%"
PRIi64
" level:%"
PRIi8
" maxdelay:%"
PRIi64
" watermark:%"
PRIi64
", finally maxdelay:%"
PRIi32
,
", finally maxdelay:%"
PRIi32
,
...
@@ -470,6 +472,7 @@ int32_t tdProcessRSmaDrop(SSma *pSma, SVDropStbReq *pReq) {
...
@@ -470,6 +472,7 @@ int32_t tdProcessRSmaDrop(SSma *pSma, SVDropStbReq *pReq) {
}
}
// set del flag for data in mem
// set del flag for data in mem
atomic_store_8
(
&
pRSmaStat
->
delFlag
,
1
);
RSMA_INFO_SET_DEL
(
pRSmaInfo
);
RSMA_INFO_SET_DEL
(
pRSmaInfo
);
tdUnRefRSmaInfo
(
pSma
,
pRSmaInfo
);
tdUnRefRSmaInfo
(
pSma
,
pRSmaInfo
);
...
@@ -939,25 +942,25 @@ static SRSmaInfo *tdAcquireRSmaInfoBySuid(SSma *pSma, int64_t suid) {
...
@@ -939,25 +942,25 @@ static SRSmaInfo *tdAcquireRSmaInfoBySuid(SSma *pSma, int64_t suid) {
return
NULL
;
return
NULL
;
}
}
//
taosRLockLatch(SMA_ENV_LOCK(pEnv));
taosRLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
pRSmaInfo
=
taosHashGet
(
RSMA_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
));
pRSmaInfo
=
taosHashGet
(
RSMA_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
));
if
(
pRSmaInfo
&&
(
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pRSmaInfo
))
{
if
(
pRSmaInfo
&&
(
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pRSmaInfo
))
{
if
(
RSMA_INFO_IS_DEL
(
pRSmaInfo
))
{
if
(
RSMA_INFO_IS_DEL
(
pRSmaInfo
))
{
//
taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
taosRUnLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
return
NULL
;
return
NULL
;
}
}
if
(
!
pRSmaInfo
->
taskInfo
[
0
])
{
if
(
!
pRSmaInfo
->
taskInfo
[
0
])
{
if
(
tdRSmaInfoClone
(
pSma
,
pRSmaInfo
)
<
0
)
{
if
(
tdRSmaInfoClone
(
pSma
,
pRSmaInfo
)
<
0
)
{
//
taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
taosRUnLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
return
NULL
;
return
NULL
;
}
}
}
}
tdRefRSmaInfo
(
pSma
,
pRSmaInfo
);
tdRefRSmaInfo
(
pSma
,
pRSmaInfo
);
//
taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
taosRUnLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
ASSERT
(
pRSmaInfo
->
suid
==
suid
);
ASSERT
(
pRSmaInfo
->
suid
==
suid
);
return
pRSmaInfo
;
return
pRSmaInfo
;
}
}
//
taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
taosRUnLockLatch
(
SMA_ENV_LOCK
(
pEnv
));
return
NULL
;
return
NULL
;
}
}
...
@@ -1709,21 +1712,23 @@ static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo) {
...
@@ -1709,21 +1712,23 @@ static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo) {
continue
;
continue
;
}
}
int64_t
curMs
=
taosGetTimestampMs
();
if
((
++
pItem
->
nScanned
*
pItem
->
maxDelay
)
>
RSMA_FETCH_DELAY_MAX
)
{
if
((
pItem
->
nSkipped
*
pItem
->
maxDelay
)
>
RSMA_FETCH_DELAY_MAX
)
{
smaDebug
(
"vgId:%d, suid:%"
PRIi64
" level:%"
PRIi8
" nScanned:%"
PRIi8
" maxDelay:%d, fetch executed"
,
smaDebug
(
"vgId:%d, suid:%"
PRIi64
" level:%"
PRIi8
" nSkipped:%"
PRIi8
" maxDelay:%d, fetch executed"
,
SMA_VID
(
pSma
),
pInfo
->
suid
,
i
,
pItem
->
nScanned
,
pItem
->
maxDelay
);
SMA_VID
(
pSma
),
pInfo
->
suid
,
i
,
pItem
->
nSkipped
,
pItem
->
maxDelay
);
}
else
if
(((
curMs
-
pInfo
->
lastRecv
)
<
RSMA_FETCH_ACTIVE_MAX
))
{
++
pItem
->
nSkipped
;
smaTrace
(
"vgId:%d, suid:%"
PRIi64
" level:%"
PRIi8
" curMs:%"
PRIi64
" lastRecv:%"
PRIi64
", fetch skipped "
,
SMA_VID
(
pSma
),
pInfo
->
suid
,
i
,
curMs
,
pInfo
->
lastRecv
);
continue
;
}
else
{
}
else
{
smaDebug
(
"vgId:%d, suid:%"
PRIi64
" level:%"
PRIi8
" curMs:%"
PRIi64
" lastRecv:%"
PRIi64
", fetch executed "
,
int64_t
curMs
=
taosGetTimestampMs
();
SMA_VID
(
pSma
),
pInfo
->
suid
,
i
,
curMs
,
pInfo
->
lastRecv
);
if
((
curMs
-
pInfo
->
lastRecv
)
<
RSMA_FETCH_ACTIVE_MAX
)
{
smaTrace
(
"vgId:%d, suid:%"
PRIi64
" level:%"
PRIi8
" curMs:%"
PRIi64
" lastRecv:%"
PRIi64
", fetch skipped "
,
SMA_VID
(
pSma
),
pInfo
->
suid
,
i
,
curMs
,
pInfo
->
lastRecv
);
atomic_store_8
(
&
pItem
->
triggerStat
,
TASK_TRIGGER_STAT_ACTIVE
);
// restore the active stat
continue
;
}
else
{
smaDebug
(
"vgId:%d, suid:%"
PRIi64
" level:%"
PRIi8
" curMs:%"
PRIi64
" lastRecv:%"
PRIi64
", fetch executed "
,
SMA_VID
(
pSma
),
pInfo
->
suid
,
i
,
curMs
,
pInfo
->
lastRecv
);
}
}
}
pItem
->
nS
kipp
ed
=
0
;
pItem
->
nS
cann
ed
=
0
;
if
((
terrno
=
qSetMultiStreamInput
(
taskInfo
,
&
dataBlock
,
1
,
STREAM_INPUT__DATA_BLOCK
))
<
0
)
{
if
((
terrno
=
qSetMultiStreamInput
(
taskInfo
,
&
dataBlock
,
1
,
STREAM_INPUT__DATA_BLOCK
))
<
0
)
{
goto
_err
;
goto
_err
;
...
@@ -1734,12 +1739,12 @@ static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo) {
...
@@ -1734,12 +1739,12 @@ static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo) {
}
}
tdCleanupStreamInputDataBlock
(
taskInfo
);
tdCleanupStreamInputDataBlock
(
taskInfo
);
sma
Info
(
"vgId:%d, suid:%"
PRIi64
" level:%"
PRIi8
" nSkipp
ed:%"
PRIi8
" maxDelay:%d, fetch finished"
,
sma
Debug
(
"vgId:%d, suid:%"
PRIi64
" level:%"
PRIi8
" nScann
ed:%"
PRIi8
" maxDelay:%d, fetch finished"
,
SMA_VID
(
pSma
),
pInfo
->
suid
,
i
,
pItem
->
nSkipp
ed
,
pItem
->
maxDelay
);
SMA_VID
(
pSma
),
pInfo
->
suid
,
i
,
pItem
->
nScann
ed
,
pItem
->
maxDelay
);
}
else
{
}
else
{
smaDebug
(
"vgId:%d, suid:%"
PRIi64
" level:%"
PRIi8
" nS
kipp
ed:%"
PRIi8
smaDebug
(
"vgId:%d, suid:%"
PRIi64
" level:%"
PRIi8
" nS
cann
ed:%"
PRIi8
" maxDelay:%d, fetch not executed as fetch level is %"
PRIi8
,
" maxDelay:%d, fetch not executed as fetch level is %"
PRIi8
,
SMA_VID
(
pSma
),
pInfo
->
suid
,
i
,
pItem
->
nS
kipp
ed
,
pItem
->
maxDelay
,
pItem
->
fetchLevel
);
SMA_VID
(
pSma
),
pInfo
->
suid
,
i
,
pItem
->
nS
cann
ed
,
pItem
->
maxDelay
,
pItem
->
fetchLevel
);
}
}
}
}
...
@@ -1829,6 +1834,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
...
@@ -1829,6 +1834,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
bool
occupied
=
(
batchMax
<=
1
);
bool
occupied
=
(
batchMax
<=
1
);
if
(
batchMax
>
1
)
{
if
(
batchMax
>
1
)
{
batchMax
=
100
/
batchMax
;
batchMax
=
100
/
batchMax
;
batchMax
=
TMAX
(
batchMax
,
4
);
}
}
while
(
occupied
||
(
++
batchCnt
<
batchMax
))
{
// greedy mode
while
(
occupied
||
(
++
batchCnt
<
batchMax
))
{
// greedy mode
taosReadAllQitems
(
pInfo
->
queue
,
pInfo
->
qall
);
// queue has mutex lock
taosReadAllQitems
(
pInfo
->
queue
,
pInfo
->
qall
);
// queue has mutex lock
...
@@ -1838,13 +1844,15 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
...
@@ -1838,13 +1844,15 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
smaDebug
(
"vgId:%d, batchSize:%d, execType:%"
PRIi8
,
SMA_VID
(
pSma
),
qallItemSize
,
type
);
smaDebug
(
"vgId:%d, batchSize:%d, execType:%"
PRIi8
,
SMA_VID
(
pSma
),
qallItemSize
,
type
);
}
}
int8_t
oldStat
=
atomic_val_compare_exchange_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
),
0
,
2
);
if
(
RSMA_INFO_ITEM
(
pInfo
,
0
)
->
fetchLevel
||
RSMA_INFO_ITEM
(
pInfo
,
1
)
->
fetchLevel
)
{
if
(
oldStat
==
0
||
int8_t
oldStat
=
atomic_val_compare_exchange_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
),
0
,
2
);
((
oldStat
==
2
)
&&
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
))
<
TASK_TRIGGER_STAT_PAUSED
))
{
if
(
oldStat
==
0
||
atomic_fetch_add_32
(
&
pRSmaStat
->
nFetchAll
,
1
);
((
oldStat
==
2
)
&&
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
))
<
TASK_TRIGGER_STAT_PAUSED
))
{
tdRSmaFetchAllResult
(
pSma
,
pInfo
);
atomic_fetch_add_32
(
&
pRSmaStat
->
nFetchAll
,
1
);
if
(
0
==
atomic_sub_fetch_32
(
&
pRSmaStat
->
nFetchAll
,
1
))
{
tdRSmaFetchAllResult
(
pSma
,
pInfo
);
atomic_store_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
),
0
);
if
(
0
==
atomic_sub_fetch_32
(
&
pRSmaStat
->
nFetchAll
,
1
))
{
atomic_store_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
),
0
);
}
}
}
}
}
...
@@ -1917,7 +1925,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
...
@@ -1917,7 +1925,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
tsem_wait
(
&
pRSmaStat
->
notEmpty
);
tsem_wait
(
&
pRSmaStat
->
notEmpty
);
if
((
pEnv
->
flag
&
SMA_ENV_FLG_CLOSE
)
&&
(
atomic_load_64
(
&
pRSmaStat
->
nBufItems
)
<=
0
))
{
if
((
pEnv
->
flag
&
SMA_ENV_FLG_CLOSE
)
&&
(
atomic_load_64
(
&
pRSmaStat
->
nBufItems
)
<=
0
))
{
sma
Info
(
"vgId:%d, exec task end, flag:%"
PRIi8
", nBufItems:%"
PRIi64
,
SMA_VID
(
pSma
),
pEnv
->
flag
,
sma
Debug
(
"vgId:%d, exec task end, flag:%"
PRIi8
", nBufItems:%"
PRIi64
,
SMA_VID
(
pSma
),
pEnv
->
flag
,
atomic_load_64
(
&
pRSmaStat
->
nBufItems
));
atomic_load_64
(
&
pRSmaStat
->
nBufItems
));
break
;
break
;
}
}
...
...
source/dnode/vnode/src/sma/smaTimeRange.c
浏览文件 @
deb017fc
...
@@ -178,7 +178,6 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char
...
@@ -178,7 +178,6 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
tdRefSmaStat
(
pSma
,
pStat
);
pTsmaStat
=
SMA_STAT_TSMA
(
pStat
);
pTsmaStat
=
SMA_STAT_TSMA
(
pStat
);
if
(
!
pTsmaStat
->
pTSma
)
{
if
(
!
pTsmaStat
->
pTSma
)
{
...
@@ -230,9 +229,7 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char
...
@@ -230,9 +229,7 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char
goto
_err
;
goto
_err
;
}
}
tdUnRefSmaStat
(
pSma
,
pStat
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_err:
_err:
tdUnRefSmaStat
(
pSma
,
pStat
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
deb017fc
...
@@ -2815,6 +2815,7 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* ret
...
@@ -2815,6 +2815,7 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* ret
if
(
VND_IS_RSMA
(
pVnode
))
{
if
(
VND_IS_RSMA
(
pVnode
))
{
int8_t
level
=
0
;
int8_t
level
=
0
;
int64_t
now
=
taosGetTimestamp
(
pVnode
->
config
.
tsdbCfg
.
precision
);
int64_t
now
=
taosGetTimestamp
(
pVnode
->
config
.
tsdbCfg
.
precision
);
int64_t
offset
=
TSDB_TICK_PER_SECOND
(
pVnode
->
config
.
tsdbCfg
.
precision
);
for
(
int8_t
i
=
0
;
i
<
TSDB_RETENTION_MAX
;
++
i
)
{
for
(
int8_t
i
=
0
;
i
<
TSDB_RETENTION_MAX
;
++
i
)
{
SRetention
*
pRetention
=
retentions
+
level
;
SRetention
*
pRetention
=
retentions
+
level
;
...
@@ -2824,7 +2825,7 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* ret
...
@@ -2824,7 +2825,7 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* ret
}
}
break
;
break
;
}
}
if
((
now
-
pRetention
->
keep
)
<=
winSKey
)
{
if
((
now
-
pRetention
->
keep
)
<=
(
winSKey
+
offset
)
)
{
break
;
break
;
}
}
++
level
;
++
level
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录