Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
王长生-AnH
TDengine
提交
56376f82
T
TDengine
项目概览
王长生-AnH
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
5
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
56376f82
编写于
12月 24, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
12月 24, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4687 from taosdata/feature/TD-2546
feature<TD-2546>: solve insert time spike problem
上级
088cd990
ab9988c1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
13 deletion
+18
-13
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+5
-0
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+13
-13
未找到文件。
src/tsdb/src/tsdbCommit.c
浏览文件 @
56376f82
...
@@ -161,6 +161,11 @@ _err:
...
@@ -161,6 +161,11 @@ _err:
static
void
tsdbEndCommit
(
STsdbRepo
*
pRepo
,
int
eno
)
{
static
void
tsdbEndCommit
(
STsdbRepo
*
pRepo
,
int
eno
)
{
if
(
pRepo
->
appH
.
notifyStatus
)
pRepo
->
appH
.
notifyStatus
(
pRepo
->
appH
.
appH
,
TSDB_STATUS_COMMIT_OVER
,
eno
);
if
(
pRepo
->
appH
.
notifyStatus
)
pRepo
->
appH
.
notifyStatus
(
pRepo
->
appH
.
appH
,
TSDB_STATUS_COMMIT_OVER
,
eno
);
SMemTable
*
pIMem
=
pRepo
->
imem
;
tsdbLockRepo
(
pRepo
);
pRepo
->
imem
=
NULL
;
tsdbUnlockRepo
(
pRepo
);
tsdbUnRefMemTable
(
pRepo
,
pIMem
);
sem_post
(
&
(
pRepo
->
readyToCommit
));
sem_post
(
&
(
pRepo
->
readyToCommit
));
}
}
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
56376f82
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include "tsdbMain.h"
#include "tsdbMain.h"
#define TSDB_DATA_SKIPLIST_LEVEL 5
#define TSDB_DATA_SKIPLIST_LEVEL 5
#define TSDB_MAX_INSERT_BATCH 512
static
SMemTable
*
tsdbNewMemTable
(
STsdbRepo
*
pRepo
);
static
SMemTable
*
tsdbNewMemTable
(
STsdbRepo
*
pRepo
);
static
void
tsdbFreeMemTable
(
SMemTable
*
pMemTable
);
static
void
tsdbFreeMemTable
(
SMemTable
*
pMemTable
);
...
@@ -205,7 +206,7 @@ void *tsdbAllocBytes(STsdbRepo *pRepo, int bytes) {
...
@@ -205,7 +206,7 @@ void *tsdbAllocBytes(STsdbRepo *pRepo, int bytes) {
int
tsdbAsyncCommit
(
STsdbRepo
*
pRepo
)
{
int
tsdbAsyncCommit
(
STsdbRepo
*
pRepo
)
{
if
(
pRepo
->
mem
==
NULL
)
return
0
;
if
(
pRepo
->
mem
==
NULL
)
return
0
;
SMemTable
*
pIMem
=
pRepo
->
imem
;
ASSERT
(
pRepo
->
imem
==
NULL
)
;
sem_wait
(
&
(
pRepo
->
readyToCommit
));
sem_wait
(
&
(
pRepo
->
readyToCommit
));
...
@@ -220,8 +221,6 @@ int tsdbAsyncCommit(STsdbRepo *pRepo) {
...
@@ -220,8 +221,6 @@ int tsdbAsyncCommit(STsdbRepo *pRepo) {
tsdbScheduleCommit
(
pRepo
);
tsdbScheduleCommit
(
pRepo
);
if
(
tsdbUnlockRepo
(
pRepo
)
<
0
)
return
-
1
;
if
(
tsdbUnlockRepo
(
pRepo
)
<
0
)
return
-
1
;
if
(
tsdbUnRefMemTable
(
pRepo
,
pIMem
)
<
0
)
return
-
1
;
return
0
;
return
0
;
}
}
...
@@ -606,19 +605,13 @@ static int tsdbInsertDataToTable(STsdbRepo *pRepo, SSubmitBlk *pBlock, int32_t *
...
@@ -606,19 +605,13 @@ static int tsdbInsertDataToTable(STsdbRepo *pRepo, SSubmitBlk *pBlock, int32_t *
STable
*
pTable
=
NULL
;
STable
*
pTable
=
NULL
;
SSubmitBlkIter
blkIter
=
{
0
};
SSubmitBlkIter
blkIter
=
{
0
};
SDataRow
row
=
NULL
;
SDataRow
row
=
NULL
;
void
*
*
rows
=
NULL
;
void
*
rows
[
TSDB_MAX_INSERT_BATCH
]
=
{
0
}
;
int
rowCounter
=
0
;
int
rowCounter
=
0
;
ASSERT
(
pBlock
->
tid
<
pMeta
->
maxTables
);
ASSERT
(
pBlock
->
tid
<
pMeta
->
maxTables
);
pTable
=
pMeta
->
tables
[
pBlock
->
tid
];
pTable
=
pMeta
->
tables
[
pBlock
->
tid
];
ASSERT
(
pTable
!=
NULL
&&
TABLE_UID
(
pTable
)
==
pBlock
->
uid
);
ASSERT
(
pTable
!=
NULL
&&
TABLE_UID
(
pTable
)
==
pBlock
->
uid
);
rows
=
(
void
**
)
calloc
(
pBlock
->
numOfRows
,
sizeof
(
void
*
));
if
(
rows
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
}
tsdbInitSubmitBlkIter
(
pBlock
,
&
blkIter
);
tsdbInitSubmitBlkIter
(
pBlock
,
&
blkIter
);
while
((
row
=
tsdbGetSubmitBlkNext
(
&
blkIter
))
!=
NULL
)
{
while
((
row
=
tsdbGetSubmitBlkNext
(
&
blkIter
))
!=
NULL
)
{
if
(
tsdbCopyRowToMem
(
pRepo
,
row
,
pTable
,
&
(
rows
[
rowCounter
]))
<
0
)
{
if
(
tsdbCopyRowToMem
(
pRepo
,
row
,
pTable
,
&
(
rows
[
rowCounter
]))
<
0
)
{
...
@@ -632,9 +625,18 @@ static int tsdbInsertDataToTable(STsdbRepo *pRepo, SSubmitBlk *pBlock, int32_t *
...
@@ -632,9 +625,18 @@ static int tsdbInsertDataToTable(STsdbRepo *pRepo, SSubmitBlk *pBlock, int32_t *
if
(
rows
[
rowCounter
]
!=
NULL
)
{
if
(
rows
[
rowCounter
]
!=
NULL
)
{
rowCounter
++
;
rowCounter
++
;
}
}
if
(
rowCounter
==
TSDB_MAX_INSERT_BATCH
)
{
if
(
tsdbInsertDataToTableImpl
(
pRepo
,
pTable
,
rows
,
rowCounter
)
<
0
)
{
goto
_err
;
}
rowCounter
=
0
;
memset
(
rows
,
0
,
sizeof
(
rows
));
}
}
}
if
(
tsdbInsertDataToTableImpl
(
pRepo
,
pTable
,
rows
,
rowCounter
)
<
0
)
{
if
(
rowCounter
>
0
&&
tsdbInsertDataToTableImpl
(
pRepo
,
pTable
,
rows
,
rowCounter
)
<
0
)
{
goto
_err
;
goto
_err
;
}
}
...
@@ -642,11 +644,9 @@ static int tsdbInsertDataToTable(STsdbRepo *pRepo, SSubmitBlk *pBlock, int32_t *
...
@@ -642,11 +644,9 @@ static int tsdbInsertDataToTable(STsdbRepo *pRepo, SSubmitBlk *pBlock, int32_t *
pRepo
->
stat
.
pointsWritten
+=
points
*
schemaNCols
(
pSchema
);
pRepo
->
stat
.
pointsWritten
+=
points
*
schemaNCols
(
pSchema
);
pRepo
->
stat
.
totalStorage
+=
points
*
schemaVLen
(
pSchema
);
pRepo
->
stat
.
totalStorage
+=
points
*
schemaVLen
(
pSchema
);
free
(
rows
);
return
0
;
return
0
;
_err:
_err:
free
(
rows
);
return
-
1
;
return
-
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录