Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ed2b3678
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看板
提交
ed2b3678
编写于
9月 23, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(tsdb): migrate support speed limit
上级
797b9376
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
51 addition
and
7 deletion
+51
-7
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+1
-1
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+2
-0
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+47
-5
source/dnode/vnode/src/tsdb/tsdbRetention2.c
source/dnode/vnode/src/tsdb/tsdbRetention2.c
+1
-1
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
ed2b3678
...
...
@@ -265,7 +265,7 @@ int32_t tsdbWriteSttBlk(SDataFWriter *pWriter, SArray *aSttBlk);
int32_t
tsdbWriteBlockData
(
SDataFWriter
*
pWriter
,
SBlockData
*
pBlockData
,
SBlockInfo
*
pBlkInfo
,
SSmaInfo
*
pSmaInfo
,
int8_t
cmprAlg
,
int8_t
toLast
);
int32_t
tsdbDFileSetCopy
(
STsdb
*
pTsdb
,
SDFileSet
*
pSetFrom
,
SDFileSet
*
pSetTo
);
int32_t
tsdbDFileSetCopy
(
STsdb
*
pTsdb
,
SDFileSet
*
pSetFrom
,
SDFileSet
*
pSetTo
,
int32_t
maxSpeed
);
// SDataFReader
int32_t
tsdbDataFReaderOpen
(
SDataFReader
**
ppReader
,
STsdb
*
pTsdb
,
SDFileSet
*
pSet
);
int32_t
tsdbDataFReaderClose
(
SDataFReader
**
ppReader
);
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
ed2b3678
...
...
@@ -763,6 +763,7 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
_wait_retention_end:
while
(
atomic_load_32
(
&
pTsdb
->
trimHdl
.
maxRetentFid
)
>=
minCommitFid
)
{
atomic_val_compare_exchange_8
(
&
pTsdb
->
trimHdl
.
limitSpeed
,
1
,
0
);
if
(
++
nLoops
>
1000
)
{
nLoops
=
0
;
sched_yield
();
...
...
@@ -778,6 +779,7 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
}
else
{
goto
_wait_retention_end
;
}
atomic_store_8
(
&
pTsdb
->
trimHdl
.
limitSpeed
,
1
);
}
code
=
tsdbFSCopy
(
pTsdb
,
&
pCommitter
->
fs
);
...
...
source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
浏览文件 @
ed2b3678
...
...
@@ -607,7 +607,43 @@ _err:
return
code
;
}
int32_t
tsdbDFileSetCopy
(
STsdb
*
pTsdb
,
SDFileSet
*
pSetFrom
,
SDFileSet
*
pSetTo
)
{
/**
* @brief send file with limited speed(rough control)
*
* @param pFileOut
* @param pFileIn
* @param size
* @param speed 0 no limit, unit: B/s
* @return int64_t
*/
static
int64_t
tsdbFSendFile
(
TdFilePtr
pOutFD
,
TdFilePtr
pInFD
,
int64_t
size
,
int32_t
speed
)
{
if
(
speed
<=
0
)
{
return
taosFSendFile
(
pOutFD
,
pInFD
,
0
,
size
);
}
int64_t
offset
=
0
;
int64_t
nBytes
=
0
;
int64_t
startMs
=
0
;
int64_t
endMs
=
0
;
int64_t
cost
=
0
;
while
((
offset
+
speed
)
<
size
)
{
startMs
=
taosGetTimestampMs
();
nBytes
+=
taosFSendFile
(
pOutFD
,
pInFD
,
&
offset
,
speed
);
cost
=
taosGetTimestampMs
()
-
startMs
;
if
(
cost
<
0
)
{
taosMsleep
(
1000
);
}
else
if
(
cost
<
1000
)
{
taosMsleep
(
1000
-
cost
);
}
}
if
(
offset
<
size
)
{
nBytes
+=
taosFSendFile
(
pOutFD
,
pInFD
,
&
offset
,
size
-
offset
);
}
return
nBytes
;
}
int32_t
tsdbDFileSetCopy
(
STsdb
*
pTsdb
,
SDFileSet
*
pSetFrom
,
SDFileSet
*
pSetTo
,
int32_t
maxSpeed
)
{
int32_t
code
=
0
;
int64_t
n
;
int64_t
size
;
...
...
@@ -616,6 +652,12 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
int32_t
szPage
=
pTsdb
->
pVnode
->
config
.
szPage
;
char
fNameFrom
[
TSDB_FILENAME_LEN
];
char
fNameTo
[
TSDB_FILENAME_LEN
];
int32_t
speed
=
0
;
if
(
atomic_load_8
(
&
pTsdb
->
trimHdl
.
limitSpeed
))
{
ASSERT
(
maxSpeed
>
0
);
speed
=
maxSpeed
;
}
// head
tsdbHeadFileName
(
pTsdb
,
pSetFrom
->
diskId
,
pSetFrom
->
fid
,
pSetFrom
->
pHeadF
,
fNameFrom
);
...
...
@@ -630,7 +672,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
n
=
t
aosFSendFile
(
pOutFD
,
PInFD
,
0
,
tsdbLogicToFileSize
(
pSetFrom
->
pHeadF
->
size
,
szPage
)
);
n
=
t
sdbFSendFile
(
pOutFD
,
PInFD
,
tsdbLogicToFileSize
(
pSetFrom
->
pHeadF
->
size
,
szPage
),
speed
);
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
...
...
@@ -651,7 +693,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
n
=
t
aosFSendFile
(
pOutFD
,
PInFD
,
0
,
LOGIC_TO_FILE_OFFSET
(
pSetFrom
->
pDataF
->
size
,
szPage
)
);
n
=
t
sdbFSendFile
(
pOutFD
,
PInFD
,
LOGIC_TO_FILE_OFFSET
(
pSetFrom
->
pDataF
->
size
,
szPage
),
speed
);
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
...
...
@@ -672,7 +714,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
n
=
t
aosFSendFile
(
pOutFD
,
PInFD
,
0
,
tsdbLogicToFileSize
(
pSetFrom
->
pSmaF
->
size
,
szPage
)
);
n
=
t
sdbFSendFile
(
pOutFD
,
PInFD
,
tsdbLogicToFileSize
(
pSetFrom
->
pSmaF
->
size
,
szPage
),
speed
);
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
...
...
@@ -694,7 +736,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
}
n
=
t
aosFSendFile
(
pOutFD
,
PInFD
,
0
,
tsdbLogicToFileSize
(
pSetFrom
->
aSttF
[
iStt
]
->
size
,
szPage
)
);
n
=
t
sdbFSendFile
(
pOutFD
,
PInFD
,
tsdbLogicToFileSize
(
pSetFrom
->
aSttF
[
iStt
]
->
size
,
szPage
),
speed
);
if
(
n
<
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
goto
_err
;
...
...
source/dnode/vnode/src/tsdb/tsdbRetention2.c
浏览文件 @
ed2b3678
...
...
@@ -245,7 +245,7 @@ _wait_commit_end:
SDFileSet
fSet
=
*
pSet
;
fSet
.
diskId
=
did
;
code
=
tsdbDFileSetCopy
(
pTsdb
,
pSet
,
&
fSet
);
code
=
tsdbDFileSetCopy
(
pTsdb
,
pSet
,
&
fSet
,
maxSpeed
);
if
(
code
)
goto
_exit
;
code
=
tsdbFSUpsertFSet
(
&
fs
,
&
fSet
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录