Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
68b7f694
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
68b7f694
编写于
5月 23, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: sync integrate into mnode
上级
89c1e823
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
30 addition
and
4 deletion
+30
-4
include/dnode/mnode/sdb/sdb.h
include/dnode/mnode/sdb/sdb.h
+3
-0
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+1
-0
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+5
-0
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+19
-3
tests/test/c/sdbDump.c
tests/test/c/sdbDump.c
+2
-1
未找到文件。
include/dnode/mnode/sdb/sdb.h
浏览文件 @
68b7f694
...
...
@@ -312,6 +312,8 @@ int64_t sdbGetTableVer(SSdb *pSdb, ESdbType type);
*/
void
sdbSetApplyIndex
(
SSdb
*
pSdb
,
int64_t
index
);
int64_t
sdbGetApplyIndex
(
SSdb
*
pSdb
);
void
sdbSetApplyTerm
(
SSdb
*
pSdb
,
int64_t
term
);
int64_t
sdbGetApplyTerm
(
SSdb
*
pSdb
);
SSdbRaw
*
sdbAllocRaw
(
ESdbType
type
,
int8_t
sver
,
int32_t
dataLen
);
void
sdbFreeRaw
(
SSdbRaw
*
pRaw
);
...
...
@@ -340,6 +342,7 @@ typedef struct SSdb {
char
*
tmpDir
;
int64_t
lastCommitVer
;
int64_t
curVer
;
int64_t
curTerm
;
int64_t
tableVer
[
SDB_MAX
];
int64_t
maxId
[
SDB_MAX
];
EKeyType
keyTypes
[
SDB_MAX
];
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
68b7f694
...
...
@@ -53,6 +53,7 @@ static void mndSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta c
static
int32_t
mndSyncGetSnapshot
(
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
pSnapshot
->
lastApplyIndex
=
sdbGetApplyIndex
(
pMnode
->
pSdb
);
pSnapshot
->
lastApplyTerm
=
sdbGetApplyTerm
(
pMnode
->
pSdb
);
return
0
;
}
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
68b7f694
...
...
@@ -53,6 +53,7 @@ SSdb *sdbInit(SSdbOpt *pOption) {
}
pSdb
->
curVer
=
-
1
;
pSdb
->
curTerm
=
-
1
;
pSdb
->
lastCommitVer
=
-
1
;
pSdb
->
pMnode
=
pOption
->
pMnode
;
mDebug
(
"sdb init successfully"
);
...
...
@@ -159,3 +160,7 @@ static int32_t sdbCreateDir(SSdb *pSdb) {
void
sdbSetApplyIndex
(
SSdb
*
pSdb
,
int64_t
index
)
{
pSdb
->
curVer
=
index
;
}
int64_t
sdbGetApplyIndex
(
SSdb
*
pSdb
)
{
return
pSdb
->
curVer
;
}
void
sdbSetApplyTerm
(
SSdb
*
pSdb
,
int64_t
term
)
{
pSdb
->
curTerm
=
term
;
}
int64_t
sdbGetApplyTerm
(
SSdb
*
pSdb
)
{
return
pSdb
->
curTerm
;
}
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
68b7f694
...
...
@@ -65,6 +65,16 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
return
-
1
;
}
ret
=
taosReadFile
(
pFile
,
&
pSdb
->
curTerm
,
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
));
...
...
@@ -123,6 +133,11 @@ static int32_t sdbWriteFileHead(SSdb *pSdb, TdFilePtr pFile) {
return
-
1
;
}
if
(
taosWriteFile
(
pFile
,
&
pSdb
->
curTerm
,
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
)
{
...
...
@@ -182,6 +197,7 @@ int32_t sdbReadFile(SSdb *pSdb) {
if
(
sdbReadFileHead
(
pSdb
,
pFile
)
!=
0
)
{
mError
(
"failed to read file:%s head since %s"
,
file
,
terrstr
());
pSdb
->
curVer
=
-
1
;
pSdb
->
curTerm
=
-
1
;
taosMemoryFree
(
pRaw
);
taosCloseFile
(
&
pFile
);
return
-
1
;
...
...
@@ -256,8 +272,8 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
char
curfile
[
PATH_MAX
]
=
{
0
};
snprintf
(
curfile
,
sizeof
(
curfile
),
"%s%ssdb.data"
,
pSdb
->
currDir
,
TD_DIRSEP
);
mDebug
(
"start to write file:%s, current ver:%"
PRId64
", commit ver:%"
PRId64
,
curfile
,
pSdb
->
curVer
,
pSdb
->
lastCommitVer
);
mDebug
(
"start to write file:%s, current ver:%"
PRId64
"
term:%"
PRId64
"
, commit ver:%"
PRId64
,
curfile
,
pSdb
->
curVer
,
pSdb
->
curTerm
,
pSdb
->
lastCommitVer
);
TdFilePtr
pFile
=
taosOpenFile
(
tmpfile
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pFile
==
NULL
)
{
...
...
@@ -350,7 +366,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
mError
(
"failed to write file:%s since %s"
,
curfile
,
tstrerror
(
code
));
}
else
{
pSdb
->
lastCommitVer
=
pSdb
->
curVer
;
mDebug
(
"write file:%s successfully, ver:%"
PRId64
,
curfile
,
pSdb
->
lastCommitVer
);
mDebug
(
"write file:%s successfully, ver:%"
PRId64
" term:%"
PRId64
,
curfile
,
pSdb
->
lastCommitVer
,
pSdb
->
curTerm
);
}
terrno
=
code
;
...
...
tests/test/c/sdbDump.c
浏览文件 @
68b7f694
...
...
@@ -262,7 +262,7 @@ void dumpCluster(SSdb *pSdb, SJson *json) {
}
void
dumpTrans
(
SSdb
*
pSdb
,
SJson
*
json
)
{
void
*
pIter
=
NULL
;
void
*
pIter
=
NULL
;
SJson
*
items
=
tjsonCreateObject
();
tjsonAddItemToObject
(
json
,
"transactions"
,
items
);
...
...
@@ -294,6 +294,7 @@ void dumpTrans(SSdb *pSdb, SJson *json) {
void
dumpHeader
(
SSdb
*
pSdb
,
SJson
*
json
)
{
tjsonAddIntegerToObject
(
json
,
"sver"
,
1
);
tjsonAddStringToObject
(
json
,
"curVer"
,
i642str
(
pSdb
->
curVer
));
tjsonAddStringToObject
(
json
,
"curTerm"
,
i642str
(
pSdb
->
curTerm
));
SJson
*
maxIdsJson
=
tjsonCreateObject
();
tjsonAddItemToObject
(
json
,
"maxIds"
,
maxIdsJson
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录