Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
129c692f
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看板
提交
129c692f
编写于
12月 02, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more async commit
上级
6cb65f33
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
47 addition
and
47 deletion
+47
-47
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+1
-2
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-0
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+12
-11
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+33
-34
未找到文件。
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
129c692f
...
...
@@ -77,7 +77,7 @@ void vnodeBufPoolReset(SVBufPool* pPool);
// vnodeQuery.c
int32_t
vnodeQueryOpen
(
SVnode
*
pVnode
);
void
vnodeQueryPreClose
(
SVnode
*
pVnode
);
void
vnodeQueryPreClose
(
SVnode
*
pVnode
);
void
vnodeQueryClose
(
SVnode
*
pVnode
);
int32_t
vnodeGetTableMeta
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
bool
direct
);
int
vnodeGetTableCfg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
bool
direct
);
...
...
@@ -86,7 +86,6 @@ int32_t vnodeGetBatchMeta(SVnode* pVnode, SRpcMsg* pMsg);
// vnodeCommit.c
int32_t
vnodeBegin
(
SVnode
*
pVnode
);
int32_t
vnodeShouldCommit
(
SVnode
*
pVnode
);
int32_t
vnodeCommit
(
SVnode
*
pVnode
);
void
vnodeRollback
(
SVnode
*
pVnode
);
int32_t
vnodeSaveInfo
(
const
char
*
dir
,
const
SVnodeInfo
*
pCfg
);
int32_t
vnodeCommitInfo
(
const
char
*
dir
,
const
SVnodeInfo
*
pInfo
);
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
129c692f
...
...
@@ -154,6 +154,7 @@ int32_t metaGetStbStats(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo);
int
tsdbOpen
(
SVnode
*
pVnode
,
STsdb
**
ppTsdb
,
const
char
*
dir
,
STsdbKeepCfg
*
pKeepCfg
,
int8_t
rollback
);
int
tsdbClose
(
STsdb
**
pTsdb
);
int32_t
tsdbBegin
(
STsdb
*
pTsdb
);
int32_t
tsdbPrepareCommit
(
STsdb
*
pTsdb
);
int32_t
tsdbCommit
(
STsdb
*
pTsdb
);
int32_t
tsdbFinishCommit
(
STsdb
*
pTsdb
);
int32_t
tsdbRollbackCommit
(
STsdb
*
pTsdb
);
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
129c692f
...
...
@@ -150,20 +150,26 @@ _exit:
return
code
;
}
int32_t
tsdbPrepareCommit
(
STsdb
*
pTsdb
)
{
taosThreadRwlockWrlock
(
&
pTsdb
->
rwLock
);
ASSERT
(
pTsdb
->
imem
==
NULL
);
pTsdb
->
imem
=
pTsdb
->
mem
;
pTsdb
->
mem
=
NULL
;
taosThreadRwlockUnlock
(
&
pTsdb
->
rwLock
);
return
0
;
}
int32_t
tsdbCommit
(
STsdb
*
pTsdb
)
{
if
(
!
pTsdb
)
return
0
;
int32_t
code
=
0
;
int32_t
lino
=
0
;
SCommitter
commith
;
SMemTable
*
pMemTable
=
pTsdb
->
mem
;
SMemTable
*
pMemTable
=
pTsdb
->
i
mem
;
// check
if
(
pMemTable
->
nRow
==
0
&&
pMemTable
->
nDel
==
0
)
{
taosThreadRwlockWrlock
(
&
pTsdb
->
rwLock
);
pTsdb
->
mem
=
NULL
;
taosThreadRwlockUnlock
(
&
pTsdb
->
rwLock
);
tsdbUnrefMemTable
(
pMemTable
);
goto
_exit
;
}
...
...
@@ -811,12 +817,7 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
int32_t
lino
=
0
;
memset
(
pCommitter
,
0
,
sizeof
(
*
pCommitter
));
ASSERT
(
pTsdb
->
mem
&&
pTsdb
->
imem
==
NULL
&&
"last tsdb commit incomplete"
);
taosThreadRwlockWrlock
(
&
pTsdb
->
rwLock
);
pTsdb
->
imem
=
pTsdb
->
mem
;
pTsdb
->
mem
=
NULL
;
taosThreadRwlockUnlock
(
&
pTsdb
->
rwLock
);
ASSERT
(
pTsdb
->
imem
&&
"last tsdb commit incomplete"
);
pCommitter
->
pTsdb
=
pTsdb
;
pCommitter
->
commitID
=
pTsdb
->
pVnode
->
state
.
commitID
;
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
129c692f
...
...
@@ -15,12 +15,17 @@
#include "vnd.h"
typedef
struct
{
SVnodeInfo
info
;
SVnode
*
pVnode
;
}
SCommitInfo
;
#define VND_INFO_FNAME "vnode.json"
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
static
int
vnodeEncodeInfo
(
const
SVnodeInfo
*
pInfo
,
char
**
ppData
);
static
int
vnodeDecodeInfo
(
uint8_t
*
pData
,
SVnodeInfo
*
pInfo
);
static
void
vnodeWaitCommit
(
SVnode
*
pVnode
);
static
int
vnodeEncodeInfo
(
const
SVnodeInfo
*
pInfo
,
char
**
ppData
);
static
int
vnodeDecodeInfo
(
uint8_t
*
pData
,
SVnodeInfo
*
pInfo
);
static
int
vnodeCommitImpl
(
SCommitInfo
*
pInfo
);
int
vnodeBegin
(
SVnode
*
pVnode
)
{
// alloc buffer pool
...
...
@@ -185,27 +190,28 @@ _err:
return
-
1
;
}
typedef
struct
{
SVnodeInfo
info
;
SVnode
*
pVnode
;
}
SCommitInfo
;
static
void
vnodePrepareCommit
(
SVnode
*
pVnode
)
{
tsem_wait
(
&
pVnode
->
canCommit
);
vnodeBufPoolUnRef
(
pVnode
->
inUse
);
pVnode
->
inUse
=
NULL
;
tsdbPrepareCommit
(
pVnode
->
pTsdb
);
}
static
int32_t
vnodeCommitTask
(
void
*
arg
)
{
int32_t
code
=
0
;
S
Vnode
*
pVnode
=
(
SVnode
*
)
pVnode
;
S
CommitInfo
*
pInfo
=
(
SCommitInfo
*
)
arg
;
code
=
vnodeCommit
(
pVnode
);
// commit
code
=
vnodeCommitImpl
(
pInfo
);
if
(
code
)
goto
_exit
;
tsem_post
(
&
pVnode
->
canCommit
);
// end commit
tsem_post
(
&
pInfo
->
pVnode
->
canCommit
);
_exit:
taosMemoryFree
(
pInfo
);
return
code
;
}
int
vnodeAsyncCommit
(
SVnode
*
pVnode
)
{
...
...
@@ -215,16 +221,18 @@ int vnodeAsyncCommit(SVnode *pVnode) {
vnodePrepareCommit
(
pVnode
);
// schedule the task
SVnodeInfo
*
pInfo
=
(
SVnodeInfo
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pInfo
));
pVnode
->
state
.
commitTerm
=
pVnode
->
state
.
applyTerm
;
SCommitInfo
*
pInfo
=
(
SCommitInfo
*
)
taosMemoryCalloc
(
1
,
sizeof
(
*
pInfo
));
if
(
NULL
==
pInfo
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
pInfo
->
config
=
pVnode
->
config
;
pInfo
->
state
.
committed
=
pVnode
->
state
.
applied
;
pInfo
->
state
.
commitTerm
=
pVnode
->
state
.
applyTerm
;
pInfo
->
state
.
commitID
=
pVnode
->
state
.
commitID
;
vnodeScheduleTask
(
vnodeCommitTask
,
p
Vnode
);
pInfo
->
info
.
config
=
pVnode
->
config
;
pInfo
->
info
.
state
.
committed
=
pVnode
->
state
.
applied
;
pInfo
->
info
.
state
.
commitTerm
=
pVnode
->
state
.
applyTerm
;
pInfo
->
info
.
state
.
commitID
=
pVnode
->
state
.
commitID
;
vnodeScheduleTask
(
vnodeCommitTask
,
p
Info
);
_exit:
if
(
code
)
{
...
...
@@ -243,11 +251,12 @@ int vnodeSyncCommit(SVnode *pVnode) {
return
0
;
}
int
vnodeCommit
(
SVnode
*
pVnode
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
SVnodeInfo
info
=
{
0
};
char
dir
[
TSDB_FILENAME_LEN
];
static
int
vnodeCommitImpl
(
SCommitInfo
*
pInfo
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
SVnode
*
pVnode
=
pInfo
->
pVnode
;
vInfo
(
"vgId:%d, start to commit, commit ID:%"
PRId64
" version:%"
PRId64
" term: %"
PRId64
,
TD_VID
(
pVnode
),
pVnode
->
state
.
commitID
,
pVnode
->
state
.
applied
,
pVnode
->
state
.
applyTerm
);
...
...
@@ -258,19 +267,13 @@ int vnodeCommit(SVnode *pVnode) {
return
-
1
;
}
pVnode
->
state
.
commitTerm
=
pVnode
->
state
.
applyTerm
;
// save info
info
.
config
=
pVnode
->
config
;
info
.
state
.
committed
=
pVnode
->
state
.
applied
;
info
.
state
.
commitTerm
=
pVnode
->
state
.
applyTerm
;
info
.
state
.
commitID
=
pVnode
->
state
.
commitID
;
if
(
pVnode
->
pTfs
)
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
);
}
else
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s"
,
pVnode
->
path
);
}
if
(
vnodeSaveInfo
(
dir
,
&
info
)
<
0
)
{
if
(
vnodeSaveInfo
(
dir
,
&
pInfo
->
info
)
<
0
)
{
code
=
terrno
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
...
...
@@ -281,9 +284,6 @@ int vnodeCommit(SVnode *pVnode) {
code
=
smaPreCommit
(
pVnode
->
pSma
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
vnodeBufPoolUnRef
(
pVnode
->
inUse
);
pVnode
->
inUse
=
NULL
;
// commit each sub-system
if
(
metaCommit
(
pVnode
->
pMeta
)
<
0
)
{
code
=
TSDB_CODE_FAILED
;
...
...
@@ -304,7 +304,7 @@ int vnodeCommit(SVnode *pVnode) {
}
// commit info
if
(
vnodeCommitInfo
(
dir
,
&
info
)
<
0
)
{
if
(
vnodeCommitInfo
(
dir
,
&
pInfo
->
info
)
<
0
)
{
code
=
terrno
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
...
...
@@ -322,14 +322,13 @@ int vnodeCommit(SVnode *pVnode) {
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
pVnode
->
state
.
committed
=
info
.
state
.
committed
;
pVnode
->
state
.
committed
=
pInfo
->
info
.
state
.
committed
;
if
(
smaPostCommit
(
pVnode
->
pSma
)
<
0
)
{
vError
(
"vgId:%d, failed to post-commit sma since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
return
-
1
;
}
// apply the commit (TODO)
// walEndSnapshot(pVnode->pWal);
syncEndSnapshot
(
pVnode
->
sync
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录