Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
15974edf
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看板
“003864f9027c9b69c497b60f13394fe721ee90bf”上不存在“source/dnode/mgmt/mm/mmInt.c”
提交
15974edf
编写于
10月 11, 2020
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
e27b797f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
64 addition
and
35 deletion
+64
-35
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+64
-35
未找到文件。
src/tsdb/src/tsdbCommit.c
浏览文件 @
15974edf
...
@@ -61,8 +61,6 @@ int tsdbCommitData(STsdbRepo *pRepo) {
...
@@ -61,8 +61,6 @@ int tsdbCommitData(STsdbRepo *pRepo) {
if
(
tsdbCommitMetaData
(
pCommitH
)
<
0
)
goto
_err
;
if
(
tsdbCommitMetaData
(
pCommitH
)
<
0
)
goto
_err
;
if
(
tsdbApplyRetention
(
pCommitH
)
<
0
)
goto
_err
;
tsdbEndCommit
(
pCommitH
,
false
);
tsdbEndCommit
(
pCommitH
,
false
);
return
0
;
return
0
;
...
@@ -80,7 +78,7 @@ static int tsdbStartCommit(SCommitHandle *pCommitH) {
...
@@ -80,7 +78,7 @@ static int tsdbStartCommit(SCommitHandle *pCommitH) {
tsdbInfo
(
"vgId:%d start to commit! keyFirst %"
PRId64
" keyLast %"
PRId64
" numOfRows %"
PRId64
,
REPO_ID
(
pRepo
),
tsdbInfo
(
"vgId:%d start to commit! keyFirst %"
PRId64
" keyLast %"
PRId64
" numOfRows %"
PRId64
,
REPO_ID
(
pRepo
),
pMem
->
keyFirst
,
pMem
->
keyLast
,
pMem
->
numOfRows
);
pMem
->
keyFirst
,
pMem
->
keyLast
,
pMem
->
numOfRows
);
pCommitH
->
pModLog
=
tdListNew
(
sizeof
(
void
*
)
);
pCommitH
->
pModLog
=
tdListNew
(
0
);
if
(
pCommitH
->
pModLog
==
NULL
)
{
if
(
pCommitH
->
pModLog
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
...
@@ -119,11 +117,10 @@ static void tsdbEndCommit(SCommitHandle *pCommitH, bool hasError) {
...
@@ -119,11 +117,10 @@ static void tsdbEndCommit(SCommitHandle *pCommitH, bool hasError) {
SListNode
*
pNode
=
NULL
;
SListNode
*
pNode
=
NULL
;
while
((
pNode
=
tdListPopHead
(
pCommitH
->
pModLog
))
!=
NULL
)
{
while
((
pNode
=
tdListPopHead
(
pCommitH
->
pModLog
))
!=
NULL
)
{
STsdbFileChange
*
pChange
=
(
STsdbFileChange
*
)
(
*
(
void
**
)
pNode
->
data
)
;
STsdbFileChange
*
pChange
=
(
STsdbFileChange
*
)
pNode
->
data
;
tsdbApplyFileChange
(
pChange
,
!
hasError
);
tsdbApplyFileChange
(
pChange
,
!
hasError
);
free
(
pNode
);
free
(
pNode
);
free
(
pChange
);
}
}
close
(
pCommitH
->
fd
);
close
(
pCommitH
->
fd
);
...
@@ -141,22 +138,7 @@ static int tsdbCommitTimeSeriesData(SCommitHandle *pCommitH) {
...
@@ -141,22 +138,7 @@ static int tsdbCommitTimeSeriesData(SCommitHandle *pCommitH) {
STsdbFileH
*
pFileH
=
pRepo
->
tsdbFileH
;
STsdbFileH
*
pFileH
=
pRepo
->
tsdbFileH
;
int
mfid
=
tsdbGetCurrMinFid
(
pCfg
->
precision
,
pCfg
->
keep
,
pCfg
->
daysPerFile
);
int
mfid
=
tsdbGetCurrMinFid
(
pCfg
->
precision
,
pCfg
->
keep
,
pCfg
->
daysPerFile
);
for
(
int
i
=
0
;
i
<
pFileH
->
nFGroups
;
i
++
)
{
if
(
tsdbLogRetentionChange
(
pCommitH
,
mfid
)
<
0
)
return
-
1
;
SFileGroup
*
pFGroup
=
pFileH
->
pFGroup
[
i
];
if
(
pFGroup
->
fileId
<
mfid
)
{
STsdbFileChange
*
pChange
=
(
STsdbFileChange
*
)
calloc
(
1
,
sizeof
(
STsdbFileChange
)
+
sizeof
(
STsdbFileChange
));
if
(
pChange
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
}
pChange
->
type
=
TSDB_DATA_FILE_CHANGE
;
SDataFileChange
*
pDataFileChange
=
(
SDataFileChange
*
)
pChange
->
change
;
pDataFileChange
->
ofgroup
=
pFGroup
;
}
else
{
break
;
}
}
if
(
pMem
->
numOfRows
<=
0
)
return
0
;
if
(
pMem
->
numOfRows
<=
0
)
return
0
;
...
@@ -173,14 +155,20 @@ static int tsdbCommitTimeSeriesData(SCommitHandle *pCommitH) {
...
@@ -173,14 +155,20 @@ static int tsdbCommitTimeSeriesData(SCommitHandle *pCommitH) {
tsdbGetFidKeyRange
(
pCfg
->
daysPerFile
,
pCfg
->
precision
,
fid
,
&
minKey
,
&
maxKey
);
tsdbGetFidKeyRange
(
pCfg
->
daysPerFile
,
pCfg
->
precision
,
fid
,
&
minKey
,
&
maxKey
);
if
(
fid
<
mfid
)
{
if
(
fid
<
mfid
)
{
// TODO: skip data in this file beyond retentioin and continue;
// Skip data in files beyond retention
tsdbSeekTSCommitHandle
(
&
tsCommitH
,
maxKey
);
continue
;
continue
;
}
}
if
(
!
tsdbHasDataToCommit
(
tsCommitH
.
pIters
,
pMem
->
maxTables
,
minKey
,
maxKey
))
continue
;
if
(
!
tsdbHasDataToCommit
(
tsCommitH
.
pIters
,
pMem
->
maxTables
,
minKey
,
maxKey
))
continue
;
{
{
// TODO: Log file change
// TODO: manifest log file group action
SFileGroup
*
pFGroup
=
tsdbSearchFGroup
(
pFileH
,
fid
,
TD_EQ
);
if
(
pFGroup
==
NULL
)
{
}
else
{
}
}
}
if
(
tsdbCommitToFile
(
pRepo
,
fid
,
&
tsCommitH
)
<
0
)
{
if
(
tsdbCommitToFile
(
pRepo
,
fid
,
&
tsCommitH
)
<
0
)
{
...
@@ -248,11 +236,6 @@ static int tsdbCommitMetaData(SCommitHandle *pCommitH) {
...
@@ -248,11 +236,6 @@ static int tsdbCommitMetaData(SCommitHandle *pCommitH) {
return
0
;
return
0
;
}
}
static
int
tsdbApplyRetention
(
SCommitHandle
*
pCommitH
)
{
// TODO
return
0
;
}
static
SCommitIter
*
tsdbCreateCommitIters
(
STsdbRepo
*
pRepo
)
{
static
SCommitIter
*
tsdbCreateCommitIters
(
STsdbRepo
*
pRepo
)
{
SMemTable
*
pMem
=
pRepo
->
imem
;
SMemTable
*
pMem
=
pRepo
->
imem
;
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
STsdbMeta
*
pMeta
=
pRepo
->
tsdbMeta
;
...
@@ -415,7 +398,10 @@ _err:
...
@@ -415,7 +398,10 @@ _err:
static
int
tsdbHasDataToCommit
(
SCommitIter
*
iters
,
int
nIters
,
TSKEY
minKey
,
TSKEY
maxKey
)
{
static
int
tsdbHasDataToCommit
(
SCommitIter
*
iters
,
int
nIters
,
TSKEY
minKey
,
TSKEY
maxKey
)
{
for
(
int
i
=
0
;
i
<
nIters
;
i
++
)
{
for
(
int
i
=
0
;
i
<
nIters
;
i
++
)
{
TSKEY
nextKey
=
tsdbNextIterKey
((
iters
+
i
)
->
pIter
);
SCommitIter
*
pIter
=
iters
+
i
;
if
(
pIter
->
pTable
==
NULL
)
continue
;
TSKEY
nextKey
=
tsdbNextIterKey
(
pIter
->
pIter
);
if
(
nextKey
>
0
&&
(
nextKey
>=
minKey
&&
nextKey
<=
maxKey
))
return
1
;
if
(
nextKey
>
0
&&
(
nextKey
>=
minKey
&&
nextKey
<=
maxKey
))
return
1
;
}
}
return
0
;
return
0
;
...
@@ -524,27 +510,60 @@ static int tsdbLogMetaFileChange(SCommitHandle *pCommitH) {
...
@@ -524,27 +510,60 @@ static int tsdbLogMetaFileChange(SCommitHandle *pCommitH) {
STsdbRepo
*
pRepo
=
pCommitH
->
pRepo
;
STsdbRepo
*
pRepo
=
pCommitH
->
pRepo
;
SKVStore
*
pStore
=
pRepo
->
tsdbMeta
->
pStore
;
SKVStore
*
pStore
=
pRepo
->
tsdbMeta
->
pStore
;
S
TsdbFileChange
*
pChange
=
(
STsdbFileChange
*
)
calloc
(
1
,
sizeof
(
*
p
Change
)
+
sizeof
(
SMetaFileChange
));
S
ListNode
*
pNode
=
(
SListNode
*
)
calloc
(
1
,
sizeof
(
SListNode
)
+
sizeof
(
STsdbFile
Change
)
+
sizeof
(
SMetaFileChange
));
if
(
p
Chang
e
==
NULL
)
{
if
(
p
Nod
e
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
STsdbFileChange
*
pChange
=
pNode
->
data
;
pChange
->
type
=
TSDB_META_FILE_CHANGE
;
pChange
->
type
=
TSDB_META_FILE_CHANGE
;
SMetaFileChange
*
pMetaChange
=
(
SMetaFileChange
*
)(
pChange
->
change
);
SMetaFileChange
*
pMetaChange
=
(
SMetaFileChange
*
)(
pChange
->
change
);
strncpy
(
pMetaChange
->
oname
,
pStore
->
fname
,
TSDB_FILENAME_LEN
);
strncpy
(
pMetaChange
->
oname
,
pStore
->
fname
,
TSDB_FILENAME_LEN
);
strncpy
(
pMetaChange
->
nname
,
pStore
->
fname
,
TSDB_FILENAME_LEN
);
strncpy
(
pMetaChange
->
nname
,
pStore
->
fname
,
TSDB_FILENAME_LEN
);
pMetaChange
->
info
=
pStore
->
info
;
pMetaChange
->
info
=
pStore
->
info
;
if
(
tsdbLogFileChange
(
pCommitH
,
pChange
)
<
0
)
{
if
(
tsdbLogFileChange
(
pCommitH
,
pChange
)
<
0
)
{
free
(
p
Chang
e
);
free
(
p
Nod
e
);
return
-
1
;
return
-
1
;
}
}
tdListPrepend
(
pCommitH
->
pModLog
,
&
pChang
e
);
tdListPrepend
Node
(
pCommitH
->
pModLog
,
pNod
e
);
return
0
;
return
0
;
}
}
static
int
static
int
tsdbLogRetentionChange
(
SCommitHandle
*
pCommitH
,
int
mfid
)
{
STsdbRepo
*
pRepo
=
pCommitH
->
pRepo
;
STsdbFileH
*
pFileH
=
pRepo
->
tsdbFileH
;
for
(
int
i
=
0
;
i
<
pFileH
->
nFGroups
;
i
++
)
{
SFileGroup
*
pFGroup
=
pFileH
->
pFGroup
[
i
];
if
(
pFGroup
->
fileId
<
mfid
)
{
SListNode
*
pNode
=
(
SListNode
*
)
calloc
(
1
,
sizeof
(
SListNode
)
+
sizeof
(
STsdbFileChange
)
+
sizeof
(
SDataFileChange
));
if
(
pNode
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
}
STsdbFileChange
*
pChange
=
(
STsdbFileChange
*
)
pNode
->
data
;
pChange
->
type
=
TSDB_DATA_FILE_CHANGE
;
SDataFileChange
*
pDataFileChange
=
(
SDataFileChange
*
)
pChange
->
change
;
pDataFileChange
->
ofgroup
=
pFGroup
;
if
(
tsdbLogFileChange
(
pCommitH
,
pChange
)
<
0
)
{
free
(
pNode
);
return
-
1
;
}
tdListPrependNode
(
pCommitH
->
pModLog
,
&
pChange
);
}
else
{
break
;
}
}
return
0
;
}
static
int
tsdbApplyFileChange
(
STsdbFileChange
*
pChange
,
bool
isCommitEnd
)
{
static
int
tsdbApplyFileChange
(
STsdbFileChange
*
pChange
,
bool
isCommitEnd
)
{
if
(
pChange
->
type
==
TSDB_META_FILE_CHANGE
)
{
if
(
pChange
->
type
==
TSDB_META_FILE_CHANGE
)
{
...
@@ -564,4 +583,14 @@ static int tsdbApplyFileChange(STsdbFileChange *pChange, bool isCommitEnd) {
...
@@ -564,4 +583,14 @@ static int tsdbApplyFileChange(STsdbFileChange *pChange, bool isCommitEnd) {
}
}
return
0
;
return
0
;
}
static
void
tsdbSeekTSCommitHandle
(
STSCommitHandle
*
pTSCh
,
TSKEY
key
)
{
for
(
int
tid
=
1
;
tid
<
pTSCh
->
maxIters
;
tid
++
)
{
SCommitIter
*
pIter
=
pTSCh
->
pIters
+
tid
;
if
(
pIter
->
pTable
==
NULL
)
continue
;
while
(
tsdbLoadDataFromCache
(
pIter
->
pTable
,
pIter
->
pIter
,
key
,
INT32_MAX
,
NULL
,
NULL
,
0
)
!=
0
)
{
}
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录