Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4da408af
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
4da408af
编写于
6月 09, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: call walEndSnapshot while sdb writefile
上级
3148df21
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
69 addition
and
33 deletion
+69
-33
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+1
-1
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+32
-2
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+18
-28
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
+2
-0
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+12
-1
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+1
-1
未找到文件。
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
4da408af
...
...
@@ -76,7 +76,6 @@ typedef struct {
}
STelemMgmt
;
typedef
struct
{
SWal
*
pWal
;
sem_t
syncSem
;
int64_t
sync
;
bool
standby
;
...
...
@@ -109,6 +108,7 @@ typedef struct SMnode {
SQHandle
*
pQuery
;
SHashObj
*
infosMeta
;
SHashObj
*
perfsMeta
;
SWal
*
pWal
;
SShowMgmt
showMgmt
;
SProfileMgmt
profileMgmt
;
STelemMgmt
telemMgmt
;
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
4da408af
...
...
@@ -139,10 +139,40 @@ static int32_t mndCreateDir(SMnode *pMnode, const char *path) {
return
0
;
}
static
int32_t
mndInitWal
(
SMnode
*
pMnode
)
{
char
path
[
PATH_MAX
+
20
]
=
{
0
};
snprintf
(
path
,
sizeof
(
path
),
"%s%swal"
,
pMnode
->
path
,
TD_DIRSEP
);
SWalCfg
cfg
=
{
.
vgId
=
1
,
.
fsyncPeriod
=
0
,
.
rollPeriod
=
-
1
,
.
segSize
=
-
1
,
.
retentionPeriod
=
-
1
,
.
retentionSize
=
-
1
,
.
level
=
TAOS_WAL_FSYNC
,
};
pMnode
->
pWal
=
walOpen
(
path
,
&
cfg
);
if
(
pMnode
->
pWal
==
NULL
)
{
mError
(
"failed to open wal since %s"
,
terrstr
());
return
-
1
;
}
return
0
;
}
static
void
mndCloseWal
(
SMnode
*
pMnode
)
{
if
(
pMnode
->
pWal
!=
NULL
)
{
walClose
(
pMnode
->
pWal
);
pMnode
->
pWal
=
NULL
;
}
}
static
int32_t
mndInitSdb
(
SMnode
*
pMnode
)
{
SSdbOpt
opt
=
{
0
};
opt
.
path
=
pMnode
->
path
;
opt
.
pMnode
=
pMnode
;
opt
.
pWal
=
pMnode
->
pWal
;
pMnode
->
pSdb
=
sdbInit
(
&
opt
);
if
(
pMnode
->
pSdb
==
NULL
)
{
...
...
@@ -156,7 +186,6 @@ static int32_t mndOpenSdb(SMnode *pMnode) {
if
(
!
pMnode
->
deploy
)
{
return
sdbReadFile
(
pMnode
->
pSdb
);
}
else
{
// return sdbDeploy(pMnode->pSdb);;
return
0
;
}
}
...
...
@@ -182,6 +211,7 @@ static int32_t mndAllocStep(SMnode *pMnode, char *name, MndInitFp initFp, MndCle
}
static
int32_t
mndInitSteps
(
SMnode
*
pMnode
)
{
if
(
mndAllocStep
(
pMnode
,
"mnode-wal"
,
mndInitWal
,
mndCloseWal
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-sdb"
,
mndInitSdb
,
mndCleanupSdb
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-trans"
,
mndInitTrans
,
mndCleanupTrans
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-cluster"
,
mndInitCluster
,
mndCleanupCluster
)
!=
0
)
return
-
1
;
...
...
@@ -201,7 +231,7 @@ static int32_t mndInitSteps(SMnode *pMnode) {
if
(
mndAllocStep
(
pMnode
,
"mnode-offset"
,
mndInitOffset
,
mndCleanupOffset
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-vgroup"
,
mndInitVgroup
,
mndCleanupVgroup
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-stb"
,
mndInitStb
,
mndCleanupStb
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-s
tb
"
,
mndInitSma
,
mndCleanupSma
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-s
ma
"
,
mndInitSma
,
mndCleanupSma
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-infos"
,
mndInitInfos
,
mndCleanupInfos
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-perfs"
,
mndInitPerfs
,
mndCleanupPerfs
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-db"
,
mndInitDb
,
mndCleanupDb
)
!=
0
)
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
4da408af
...
...
@@ -17,15 +17,27 @@
#include "mndSync.h"
#include "mndTrans.h"
int32_t
mndSyncEqMsg
(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
)
{
static
int32_t
mndSyncEqMsg
(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
)
{
SMsgHead
*
pHead
=
pMsg
->
pCont
;
pHead
->
contLen
=
htonl
(
pHead
->
contLen
);
pHead
->
vgId
=
htonl
(
pHead
->
vgId
);
return
tmsgPutToQueue
(
msgcb
,
SYNC_QUEUE
,
pMsg
);
int32_t
code
=
tmsgPutToQueue
(
msgcb
,
SYNC_QUEUE
,
pMsg
);
if
(
code
!=
0
)
{
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
}
return
code
;
}
int32_t
mndSyncSendMsg
(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
)
{
return
tmsgSendReq
(
pEpSet
,
pMsg
);
}
static
int32_t
mndSyncSendMsg
(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
)
{
int32_t
code
=
tmsgSendReq
(
pEpSet
,
pMsg
);
if
(
code
!=
0
)
{
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
}
return
code
;
}
void
mndSyncCommitMsg
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
...
...
@@ -89,8 +101,8 @@ void mndReConfig(struct SSyncFSM *pFsm, SSyncCfg newCfg, SReConfigCbMeta cbMeta)
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
pMgmt
->
errCode
=
cbMeta
.
code
;
mInfo
(
"trans:-1, sync reconfig is proposed, saved:%d code:0x%x, index:%"
PRId64
" term:%"
PRId64
,
pMgmt
->
transId
,
cbMeta
.
code
,
cbMeta
.
index
,
cbMeta
.
term
);
mInfo
(
"trans:-1, sync reconfig is proposed, saved:%d code:0x%x, index:%"
PRId64
" term:%"
PRId64
,
pMgmt
->
transId
,
cbMeta
.
code
,
cbMeta
.
index
,
cbMeta
.
term
);
if
(
pMgmt
->
transId
==
-
1
)
{
if
(
pMgmt
->
errCode
!=
0
)
{
...
...
@@ -155,27 +167,9 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
int32_t
mndInitSync
(
SMnode
*
pMnode
)
{
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
char
path
[
PATH_MAX
+
20
]
=
{
0
};
snprintf
(
path
,
sizeof
(
path
),
"%s%swal"
,
pMnode
->
path
,
TD_DIRSEP
);
SWalCfg
cfg
=
{
.
vgId
=
1
,
.
fsyncPeriod
=
0
,
.
rollPeriod
=
-
1
,
.
segSize
=
-
1
,
.
retentionPeriod
=
-
1
,
.
retentionSize
=
-
1
,
.
level
=
TAOS_WAL_FSYNC
,
};
pMgmt
->
pWal
=
walOpen
(
path
,
&
cfg
);
if
(
pMgmt
->
pWal
==
NULL
)
{
mError
(
"failed to open wal since %s"
,
terrstr
());
return
-
1
;
}
SSyncInfo
syncInfo
=
{.
vgId
=
1
,
.
FpSendMsg
=
mndSyncSendMsg
,
.
FpEqMsg
=
mndSyncEqMsg
};
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s%ssync"
,
pMnode
->
path
,
TD_DIRSEP
);
syncInfo
.
pWal
=
pM
gmt
->
pWal
;
syncInfo
.
pWal
=
pM
node
->
pWal
;
syncInfo
.
pFsm
=
mndSyncMakeFsm
(
pMnode
);
syncInfo
.
isStandBy
=
pMgmt
->
standby
;
syncInfo
.
snapshotEnable
=
true
;
...
...
@@ -208,10 +202,6 @@ void mndCleanupSync(SMnode *pMnode) {
mDebug
(
"mnode sync is stopped, id:%"
PRId64
,
pMgmt
->
sync
);
tsem_destroy
(
&
pMgmt
->
syncSem
);
if
(
pMgmt
->
pWal
!=
NULL
)
{
walClose
(
pMgmt
->
pWal
);
}
memset
(
pMgmt
,
0
,
sizeof
(
SSyncMgmt
));
}
...
...
source/dnode/mnode/sdb/inc/sdb.h
浏览文件 @
4da408af
...
...
@@ -22,6 +22,7 @@
#include "tlockfree.h"
#include "tlog.h"
#include "tmsg.h"
#include "wal.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -165,6 +166,7 @@ typedef struct SSdbRow {
typedef
struct
SSdb
{
SMnode
*
pMnode
;
SWal
*
pWal
;
char
*
currDir
;
char
*
tmpDir
;
int64_t
lastCommitVer
;
...
...
@@ -206,6 +208,7 @@ typedef struct {
typedef
struct
SSdbOpt
{
const
char
*
path
;
SMnode
*
pMnode
;
SWal
*
pWal
;
}
SSdbOpt
;
/**
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
4da408af
...
...
@@ -52,10 +52,12 @@ SSdb *sdbInit(SSdbOpt *pOption) {
pSdb
->
keyTypes
[
i
]
=
SDB_KEY_INT32
;
}
pSdb
->
pWal
=
pOption
->
pWal
;
pSdb
->
curVer
=
-
1
;
pSdb
->
curTerm
=
-
1
;
pSdb
->
lastCommitVer
=
-
1
;
pSdb
->
lastCommitTerm
=
-
1
;
pSdb
->
curConfig
=
-
1
;
pSdb
->
pMnode
=
pOption
->
pMnode
;
taosThreadMutexInit
(
&
pSdb
->
filelock
,
NULL
);
mDebug
(
"sdb init successfully"
);
...
...
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
4da408af
...
...
@@ -441,12 +441,23 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) {
}
int32_t
sdbWriteFile
(
SSdb
*
pSdb
)
{
int32_t
code
=
0
;
if
(
pSdb
->
curVer
==
pSdb
->
lastCommitVer
)
{
return
0
;
}
taosThreadMutexLock
(
&
pSdb
->
filelock
);
int32_t
code
=
sdbWriteFileImp
(
pSdb
);
if
(
pSdb
->
pWal
!=
NULL
)
{
code
=
walBeginSnapshot
(
pSdb
->
pWal
,
pSdb
->
curVer
);
}
if
(
code
==
0
)
{
code
=
sdbWriteFileImp
(
pSdb
);
}
if
(
code
==
0
)
{
if
(
pSdb
->
pWal
!=
NULL
)
{
code
=
walEndSnapshot
(
pSdb
->
pWal
);
}
}
if
(
code
!=
0
)
{
mError
(
"failed to write sdb file since %s"
,
terrstr
());
}
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
4da408af
...
...
@@ -252,7 +252,7 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
int32_t
vnodeSyncOpen
(
SVnode
*
pVnode
,
char
*
path
)
{
SSyncInfo
syncInfo
=
{
.
isStandBy
=
false
,
.
isStandBy
=
false
,
.
snapshotEnable
=
false
,
.
vgId
=
pVnode
->
config
.
vgId
,
.
isStandBy
=
pVnode
->
config
.
standby
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录