Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
073d7b1f
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看板
提交
073d7b1f
编写于
4月 29, 2021
作者:
L
lichuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-3963]tsdbRepo config hot change
上级
645afbf9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
102 addition
and
0 deletion
+102
-0
src/tsdb/inc/tsdbint.h
src/tsdb/inc/tsdbint.h
+5
-0
src/tsdb/src/tsdbCommitQueue.c
src/tsdb/src/tsdbCommitQueue.c
+25
-0
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+72
-0
未找到文件。
src/tsdb/inc/tsdbint.h
浏览文件 @
073d7b1f
...
@@ -71,6 +71,11 @@ struct STsdbRepo {
...
@@ -71,6 +71,11 @@ struct STsdbRepo {
uint8_t
state
;
uint8_t
state
;
STsdbCfg
config
;
STsdbCfg
config
;
STsdbCfg
save_config
;
// save apply config
bool
config_changed
;
// config changed flag
pthread_mutex_t
save_mutex
;
// protect save config
STsdbAppH
appH
;
STsdbAppH
appH
;
STsdbStat
stat
;
STsdbStat
stat
;
STsdbMeta
*
tsdbMeta
;
STsdbMeta
*
tsdbMeta
;
...
...
src/tsdb/src/tsdbCommitQueue.c
浏览文件 @
073d7b1f
...
@@ -112,6 +112,24 @@ int tsdbScheduleCommit(STsdbRepo *pRepo) {
...
@@ -112,6 +112,24 @@ int tsdbScheduleCommit(STsdbRepo *pRepo) {
return
0
;
return
0
;
}
}
static
void
tsdbApplyRepoConfig
(
STsdbRepo
*
pRepo
)
{
pRepo
->
config_changed
=
false
;
STsdbCfg
*
pSaveCfg
=
&
pRepo
->
save_config
;
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
;
tsdbInfo
(
"vgId:%d apply new config: compression(%d), keep(%d,%d,%d), totalBlocks(%d), cacheLastRow(%d), update(%d)"
,
REPO_ID
(
pRepo
),
pSaveCfg
->
compression
,
pSaveCfg
->
keep
,
pSaveCfg
->
keep1
,
pSaveCfg
->
keep2
,
pSaveCfg
->
totalBlocks
,
pSaveCfg
->
cacheLastRow
,
pSaveCfg
->
update
);
}
static
void
*
tsdbLoopCommit
(
void
*
arg
)
{
static
void
*
tsdbLoopCommit
(
void
*
arg
)
{
SCommitQueue
*
pQueue
=
&
tsCommitQueue
;
SCommitQueue
*
pQueue
=
&
tsCommitQueue
;
SListNode
*
pNode
=
NULL
;
SListNode
*
pNode
=
NULL
;
...
@@ -138,6 +156,13 @@ static void *tsdbLoopCommit(void *arg) {
...
@@ -138,6 +156,13 @@ static void *tsdbLoopCommit(void *arg) {
pRepo
=
((
SCommitReq
*
)
pNode
->
data
)
->
pRepo
;
pRepo
=
((
SCommitReq
*
)
pNode
->
data
)
->
pRepo
;
// check if need to apply new config
if
(
pRepo
->
config_changed
)
{
pthread_mutex_lock
(
&
pRepo
->
save_mutex
);
tsdbApplyRepoConfig
(
pRepo
);
pthread_mutex_unlock
(
&
pRepo
->
save_mutex
);
}
tsdbCommitData
(
pRepo
);
tsdbCommitData
(
pRepo
);
listNodeFree
(
pNode
);
listNodeFree
(
pNode
);
}
}
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
073d7b1f
...
@@ -203,6 +203,70 @@ void tsdbReportStat(void *repo, int64_t *totalPoints, int64_t *totalStorage, int
...
@@ -203,6 +203,70 @@ void tsdbReportStat(void *repo, int64_t *totalPoints, int64_t *totalStorage, int
int32_t
tsdbConfigRepo
(
STsdbRepo
*
repo
,
STsdbCfg
*
pCfg
)
{
int32_t
tsdbConfigRepo
(
STsdbRepo
*
repo
,
STsdbCfg
*
pCfg
)
{
// TODO: think about multithread cases
// TODO: think about multithread cases
if
(
tsdbCheckAndSetDefaultCfg
(
pCfg
)
<
0
)
return
-
1
;
STsdbCfg
*
pRCfg
=
&
repo
->
config
;
ASSERT
(
pRCfg
->
tsdbId
==
pCfg
->
tsdbId
);
ASSERT
(
pRCfg
->
cacheBlockSize
==
pCfg
->
cacheBlockSize
);
ASSERT
(
pRCfg
->
daysPerFile
==
pCfg
->
daysPerFile
);
ASSERT
(
pRCfg
->
minRowsPerFileBlock
==
pCfg
->
minRowsPerFileBlock
);
ASSERT
(
pRCfg
->
maxRowsPerFileBlock
==
pCfg
->
maxRowsPerFileBlock
);
ASSERT
(
pRCfg
->
precision
==
pCfg
->
precision
);
bool
configChanged
=
false
;
if
(
pRCfg
->
compression
!=
pCfg
->
compression
)
{
configChanged
=
true
;
}
if
(
pRCfg
->
keep
!=
pCfg
->
keep
)
{
configChanged
=
true
;
}
if
(
pRCfg
->
keep1
!=
pCfg
->
keep1
)
{
configChanged
=
true
;
}
if
(
pRCfg
->
keep2
!=
pCfg
->
keep2
)
{
configChanged
=
true
;
}
if
(
pRCfg
->
cacheLastRow
!=
pCfg
->
cacheLastRow
)
{
configChanged
=
true
;
}
if
(
pRCfg
->
update
!=
pCfg
->
update
)
{
configChanged
=
true
;
}
if
(
!
configChanged
)
{
tsdbError
(
"vgId:%d no config changed"
,
REPO_ID
(
repo
));
}
int
code
=
pthread_mutex_lock
(
&
repo
->
save_mutex
);
if
(
code
!=
0
)
{
tsdbError
(
"vgId:%d failed to lock tsdb save config mutex since %s"
,
REPO_ID
(
repo
),
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
STsdbCfg
*
pSaveCfg
=
&
repo
->
save_config
;
*
pSaveCfg
=
repo
->
config
;
pSaveCfg
->
compression
=
pCfg
->
compression
;
pSaveCfg
->
keep
=
pCfg
->
keep
;
pSaveCfg
->
keep1
=
pCfg
->
keep1
;
pSaveCfg
->
keep2
=
pCfg
->
keep2
;
pSaveCfg
->
cacheLastRow
=
pCfg
->
cacheLastRow
;
pSaveCfg
->
update
=
pCfg
->
update
;
tsdbInfo
(
"vgId:%d old config: compression(%d), keep(%d,%d,%d), cacheLastRow(%d), update(%d)"
,
REPO_ID
(
repo
),
pRCfg
->
compression
,
pRCfg
->
keep
,
pRCfg
->
keep1
,
pRCfg
->
keep2
,
pRCfg
->
cacheLastRow
,
pRCfg
->
update
);
tsdbInfo
(
"vgId:%d new config: compression(%d), keep(%d,%d,%d), cacheLastRow(%d), update(%d)"
,
REPO_ID
(
repo
),
pSaveCfg
->
compression
,
pSaveCfg
->
keep
,
pSaveCfg
->
keep1
,
pSaveCfg
->
keep2
,
pSaveCfg
->
cacheLastRow
,
pSaveCfg
->
update
);
repo
->
config_changed
=
true
;
pthread_mutex_unlock
(
&
repo
->
save_mutex
);
return
0
;
return
0
;
#if 0
#if 0
STsdbRepo *pRepo = (STsdbRepo *)repo;
STsdbRepo *pRepo = (STsdbRepo *)repo;
...
@@ -474,6 +538,14 @@ static STsdbRepo *tsdbNewRepo(STsdbCfg *pCfg, STsdbAppH *pAppH) {
...
@@ -474,6 +538,14 @@ static STsdbRepo *tsdbNewRepo(STsdbCfg *pCfg, STsdbAppH *pAppH) {
return
NULL
;
return
NULL
;
}
}
code
=
pthread_mutex_init
(
&
(
pRepo
->
save_mutex
),
NULL
);
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
tsdbFreeRepo
(
pRepo
);
return
NULL
;
}
pRepo
->
config_changed
=
false
;
code
=
tsem_init
(
&
(
pRepo
->
readyToCommit
),
0
,
1
);
code
=
tsem_init
(
&
(
pRepo
->
readyToCommit
),
0
,
1
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
code
=
errno
;
code
=
errno
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录