Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
7aa1ea29
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看板
提交
7aa1ea29
编写于
6月 13, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-353
上级
21a5beab
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
34 deletion
+30
-34
src/tsdb/src/tsdbBuffer.c
src/tsdb/src/tsdbBuffer.c
+0
-2
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+30
-32
未找到文件。
src/tsdb/src/tsdbBuffer.c
浏览文件 @
7aa1ea29
...
...
@@ -123,8 +123,6 @@ SListNode *tsdbAllocBufBlockFromPool(STsdbRepo *pRepo) {
pthread_cond_wait
(
&
(
pBufPool
->
poolNotEmpty
),
&
(
pRepo
->
mutex
));
}
ASSERT
(
!
POOL_IS_EMPTY
(
pBufPool
));
SListNode
*
pNode
=
tdListPopHead
(
pBufPool
->
bufBlockList
);
STsdbBufBlock
*
pBufBlock
=
NULL
;
tdListNodeGetData
(
pBufPool
->
bufBlockList
,
pNode
,
(
void
*
)(
&
pBufBlock
));
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
7aa1ea29
...
...
@@ -97,7 +97,6 @@ int tsdbRefMemTable(STsdbRepo *pRepo, SMemTable *pMemTable) {
// Need to lock the repository
int
tsdbUnRefMemTable
(
STsdbRepo
*
pRepo
,
SMemTable
*
pMemTable
)
{
ASSERT
(
IS_REPO_LOCKED
(
pRepo
));
ASSERT
(
pMemTable
!=
NULL
);
if
(
T_REF_DEC
(
pMemTable
)
==
0
)
{
...
...
@@ -105,12 +104,15 @@ int tsdbUnRefMemTable(STsdbRepo *pRepo, SMemTable *pMemTable) {
STsdbBufPool
*
pBufPool
=
pRepo
->
pPool
;
SListNode
*
pNode
=
NULL
;
// TODO: check the correctness of this code part
if
(
tsdbLockRepo
(
pRepo
)
<
0
)
return
-
1
;
while
((
pNode
=
tdListPopHead
(
pMemTable
->
bufBlockList
))
!=
NULL
)
{
tdListAppendNode
(
pBufPool
->
bufBlockList
,
pNode
);
if
(
pthread_cond_signal
(
&
pBufPool
->
poolNotEmpty
)
!=
0
)
{
// TODO
}
}
if
(
tsdbUnlockRepo
(
pRepo
)
<
0
)
return
-
1
;
for
(
int
i
=
0
;
i
<
pCfg
->
maxTables
;
i
++
)
{
if
(
pMemTable
->
tData
[
i
]
!=
NULL
)
{
...
...
@@ -127,7 +129,8 @@ int tsdbUnRefMemTable(STsdbRepo *pRepo, SMemTable *pMemTable) {
// ---------------- LOCAL FUNCTIONS ----------------
static
FORCE_INLINE
STsdbBufBlock
*
tsdbGetCurrBufBlock
(
STsdbRepo
*
pRepo
)
{
if
(
pRepo
==
NULL
||
pRepo
->
mem
==
NULL
)
return
NULL
;
ASSERT
(
pRepo
!=
NULL
);
if
(
pRepo
->
mem
==
NULL
)
return
NULL
;
SListNode
*
pNode
=
listTail
(
pRepo
->
mem
);
if
(
pNode
==
NULL
)
return
NULL
;
...
...
@@ -141,45 +144,40 @@ static FORCE_INLINE STsdbBufBlock *tsdbGetCurrBufBlock(STsdbRepo *pRepo) {
static
void
*
tsdbAllocBytes
(
STsdbRepo
*
pRepo
,
int
bytes
)
{
STsdbCfg
*
pCfg
=
&
pRepo
->
config
;
STsdbBufBlock
*
pBufBlock
=
tsdbGetCurrBufBlock
(
pRepo
);
int
code
=
0
;
if
(
pBufBlock
!=
NULL
&&
pBufBlock
->
remain
<
bytes
)
{
if
(
listNEles
(
pRepo
->
mem
)
>=
pCfg
->
totalBlocks
/
2
)
{
// need to trigger commit
if
(
pRepo
->
imem
!=
NULL
)
{
if
(
pRepo
->
commit
)
pthread_join
(
pRepo
->
commitThread
,
NULL
);
ASSERT
(
pRepo
->
commit
==
0
);
SMemTable
*
pIMem
=
pRepo
->
imem
;
if
(
tsdbLockRepo
(
pRepo
)
<
0
)
{
// TODO
return
NULL
;
}
pRepo
->
imem
=
pRepo
->
mem
;
pRepo
->
mem
=
NULL
;
pRepo
->
commit
=
1
;
if
(
pthread_create
(
&
pRepo
->
commitThread
,
NULL
,
tsdbCommitData
,
(
void
*
)
pRepo
)
!=
0
)
{
// TODO
tsdbUnlockRepo
(
pRepo
);
return
NULL
;
}
if
(
tsdbUnlockRepo
(
pRepo
)
<
0
)
{
// TODO
if
(
listNEles
(
pRepo
->
mem
)
>=
pCfg
->
totalBlocks
/
2
)
{
// need to commit mem
if
(
pRepo
->
imem
)
{
code
=
pthread_join
(
pRepo
->
commitThread
,
NULL
);
if
(
code
!=
0
)
{
tsdbError
(
"vgId:%d failed to thread join since %s"
,
REPO_ID
(
pRepo
),
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
NULL
;
}
tsdbUnRefMemTable
(
pRepo
,
pIMem
);
}
}
else
{
if
(
tsdbLockRepo
(
pRepo
)
<
0
)
{
tsdbFreeMemTable
(
pMemTable
);
ASSERT
(
pRepo
->
commit
==
0
);
SMemTable
*
pImem
=
pRepo
->
imem
;
if
(
tsdbLockRepo
(
pRepo
)
<
0
)
return
NULL
;
pRepo
->
imem
=
pRepo
->
mem
;
pRepo
->
mem
=
NULL
;
pRepo
->
commit
=
1
;
code
=
pthread_create
(
&
pRepo
->
commitThread
,
NULL
,
tsdbCommitData
,
(
void
*
)
pRepo
);
if
(
code
!=
0
)
{
tsdbError
(
"vgId:%d failed to create commit thread since %s"
,
REPO_ID
(
pRepo
),
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
tsdbUnlockRepo
(
pRepo
);
return
NULL
;
}
if
(
tsdbUnlockRepo
(
pRepo
)
<
0
)
return
NULL
;
if
(
pImem
&&
tsdbUnRefMemTable
(
pRepo
,
pImem
)
<
0
)
return
NULL
;
}
else
{
if
(
tsdbLockRepo
(
pRepo
)
<
0
)
return
NULL
;
SListNode
*
pNode
=
tsdbAllocBufBlockFromPool
(
pRepo
);
tdListAppendNode
(
pMemTable
->
bufBlockList
,
pNode
);
pRepo
->
mem
=
pMemTable
;
tdListAppendNode
(
pRepo
->
mem
->
bufBlockList
,
pNode
);
if
(
tsdbUnlockRepo
(
pRepo
)
<
0
)
return
NULL
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录