Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
344aff20
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
344aff20
编写于
5月 07, 2021
作者:
L
lichuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-3963]change totalBlocks config
上级
968917f3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
76 addition
and
17 deletion
+76
-17
src/tsdb/inc/tsdbBuffer.h
src/tsdb/inc/tsdbBuffer.h
+4
-1
src/tsdb/src/tsdbBuffer.c
src/tsdb/src/tsdbBuffer.c
+40
-1
src/tsdb/src/tsdbCommitQueue.c
src/tsdb/src/tsdbCommitQueue.c
+7
-3
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+8
-4
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+17
-8
未找到文件。
src/tsdb/inc/tsdbBuffer.h
浏览文件 @
344aff20
...
...
@@ -28,8 +28,9 @@ typedef struct {
int
bufBlockSize
;
int
tBufBlocks
;
int
nBufBlocks
;
int
nRecycleBlocks
;
int64_t
index
;
SList
*
bufBlockList
;
SList
*
bufBlockList
;
}
STsdbBufPool
;
#define TSDB_BUFFER_RESERVE 1024 // Reseve 1K as commit threshold
...
...
@@ -39,5 +40,7 @@ void tsdbFreeBufPool(STsdbBufPool* pBufPool);
int
tsdbOpenBufPool
(
STsdbRepo
*
pRepo
);
void
tsdbCloseBufPool
(
STsdbRepo
*
pRepo
);
SListNode
*
tsdbAllocBufBlockFromPool
(
STsdbRepo
*
pRepo
);
void
tsdbExpendPool
(
STsdbRepo
*
pRepo
,
int32_t
oldTotalBlocks
);
void
tsdbRecycleBufferBlock
(
STsdbBufPool
*
pPool
,
SListNode
*
pNode
);
#endif
/* _TD_TSDB_BUFFER_H_ */
\ No newline at end of file
src/tsdb/src/tsdbBuffer.c
浏览文件 @
344aff20
...
...
@@ -70,6 +70,7 @@ int tsdbOpenBufPool(STsdbRepo *pRepo) {
pPool
->
tBufBlocks
=
pCfg
->
totalBlocks
;
pPool
->
nBufBlocks
=
0
;
pPool
->
index
=
0
;
pPool
->
nRecycleBlocks
=
0
;
for
(
int
i
=
0
;
i
<
pCfg
->
totalBlocks
;
i
++
)
{
STsdbBufBlock
*
pBufBlock
=
tsdbNewBufBlock
(
pPool
->
bufBlockSize
);
...
...
@@ -156,4 +157,42 @@ _err:
return
NULL
;
}
static
void
tsdbFreeBufBlock
(
STsdbBufBlock
*
pBufBlock
)
{
tfree
(
pBufBlock
);
}
\ No newline at end of file
static
void
tsdbFreeBufBlock
(
STsdbBufBlock
*
pBufBlock
)
{
tfree
(
pBufBlock
);
}
void
tsdbExpendPool
(
STsdbRepo
*
pRepo
,
int32_t
oldTotalBlocks
)
{
if
(
oldTotalBlocks
==
pRepo
->
config
.
totalBlocks
)
{
return
;
}
if
(
tsdbLockRepo
(
pRepo
)
<
0
)
return
;
STsdbBufPool
*
pPool
=
pRepo
->
pPool
;
if
(
pRepo
->
config
.
totalBlocks
>
oldTotalBlocks
)
{
for
(
int
i
=
0
;
i
<
pRepo
->
config
.
totalBlocks
-
oldTotalBlocks
;
i
++
)
{
STsdbBufBlock
*
pBufBlock
=
tsdbNewBufBlock
(
pPool
->
bufBlockSize
);
if
(
pBufBlock
==
NULL
)
goto
err
;
if
(
tdListAppend
(
pPool
->
bufBlockList
,
(
void
*
)(
&
pBufBlock
))
<
0
)
{
tsdbFreeBufBlock
(
pBufBlock
);
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
err
;
}
pPool
->
nBufBlocks
++
;
}
pthread_cond_signal
(
&
pPool
->
poolNotEmpty
);
}
else
{
pPool
->
nRecycleBlocks
=
oldTotalBlocks
-
pRepo
->
config
.
totalBlocks
;
}
err:
tsdbUnlockRepo
(
pRepo
);
}
void
tsdbRecycleBufferBlock
(
STsdbBufPool
*
pPool
,
SListNode
*
pNode
)
{
STsdbBufBlock
*
pBufBlock
=
NULL
;
tdListNodeGetData
(
pPool
->
bufBlockList
,
pNode
,
(
void
*
)(
&
pBufBlock
));
tsdbFreeBufBlock
(
pBufBlock
);
free
(
pNode
);
pPool
->
nBufBlocks
--
;
}
\ No newline at end of file
src/tsdb/src/tsdbCommitQueue.c
浏览文件 @
344aff20
...
...
@@ -116,17 +116,21 @@ static void tsdbApplyRepoConfig(STsdbRepo *pRepo) {
pRepo
->
config_changed
=
false
;
STsdbCfg
*
pSaveCfg
=
&
pRepo
->
save_config
;
int32_t
oldTotalBlocks
=
pRepo
->
config
.
totalBlocks
;
pRepo
->
config
.
compression
=
pRepo
->
save_config
.
compression
;
pRepo
->
config
.
keep
=
pRepo
->
save_config
.
keep
;
pRepo
->
config
.
keep1
=
pRepo
->
save_config
.
keep1
;
pRepo
->
config
.
keep2
=
pRepo
->
save_config
.
keep2
;
pRepo
->
config
.
cacheLastRow
=
pRepo
->
save_config
.
cacheLastRow
;
//pRepo->config.update = pRepo->save_config.update
;
pRepo
->
config
.
totalBlocks
=
pRepo
->
save_config
.
totalBlocks
;
tsdbInfo
(
"vgId:%d apply new config: compression(%d), keep(%d,%d,%d), totalBlocks(%d), cacheLastRow(%d)"
,
tsdbInfo
(
"vgId:%d apply new config: compression(%d), keep(%d,%d,%d), totalBlocks(%d), cacheLastRow(%d)
,totalBlocks(%d)
"
,
REPO_ID
(
pRepo
),
pSaveCfg
->
compression
,
pSaveCfg
->
keep
,
pSaveCfg
->
keep1
,
pSaveCfg
->
keep2
,
pSaveCfg
->
totalBlocks
,
pSaveCfg
->
cacheLastRow
);
pSaveCfg
->
totalBlocks
,
pSaveCfg
->
cacheLastRow
,
pSaveCfg
->
totalBlocks
);
tsdbExpendPool
(
pRepo
,
oldTotalBlocks
);
}
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
344aff20
...
...
@@ -230,6 +230,9 @@ int32_t tsdbConfigRepo(STsdbRepo *repo, STsdbCfg *pCfg) {
if
(
pRCfg
->
cacheLastRow
!=
pCfg
->
cacheLastRow
)
{
configChanged
=
true
;
}
if
(
pRCfg
->
totalBlocks
!=
pCfg
->
totalBlocks
)
{
configChanged
=
true
;
}
if
(
!
configChanged
)
{
tsdbError
(
"vgId:%d no config changed"
,
REPO_ID
(
repo
));
...
...
@@ -250,15 +253,16 @@ int32_t tsdbConfigRepo(STsdbRepo *repo, STsdbCfg *pCfg) {
pSaveCfg
->
keep1
=
pCfg
->
keep1
;
pSaveCfg
->
keep2
=
pCfg
->
keep2
;
pSaveCfg
->
cacheLastRow
=
pCfg
->
cacheLastRow
;
pSaveCfg
->
totalBlocks
=
pCfg
->
totalBlocks
;
tsdbInfo
(
"vgId:%d old config: compression(%d), keep(%d,%d,%d), cacheLastRow(%d)"
,
tsdbInfo
(
"vgId:%d old config: compression(%d), keep(%d,%d,%d), cacheLastRow(%d)
,totalBlocks(%d)
"
,
REPO_ID
(
repo
),
pRCfg
->
compression
,
pRCfg
->
keep
,
pRCfg
->
keep1
,
pRCfg
->
keep2
,
pRCfg
->
cacheLastRow
);
tsdbInfo
(
"vgId:%d new config: compression(%d), keep(%d,%d,%d), cacheLastRow(%d)"
,
pRCfg
->
cacheLastRow
,
pRCfg
->
totalBlocks
);
tsdbInfo
(
"vgId:%d new config: compression(%d), keep(%d,%d,%d), cacheLastRow(%d)
,totalBlocks(%d)
"
,
REPO_ID
(
repo
),
pSaveCfg
->
compression
,
pSaveCfg
->
keep
,
pSaveCfg
->
keep1
,
pSaveCfg
->
keep2
,
pSaveCfg
->
cacheLastRow
);
pSaveCfg
->
cacheLastRow
,
pSaveCfg
->
totalBlocks
);
repo
->
config_changed
=
true
;
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
344aff20
...
...
@@ -98,17 +98,26 @@ int tsdbUnRefMemTable(STsdbRepo *pRepo, SMemTable *pMemTable) {
STsdbBufPool
*
pBufPool
=
pRepo
->
pPool
;
SListNode
*
pNode
=
NULL
;
bool
recycleBlocks
=
pBufPool
->
nRecycleBlocks
>
0
;
if
(
tsdbLockRepo
(
pRepo
)
<
0
)
return
-
1
;
while
((
pNode
=
tdListPopHead
(
pMemTable
->
bufBlockList
))
!=
NULL
)
{
tdListAppendNode
(
pBufPool
->
bufBlockList
,
pNode
);
}
int
code
=
pthread_cond_signal
(
&
pBufPool
->
poolNotEmpty
);
if
(
code
!=
0
)
{
if
(
tsdbUnlockRepo
(
pRepo
)
<
0
)
return
-
1
;
tsdbError
(
"vgId:%d failed to signal pool not empty since %s"
,
REPO_ID
(
pRepo
),
strerror
(
code
));
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
if
(
pBufPool
->
nRecycleBlocks
>
0
)
{
tsdbRecycleBufferBlock
(
pBufPool
,
pNode
);
pBufPool
->
nRecycleBlocks
-=
1
;
}
else
{
tdListAppendNode
(
pBufPool
->
bufBlockList
,
pNode
);
}
}
if
(
!
recycleBlocks
)
{
int
code
=
pthread_cond_signal
(
&
pBufPool
->
poolNotEmpty
);
if
(
code
!=
0
)
{
if
(
tsdbUnlockRepo
(
pRepo
)
<
0
)
return
-
1
;
tsdbError
(
"vgId:%d failed to signal pool not empty since %s"
,
REPO_ID
(
pRepo
),
strerror
(
code
));
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
}
if
(
tsdbUnlockRepo
(
pRepo
)
<
0
)
return
-
1
;
for
(
int
i
=
0
;
i
<
pMemTable
->
maxTables
;
i
++
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录