Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3efe6215
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,发现更多精彩内容 >>
提交
3efe6215
编写于
1月 03, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
integration with wal module
上级
65acb7df
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
54 addition
and
3 deletion
+54
-3
include/dnode/mnode/sdb/sdb.h
include/dnode/mnode/sdb/sdb.h
+11
-2
source/dnode/mnode/impl/CMakeLists.txt
source/dnode/mnode/impl/CMakeLists.txt
+1
-0
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+3
-0
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+33
-1
source/dnode/mnode/sdb/inc/sdbInt.h
source/dnode/mnode/sdb/inc/sdbInt.h
+1
-0
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+5
-0
未找到文件。
include/dnode/mnode/sdb/sdb.h
浏览文件 @
3efe6215
...
...
@@ -260,7 +260,7 @@ void sdbTraverse(SSdb *pSdb, ESdbType type, sdbTraverseFp fp, void *p1, void *p2
*
* @param pSdb The sdb object.
* @param pIter The type of the table.
* @re
cord
int32_t The number of rows in the table
* @re
turn
int32_t The number of rows in the table
*/
int32_t
sdbGetSize
(
SSdb
*
pSdb
,
ESdbType
type
);
...
...
@@ -269,10 +269,19 @@ int32_t sdbGetSize(SSdb *pSdb, ESdbType type);
*
* @param pSdb The sdb object.
* @param pIter The type of the table.
* @re
cord
int32_t The max id of the table
* @re
turn
int32_t The max id of the table
*/
int32_t
sdbGetMaxId
(
SSdb
*
pSdb
,
ESdbType
type
);
/**
* @brief Update the version of sdb
*
* @param pSdb The sdb object.
* @param val The update value of the version.
* @return int32_t The current version of sdb
*/
int64_t
sdbUpdateVer
(
SSdb
*
pSdb
,
int32_t
val
);
SSdbRaw
*
sdbAllocRaw
(
ESdbType
type
,
int8_t
sver
,
int32_t
dataLen
);
void
sdbFreeRaw
(
SSdbRaw
*
pRaw
);
int32_t
sdbSetRawInt8
(
SSdbRaw
*
pRaw
,
int32_t
dataPos
,
int8_t
val
);
...
...
source/dnode/mnode/impl/CMakeLists.txt
浏览文件 @
3efe6215
...
...
@@ -8,6 +8,7 @@ target_include_directories(
target_link_libraries
(
mnode
PRIVATE sdb
PRIVATE wal
PRIVATE transport
PRIVATE cjson
PRIVATE sync
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
3efe6215
...
...
@@ -17,11 +17,13 @@
#define _TD_MND_INT_H_
#include "mndDef.h"
#include "sdb.h"
#include "tcache.h"
#include "tep.h"
#include "tqueue.h"
#include "ttime.h"
#include "wal.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -65,6 +67,7 @@ typedef struct {
typedef
struct
{
int32_t
errCode
;
sem_t
syncSem
;
SWal
*
pWal
;
SSyncNode
*
pSyncNode
;
ESyncState
state
;
}
SSyncMgmt
;
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
3efe6215
...
...
@@ -20,6 +20,21 @@ int32_t mndInitSync(SMnode *pMnode) {
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
tsem_init
(
&
pMgmt
->
syncSem
,
0
,
0
);
char
path
[
PATH_MAX
]
=
{
0
};
snprintf
(
path
,
sizeof
(
path
),
"%s%swal"
,
pMnode
->
path
,
TD_DIRSEP
);
SWalCfg
cfg
=
{.
vgId
=
1
,
.
fsyncPeriod
=
0
,
.
rollPeriod
=
-
1
,
.
segSize
=
-
1
,
.
retentionPeriod
=
0
,
.
retentionSize
=
0
,
.
level
=
TAOS_WAL_FSYNC
};
pMgmt
->
pWal
=
walOpen
(
path
,
&
cfg
);
if
(
pMgmt
->
pWal
==
NULL
)
{
mError
(
"failed to open wal in %s since %s"
,
path
,
terrstr
());
return
-
1
;
}
pMgmt
->
state
=
TAOS_SYNC_STATE_LEADER
;
pMgmt
->
pSyncNode
=
NULL
;
return
0
;
...
...
@@ -27,7 +42,11 @@ int32_t mndInitSync(SMnode *pMnode) {
void
mndCleanupSync
(
SMnode
*
pMnode
)
{
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
tsem_destroy
(
&
pMgmt
->
syncSem
);
if
(
pMgmt
->
pWal
!=
NULL
)
{
walClose
(
pMgmt
->
pWal
);
pMgmt
->
pWal
=
NULL
;
tsem_destroy
(
&
pMgmt
->
syncSem
);
}
}
static
int32_t
mndSyncApplyCb
(
struct
SSyncFSM
*
fsm
,
SyncIndex
index
,
const
SSyncBuffer
*
buf
,
void
*
pData
)
{
...
...
@@ -41,6 +60,19 @@ static int32_t mndSyncApplyCb(struct SSyncFSM *fsm, SyncIndex index, const SSync
}
int32_t
mndSyncPropose
(
SMnode
*
pMnode
,
SSdbRaw
*
pRaw
)
{
SWal
*
pWal
=
pMnode
->
syncMgmt
.
pWal
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int64_t
ver
=
sdbUpdateVer
(
pSdb
,
1
);
if
(
walWrite
(
pWal
,
ver
,
1
,
pRaw
,
sdbGetRawTotalSize
(
pRaw
))
<
0
)
{
sdbUpdateVer
(
pSdb
,
-
1
);
mError
(
"failed to write raw:%p since %s, ver:%"
PRId64
,
pRaw
,
terrstr
(),
ver
);
return
-
1
;
}
mTrace
(
"raw:%p has been write to wal, ver:%"
PRId64
,
pRaw
,
ver
);
walFsync
(
pWal
,
true
);
#if 1
return
0
;
#else
...
...
source/dnode/mnode/sdb/inc/sdbInt.h
浏览文件 @
3efe6215
...
...
@@ -59,6 +59,7 @@ typedef struct SSdb {
char
*
tmpDir
;
int64_t
lastCommitVer
;
int64_t
curVer
;
int64_t
tableVer
[
SDB_MAX
];
int32_t
maxId
[
SDB_MAX
];
EKeyType
keyTypes
[
SDB_MAX
];
SHashObj
*
hashObjs
[
SDB_MAX
];
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
3efe6215
...
...
@@ -159,3 +159,8 @@ static int32_t sdbCreateDir(SSdb *pSdb) {
return
0
;
}
int64_t
sdbUpdateVer
(
SSdb
*
pSdb
,
int32_t
val
)
{
pSdb
->
curVer
+=
val
;
return
val
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录