Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b336971e
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b336971e
编写于
10月 14, 2021
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor
上级
e65c33eb
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
24 addition
and
31 deletion
+24
-31
src/inc/tsdb.h
src/inc/tsdb.h
+2
-1
src/tsdb/inc/tsdbint.h
src/tsdb/inc/tsdbint.h
+1
-3
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+10
-16
src/tsdb/src/tsdbMemTable.c
src/tsdb/src/tsdbMemTable.c
+1
-1
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+3
-3
src/vnode/inc/vnodeInt.h
src/vnode/inc/vnodeInt.h
+1
-0
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+1
-1
src/vnode/src/vnodeWrite.c
src/vnode/src/vnodeWrite.c
+5
-6
未找到文件。
src/inc/tsdb.h
浏览文件 @
b336971e
...
@@ -418,7 +418,8 @@ int tsdbCompact(STsdbRepo *pRepo);
...
@@ -418,7 +418,8 @@ int tsdbCompact(STsdbRepo *pRepo);
// no problem return true
// no problem return true
bool
tsdbNoProblem
(
STsdbRepo
*
pRepo
);
bool
tsdbNoProblem
(
STsdbRepo
*
pRepo
);
void
tsdbSetWalSize
(
STsdbRepo
*
pRepo
,
int64_t
walSize
);
// unit of walSize: MB
int
tsdbCheckWal
(
STsdbRepo
*
pRepo
,
uint32_t
walSize
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/tsdb/inc/tsdbint.h
浏览文件 @
b336971e
...
@@ -94,8 +94,6 @@ struct STsdbRepo {
...
@@ -94,8 +94,6 @@ struct STsdbRepo {
pthread_mutex_t
mutex
;
pthread_mutex_t
mutex
;
bool
repoLocked
;
bool
repoLocked
;
int32_t
code
;
// Commit code
int32_t
code
;
// Commit code
int64_t
commitWalSize
;
// last commit wal size. MB
int64_t
walSize
;
// current wal size. MB
SMergeBuf
mergeBuf
;
//used when update=2
SMergeBuf
mergeBuf
;
//used when update=2
int8_t
compactState
;
// compact state: inCompact/noCompact/waitingCompact?
int8_t
compactState
;
// compact state: inCompact/noCompact/waitingCompact?
...
@@ -111,7 +109,7 @@ struct STsdbRepo {
...
@@ -111,7 +109,7 @@ struct STsdbRepo {
int
tsdbLockRepo
(
STsdbRepo
*
pRepo
);
int
tsdbLockRepo
(
STsdbRepo
*
pRepo
);
int
tsdbUnlockRepo
(
STsdbRepo
*
pRepo
);
int
tsdbUnlockRepo
(
STsdbRepo
*
pRepo
);
STsdbMeta
*
tsdbGetMeta
(
STsdbRepo
*
pRepo
);
STsdbMeta
*
tsdbGetMeta
(
STsdbRepo
*
pRepo
);
int
tsdbCheckCommit
(
STsdbRepo
*
pRepo
,
bool
checkWal
);
int
tsdbCheckCommit
(
STsdbRepo
*
pRepo
);
int
tsdbRestoreInfo
(
STsdbRepo
*
pRepo
);
int
tsdbRestoreInfo
(
STsdbRepo
*
pRepo
);
int
tsdbCacheLastData
(
STsdbRepo
*
pRepo
,
STsdbCfg
*
oldCfg
);
int
tsdbCacheLastData
(
STsdbRepo
*
pRepo
,
STsdbCfg
*
oldCfg
);
void
tsdbGetRootDir
(
int
repoid
,
char
dirName
[]);
void
tsdbGetRootDir
(
int
repoid
,
char
dirName
[]);
...
...
src/tsdb/src/tsdbMain.c
浏览文件 @
b336971e
...
@@ -185,14 +185,7 @@ int tsdbUnlockRepo(STsdbRepo *pRepo) {
...
@@ -185,14 +185,7 @@ int tsdbUnlockRepo(STsdbRepo *pRepo) {
return
0
;
return
0
;
}
}
void
tsdbSetWalSize
(
STsdbRepo
*
pRepo
,
int64_t
walSize
)
{
// MB
int
tsdbCheckCommit
(
STsdbRepo
*
pRepo
)
{
atomic_store_64
(
&
pRepo
->
walSize
,
walSize
);
if
(
walSize
<=
atomic_load_64
(
&
pRepo
->
commitWalSize
))
{
atomic_store_64
(
&
pRepo
->
commitWalSize
,
0
);
// restart
}
}
int
tsdbCheckCommit
(
STsdbRepo
*
pRepo
,
bool
checkWal
)
{
ASSERT
(
pRepo
->
mem
!=
NULL
);
ASSERT
(
pRepo
->
mem
!=
NULL
);
STsdbCfg
*
pCfg
=
&
(
pRepo
->
config
);
STsdbCfg
*
pCfg
=
&
(
pRepo
->
config
);
...
@@ -202,14 +195,15 @@ int tsdbCheckCommit(STsdbRepo *pRepo, bool checkWal) {
...
@@ -202,14 +195,15 @@ int tsdbCheckCommit(STsdbRepo *pRepo, bool checkWal) {
((
listNEles
(
pRepo
->
mem
->
bufBlockList
)
>=
pCfg
->
totalBlocks
/
3
)
&&
(
pBufBlock
->
remain
<
TSDB_BUFFER_RESERVE
)))
{
((
listNEles
(
pRepo
->
mem
->
bufBlockList
)
>=
pCfg
->
totalBlocks
/
3
)
&&
(
pBufBlock
->
remain
<
TSDB_BUFFER_RESERVE
)))
{
// trigger commit
// trigger commit
if
(
tsdbAsyncCommit
(
pRepo
)
<
0
)
return
-
1
;
if
(
tsdbAsyncCommit
(
pRepo
)
<
0
)
return
-
1
;
}
else
if
(
checkWal
)
{
int64_t
walSize
=
atomic_load_64
(
&
pRepo
->
walSize
);
int64_t
commitWalSize
=
atomic_load_64
(
&
pRepo
->
commitWalSize
);
int64_t
delta
=
walSize
-
commitWalSize
;
if
((
delta
>
tsdbWalFlushSize
)
&&
(
delta
>
(
pCfg
->
totalBlocks
/
2
*
pCfg
->
cacheBlockSize
)))
{
atomic_store_64
(
&
pRepo
->
commitWalSize
,
walSize
);
if
(
tsdbAsyncCommit
(
pRepo
)
<
0
)
return
-
1
;
}
}
return
0
;
}
int
tsdbCheckWal
(
STsdbRepo
*
pRepo
,
uint32_t
walSize
)
{
// MB
STsdbCfg
*
pCfg
=
&
(
pRepo
->
config
);
if
((
walSize
>
tsdbWalFlushSize
)
&&
(
walSize
>
(
pCfg
->
totalBlocks
/
2
*
pCfg
->
cacheBlockSize
)))
{
if
(
tsdbAsyncCommit
(
pRepo
)
<
0
)
return
-
1
;
}
}
return
0
;
return
0
;
...
...
src/tsdb/src/tsdbMemTable.c
浏览文件 @
b336971e
...
@@ -77,7 +77,7 @@ int32_t tsdbInsertData(STsdbRepo *repo, SSubmitMsg *pMsg, SShellSubmitRspMsg *pR
...
@@ -77,7 +77,7 @@ int32_t tsdbInsertData(STsdbRepo *repo, SSubmitMsg *pMsg, SShellSubmitRspMsg *pR
if
(
pRsp
!=
NULL
)
pRsp
->
affectedRows
=
htonl
(
affectedrows
);
if
(
pRsp
!=
NULL
)
pRsp
->
affectedRows
=
htonl
(
affectedrows
);
if
(
tsdbCheckCommit
(
pRepo
,
false
)
<
0
)
return
-
1
;
if
(
tsdbCheckCommit
(
pRepo
)
<
0
)
return
-
1
;
return
0
;
return
0
;
}
}
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
b336971e
...
@@ -140,7 +140,7 @@ int tsdbCreateTable(STsdbRepo *repo, STableCfg *pCfg) {
...
@@ -140,7 +140,7 @@ int tsdbCreateTable(STsdbRepo *repo, STableCfg *pCfg) {
goto
_err
;
goto
_err
;
}
}
if
(
tsdbCheckCommit
(
pRepo
,
true
)
<
0
)
return
-
1
;
if
(
tsdbCheckCommit
(
pRepo
)
<
0
)
return
-
1
;
return
0
;
return
0
;
...
@@ -191,7 +191,7 @@ int tsdbDropTable(STsdbRepo *repo, STableId tableId) {
...
@@ -191,7 +191,7 @@ int tsdbDropTable(STsdbRepo *repo, STableId tableId) {
tsdbDebug
(
"vgId:%d, table %s is dropped! tid:%d, uid:%"
PRId64
,
pRepo
->
config
.
tsdbId
,
tbname
,
tid
,
uid
);
tsdbDebug
(
"vgId:%d, table %s is dropped! tid:%d, uid:%"
PRId64
,
pRepo
->
config
.
tsdbId
,
tbname
,
tid
,
uid
);
free
(
tbname
);
free
(
tbname
);
if
(
tsdbCheckCommit
(
pRepo
,
false
)
<
0
)
goto
_err
;
if
(
tsdbCheckCommit
(
pRepo
)
<
0
)
goto
_err
;
return
0
;
return
0
;
...
@@ -416,7 +416,7 @@ int tsdbUpdateTableTagValue(STsdbRepo *repo, SUpdateTableTagValMsg *pMsg) {
...
@@ -416,7 +416,7 @@ int tsdbUpdateTableTagValue(STsdbRepo *repo, SUpdateTableTagValMsg *pMsg) {
}
}
tsdbInsertTableAct
(
pRepo
,
TSDB_UPDATE_META
,
buf
,
pTable
);
tsdbInsertTableAct
(
pRepo
,
TSDB_UPDATE_META
,
buf
,
pTable
);
if
(
tsdbCheckCommit
(
pRepo
,
false
)
<
0
)
return
-
1
;
if
(
tsdbCheckCommit
(
pRepo
)
<
0
)
return
-
1
;
return
0
;
return
0
;
}
}
...
...
src/vnode/inc/vnodeInt.h
浏览文件 @
b336971e
...
@@ -56,6 +56,7 @@ typedef struct {
...
@@ -56,6 +56,7 @@ typedef struct {
uint64_t
version
;
// current version
uint64_t
version
;
// current version
uint64_t
cversion
;
// version while commit start
uint64_t
cversion
;
// version while commit start
uint64_t
fversion
;
// version on saved data file
uint64_t
fversion
;
// version on saved data file
uint32_t
tblMsgVer
;
// create table msg version
void
*
wqueue
;
// write queue
void
*
wqueue
;
// write queue
void
*
qqueue
;
// read query queue
void
*
qqueue
;
// read query queue
void
*
fqueue
;
// read fetch/cancel queue
void
*
fqueue
;
// read fetch/cancel queue
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
b336971e
...
@@ -556,7 +556,7 @@ static int32_t vnodeProcessTsdbStatus(void *arg, int32_t status, int32_t eno) {
...
@@ -556,7 +556,7 @@ static int32_t vnodeProcessTsdbStatus(void *arg, int32_t status, int32_t eno) {
if
(
!
vnodeInInitStatus
(
pVnode
))
{
if
(
!
vnodeInInitStatus
(
pVnode
))
{
walRemoveOneOldFile
(
pVnode
->
wal
);
walRemoveOneOldFile
(
pVnode
->
wal
);
}
}
// vnodeGetVersion() and calling tsdb
SetWalSize() would reply on the vnode isCommiting state
// vnodeGetVersion() and calling tsdb
CheckWal() would reply on the vnode isCommiting state
pVnode
->
isCommiting
=
0
;
pVnode
->
isCommiting
=
0
;
return
vnodeSaveVersion
(
pVnode
);
return
vnodeSaveVersion
(
pVnode
);
}
}
...
...
src/vnode/src/vnodeWrite.c
浏览文件 @
b336971e
...
@@ -176,17 +176,16 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe
...
@@ -176,17 +176,16 @@ static int32_t vnodeProcessCreateTableMsg(SVnodeObj *pVnode, void *pCont, SRspRe
return
terrno
;
return
terrno
;
}
}
// no need to set wal size to trigger commit if vnode in committing state
// TODO: retrieve pVnode->isCommiting need atomic operation?
if
(((
pVnode
->
version
&
8191
)
==
0
)
&&
(
pVnode
->
isCommiting
==
0
))
{
tsdbSetWalSize
(
pVnode
->
tsdb
,
walGetFSize
(
pVnode
->
wal
)
>>
20
);
}
if
(
tsdbCreateTable
(
pVnode
->
tsdb
,
pCfg
)
<
0
)
{
if
(
tsdbCreateTable
(
pVnode
->
tsdb
,
pCfg
)
<
0
)
{
code
=
terrno
;
code
=
terrno
;
ASSERT
(
code
!=
0
);
ASSERT
(
code
!=
0
);
}
}
// no need to set wal size to trigger commit if vnode in committing state
if
((((
++
pVnode
->
tblMsgVer
)
&
32767
)
==
0
)
&&
(
pVnode
->
isCommiting
==
0
))
{
// lazy check
tsdbCheckWal
(
pVnode
->
tsdb
,
walGetFSize
(
pVnode
->
wal
)
>>
20
);
}
tsdbClearTableCfg
(
pCfg
);
tsdbClearTableCfg
(
pCfg
);
return
code
;
return
code
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录