Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
17f8ccc9
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看板
提交
17f8ccc9
编写于
6月 09, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: record config index
上级
65f65b53
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
43 addition
and
5 deletion
+43
-5
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+11
-0
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+4
-0
source/dnode/mnode/sdb/inc/sdb.h
source/dnode/mnode/sdb/inc/sdb.h
+3
-0
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+5
-1
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+20
-4
未找到文件。
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
17f8ccc9
...
...
@@ -50,6 +50,10 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
tsem_post
(
&
pMgmt
->
syncSem
);
}
else
{
if
(
cbMeta
.
index
-
sdbGetApplyIndex
(
pMnode
->
pSdb
)
>
100
)
{
SSnapshotMeta
sMeta
=
{
0
};
if
(
syncGetSnapshotMeta
(
pMnode
->
syncMgmt
.
sync
,
&
sMeta
)
==
0
)
{
sdbSetCurConfig
(
pMnode
->
pSdb
,
sMeta
.
lastConfigIndex
);
}
sdbWriteFile
(
pMnode
->
pSdb
);
}
}
...
...
@@ -59,11 +63,18 @@ int32_t mndSyncGetSnapshot(struct SSyncFSM *pFsm, SSnapshot *pSnapshot) {
SMnode
*
pMnode
=
pFsm
->
data
;
pSnapshot
->
lastApplyIndex
=
sdbGetCommitIndex
(
pMnode
->
pSdb
);
pSnapshot
->
lastApplyTerm
=
sdbGetCommitTerm
(
pMnode
->
pSdb
);
pSnapshot
->
lastConfigIndex
=
sdbGetCurConfig
(
pMnode
->
pSdb
);
return
0
;
}
void
mndRestoreFinish
(
struct
SSyncFSM
*
pFsm
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
SSnapshotMeta
sMeta
=
{
0
};
if
(
syncGetSnapshotMeta
(
pMnode
->
syncMgmt
.
sync
,
&
sMeta
)
==
0
)
{
sdbSetCurConfig
(
pMnode
->
pSdb
,
sMeta
.
lastConfigIndex
);
}
if
(
!
pMnode
->
deploy
)
{
mInfo
(
"mnode sync restore finished, and will handle outstanding transactions"
);
mndTransPullup
(
pMnode
);
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
17f8ccc9
...
...
@@ -1388,6 +1388,10 @@ void mndTransPullup(SMnode *pMnode) {
mndReleaseTrans
(
pMnode
,
pTrans
);
}
SSnapshotMeta
sMeta
=
{
0
};
if
(
syncGetSnapshotMeta
(
pMnode
->
syncMgmt
.
sync
,
&
sMeta
)
==
0
)
{
sdbSetCurConfig
(
pMnode
->
pSdb
,
sMeta
.
lastConfigIndex
);
}
sdbWriteFile
(
pMnode
->
pSdb
);
taosArrayDestroy
(
pArray
);
}
...
...
source/dnode/mnode/sdb/inc/sdb.h
浏览文件 @
17f8ccc9
...
...
@@ -171,6 +171,7 @@ typedef struct SSdb {
int64_t
lastCommitTerm
;
int64_t
curVer
;
int64_t
curTerm
;
int64_t
curConfig
;
int64_t
tableVer
[
SDB_MAX
];
int64_t
maxId
[
SDB_MAX
];
EKeyType
keyTypes
[
SDB_MAX
];
...
...
@@ -359,10 +360,12 @@ int64_t sdbGetTableVer(SSdb *pSdb, ESdbType type);
*/
void
sdbSetApplyIndex
(
SSdb
*
pSdb
,
int64_t
index
);
void
sdbSetApplyTerm
(
SSdb
*
pSdb
,
int64_t
term
);
void
sdbSetCurConfig
(
SSdb
*
pSdb
,
int64_t
config
);
int64_t
sdbGetApplyIndex
(
SSdb
*
pSdb
);
int64_t
sdbGetApplyTerm
(
SSdb
*
pSdb
);
int64_t
sdbGetCommitIndex
(
SSdb
*
pSdb
);
int64_t
sdbGetCommitTerm
(
SSdb
*
pSdb
);
int64_t
sdbGetCurConfig
(
SSdb
*
pSdb
);
SSdbRaw
*
sdbAllocRaw
(
ESdbType
type
,
int8_t
sver
,
int32_t
dataLen
);
void
sdbFreeRaw
(
SSdbRaw
*
pRaw
);
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
17f8ccc9
...
...
@@ -161,10 +161,14 @@ void sdbSetApplyIndex(SSdb *pSdb, int64_t index) { pSdb->curVer = index; }
void
sdbSetApplyTerm
(
SSdb
*
pSdb
,
int64_t
term
)
{
pSdb
->
curTerm
=
term
;
}
void
sdbSetCurConfig
(
SSdb
*
pSdb
,
int64_t
config
)
{
pSdb
->
curConfig
=
config
;
}
int64_t
sdbGetApplyIndex
(
SSdb
*
pSdb
)
{
return
pSdb
->
curVer
;
}
int64_t
sdbGetApplyTerm
(
SSdb
*
pSdb
)
{
return
pSdb
->
curTerm
;
}
int64_t
sdbGetCommitIndex
(
SSdb
*
pSdb
)
{
return
pSdb
->
lastCommitVer
;
}
int64_t
sdbGetCommitTerm
(
SSdb
*
pSdb
)
{
return
pSdb
->
lastCommitTerm
;
}
\ No newline at end of file
int64_t
sdbGetCommitTerm
(
SSdb
*
pSdb
)
{
return
pSdb
->
lastCommitTerm
;
}
int64_t
sdbGetCurConfig
(
SSdb
*
pSdb
)
{
return
pSdb
->
curConfig
;
}
\ No newline at end of file
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
17f8ccc9
...
...
@@ -110,6 +110,16 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
return
-
1
;
}
ret
=
taosReadFile
(
pFile
,
&
pSdb
->
curConfig
,
sizeof
(
int64_t
));
if
(
ret
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
if
(
ret
!=
sizeof
(
int64_t
))
{
terrno
=
TSDB_CODE_FILE_CORRUPTED
;
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
SDB_TABLE_SIZE
;
++
i
)
{
int64_t
maxId
=
0
;
ret
=
taosReadFile
(
pFile
,
&
maxId
,
sizeof
(
int64_t
));
...
...
@@ -173,6 +183,11 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
return
-
1
;
}
if
(
taosWriteFile
(
pFile
,
&
pSdb
->
curConfig
,
sizeof
(
int64_t
))
!=
sizeof
(
int64_t
))
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
SDB_TABLE_SIZE
;
++
i
)
{
int64_t
maxId
=
0
;
if
(
i
<
SDB_MAX
)
{
...
...
@@ -288,8 +303,8 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
pSdb
->
lastCommitVer
=
pSdb
->
curVer
;
pSdb
->
lastCommitTerm
=
pSdb
->
curTerm
;
memcpy
(
pSdb
->
tableVer
,
tableVer
,
sizeof
(
tableVer
));
mDebug
(
"read sdb file:%s successfully,
ver:%"
PRId64
" term
:%"
PRId64
,
file
,
pSdb
->
lastCommitVer
,
pSdb
->
lastCommitTerm
);
mDebug
(
"read sdb file:%s successfully,
index:%"
PRId64
" term:%"
PRId64
" config
:%"
PRId64
,
file
,
pSdb
->
lastCommitVer
,
pSdb
->
lastCommitTerm
,
pSdb
->
curConfig
);
_OVER:
taosCloseFile
(
&
pFile
);
...
...
@@ -498,6 +513,7 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter) {
taosThreadMutexLock
(
&
pSdb
->
filelock
);
int64_t
commitIndex
=
pSdb
->
lastCommitVer
;
int64_t
commitTerm
=
pSdb
->
lastCommitTerm
;
int64_t
curConfig
=
pSdb
->
curConfig
;
if
(
taosCopyFile
(
datafile
,
pIter
->
name
)
<
0
)
{
taosThreadMutexUnlock
(
&
pSdb
->
filelock
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
...
@@ -516,8 +532,8 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter) {
}
*
ppIter
=
pIter
;
mInfo
(
"sdbiter:%p, is created to read snapshot, index:%"
PRId64
" term:%"
PRId64
"
file:%s"
,
pIter
,
commitIndex
,
commit
Term
,
pIter
->
name
);
mInfo
(
"sdbiter:%p, is created to read snapshot, index:%"
PRId64
" term:%"
PRId64
"
config:%"
PRId64
" file:%s"
,
pIter
,
commit
Index
,
commitTerm
,
curConfig
,
pIter
->
name
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录