Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b21e6034
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b21e6034
编写于
7月 14, 2023
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: add the field diskPrimary to vnodeGetPrimaryDir, and entries of vnodes.json
上级
021fcf2a
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
81 addition
and
49 deletion
+81
-49
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
+3
-0
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
+3
-0
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+16
-8
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+11
-2
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+7
-5
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+1
-1
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-0
source/dnode/vnode/src/meta/metaOpen.c
source/dnode/vnode/src/meta/metaOpen.c
+1
-1
source/dnode/vnode/src/sma/smaUtil.c
source/dnode/vnode/src/sma/smaUtil.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+2
-1
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+4
-4
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+21
-16
source/dnode/vnode/src/vnd/vnodeRetention.c
source/dnode/vnode/src/vnd/vnodeRetention.c
+2
-2
source/dnode/vnode/src/vnd/vnodeSnapshot.c
source/dnode/vnode/src/vnd/vnodeSnapshot.c
+5
-5
未找到文件。
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
浏览文件 @
b21e6034
...
...
@@ -46,6 +46,7 @@ typedef struct {
int32_t
vgId
;
int32_t
vgVersion
;
int8_t
dropped
;
int32_t
diskPrimary
;
int32_t
toVgId
;
char
path
[
PATH_MAX
+
20
];
}
SWrapperCfg
;
...
...
@@ -56,6 +57,7 @@ typedef struct {
int32_t
refCount
;
int8_t
dropped
;
int8_t
disable
;
int32_t
diskPrimary
;
int32_t
toVgId
;
char
*
path
;
SVnode
*
pImpl
;
...
...
@@ -81,6 +83,7 @@ typedef struct {
}
SVnodeThread
;
// vmInt.c
int32_t
vmAllocPrimaryDisk
(
SVnodeMgmt
*
pMgmt
,
int32_t
vgId
);
SVnodeObj
*
vmAcquireVnode
(
SVnodeMgmt
*
pMgmt
,
int32_t
vgId
);
void
vmReleaseVnode
(
SVnodeMgmt
*
pMgmt
,
SVnodeObj
*
pVnode
);
int32_t
vmOpenVnode
(
SVnodeMgmt
*
pMgmt
,
SWrapperCfg
*
pCfg
,
SVnode
*
pImpl
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmFile.c
浏览文件 @
b21e6034
...
...
@@ -71,6 +71,8 @@ static int32_t vmDecodeVnodeList(SJson *pJson, SVnodeMgmt *pMgmt, SWrapperCfg **
if
(
code
<
0
)
goto
_OVER
;
tjsonGetInt32ValueFromDouble
(
vnode
,
"vgVersion"
,
pCfg
->
vgVersion
,
code
);
if
(
code
<
0
)
goto
_OVER
;
tjsonGetInt32ValueFromDouble
(
vnode
,
"diskPrimary"
,
pCfg
->
diskPrimary
,
code
);
if
(
code
<
0
)
goto
_OVER
;
tjsonGetInt32ValueFromDouble
(
vnode
,
"toVgId"
,
pCfg
->
toVgId
,
code
);
if
(
code
<
0
)
goto
_OVER
;
...
...
@@ -167,6 +169,7 @@ static int32_t vmEncodeVnodeList(SJson *pJson, SVnodeObj **ppVnodes, int32_t num
if
(
tjsonAddDoubleToObject
(
vnode
,
"vgId"
,
pVnode
->
vgId
)
<
0
)
return
-
1
;
if
(
tjsonAddDoubleToObject
(
vnode
,
"dropped"
,
pVnode
->
dropped
)
<
0
)
return
-
1
;
if
(
tjsonAddDoubleToObject
(
vnode
,
"vgVersion"
,
pVnode
->
vgVersion
)
<
0
)
return
-
1
;
if
(
tjsonAddDoubleToObject
(
vnode
,
"diskPrimary"
,
pVnode
->
diskPrimary
)
<
0
)
return
-
1
;
if
(
pVnode
->
toVgId
&&
tjsonAddDoubleToObject
(
vnode
,
"toVgId"
,
pVnode
->
toVgId
)
<
0
)
return
-
1
;
if
(
tjsonAddItemToArray
(
vnodes
,
vnode
)
<
0
)
return
-
1
;
}
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
b21e6034
...
...
@@ -263,16 +263,19 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
0
;
}
int32_t
diskPrimary
=
vmAllocPrimaryDisk
(
pMgmt
,
vnodeCfg
.
vgId
);
wrapperCfg
.
diskPrimary
=
diskPrimary
;
snprintf
(
path
,
TSDB_FILENAME_LEN
,
"vnode%svnode%d"
,
TD_DIRSEP
,
vnodeCfg
.
vgId
);
if
(
vnodeCreate
(
path
,
&
vnodeCfg
,
pMgmt
->
pTfs
)
<
0
)
{
if
(
vnodeCreate
(
path
,
&
vnodeCfg
,
diskPrimary
,
pMgmt
->
pTfs
)
<
0
)
{
tFreeSCreateVnodeReq
(
&
req
);
dError
(
"vgId:%d, failed to create vnode since %s"
,
req
.
vgId
,
terrstr
());
code
=
terrno
;
goto
_OVER
;
}
SVnode
*
pImpl
=
vnodeOpen
(
path
,
pMgmt
->
pTfs
,
pMgmt
->
msgCb
);
SVnode
*
pImpl
=
vnodeOpen
(
path
,
diskPrimary
,
pMgmt
->
pTfs
,
pMgmt
->
msgCb
);
if
(
pImpl
==
NULL
)
{
dError
(
"vgId:%d, failed to open vnode since %s"
,
req
.
vgId
,
terrstr
());
code
=
terrno
;
...
...
@@ -399,6 +402,7 @@ int32_t vmProcessAlterVnodeTypeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
}
dInfo
(
"vgId:%d, start to close vnode"
,
vgId
);
int32_t
diskPrimary
=
pVnode
->
diskPrimary
;
SWrapperCfg
wrapperCfg
=
{
.
dropped
=
pVnode
->
dropped
,
.
vgId
=
pVnode
->
vgId
,
...
...
@@ -411,13 +415,13 @@ int32_t vmProcessAlterVnodeTypeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
snprintf
(
path
,
TSDB_FILENAME_LEN
,
"vnode%svnode%d"
,
TD_DIRSEP
,
vgId
);
dInfo
(
"vgId:%d, start to alter vnode replica at %s"
,
vgId
,
path
);
if
(
vnodeAlterReplica
(
path
,
&
req
,
pMgmt
->
pTfs
)
<
0
)
{
if
(
vnodeAlterReplica
(
path
,
&
req
,
diskPrimary
,
pMgmt
->
pTfs
)
<
0
)
{
dError
(
"vgId:%d, failed to alter vnode at %s since %s"
,
vgId
,
path
,
terrstr
());
return
-
1
;
}
dInfo
(
"vgId:%d, begin to open vnode"
,
vgId
);
SVnode
*
pImpl
=
vnodeOpen
(
path
,
pMgmt
->
pTfs
,
pMgmt
->
msgCb
);
SVnode
*
pImpl
=
vnodeOpen
(
path
,
diskPrimary
,
pMgmt
->
pTfs
,
pMgmt
->
msgCb
);
if
(
pImpl
==
NULL
)
{
dError
(
"vgId:%d, failed to open vnode at %s since %s"
,
vgId
,
path
,
terrstr
());
return
-
1
;
...
...
@@ -486,10 +490,12 @@ int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
-
1
;
}
int32_t
diskPrimary
=
pVnode
->
diskPrimary
;
SWrapperCfg
wrapperCfg
=
{
.
dropped
=
pVnode
->
dropped
,
.
vgId
=
dstVgId
,
.
vgVersion
=
pVnode
->
vgVersion
,
.
diskPrimary
=
pVnode
->
diskPrimary
,
};
tstrncpy
(
wrapperCfg
.
path
,
pVnode
->
path
,
sizeof
(
wrapperCfg
.
path
));
...
...
@@ -509,13 +515,13 @@ int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
snprintf
(
dstPath
,
TSDB_FILENAME_LEN
,
"vnode%svnode%d"
,
TD_DIRSEP
,
dstVgId
);
dInfo
(
"vgId:%d, alter vnode hashrange at %s"
,
srcVgId
,
srcPath
);
if
(
vnodeAlterHashRange
(
srcPath
,
dstPath
,
&
req
,
pMgmt
->
pTfs
)
<
0
)
{
if
(
vnodeAlterHashRange
(
srcPath
,
dstPath
,
&
req
,
diskPrimary
,
pMgmt
->
pTfs
)
<
0
)
{
dError
(
"vgId:%d, failed to alter vnode hashrange since %s"
,
srcVgId
,
terrstr
());
return
-
1
;
}
dInfo
(
"vgId:%d, open vnode"
,
dstVgId
);
SVnode
*
pImpl
=
vnodeOpen
(
dstPath
,
pMgmt
->
pTfs
,
pMgmt
->
msgCb
);
SVnode
*
pImpl
=
vnodeOpen
(
dstPath
,
diskPrimary
,
pMgmt
->
pTfs
,
pMgmt
->
msgCb
);
if
(
pImpl
==
NULL
)
{
dError
(
"vgId:%d, failed to open vnode at %s since %s"
,
dstVgId
,
dstPath
,
terrstr
());
return
-
1
;
...
...
@@ -598,10 +604,12 @@ int32_t vmProcessAlterVnodeReplicaReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
}
dInfo
(
"vgId:%d, start to close vnode"
,
vgId
);
int32_t
diskPrimary
=
pVnode
->
diskPrimary
;
SWrapperCfg
wrapperCfg
=
{
.
dropped
=
pVnode
->
dropped
,
.
vgId
=
pVnode
->
vgId
,
.
vgVersion
=
pVnode
->
vgVersion
,
.
diskPrimary
=
pVnode
->
diskPrimary
,
};
tstrncpy
(
wrapperCfg
.
path
,
pVnode
->
path
,
sizeof
(
wrapperCfg
.
path
));
vmCloseVnode
(
pMgmt
,
pVnode
,
false
);
...
...
@@ -610,13 +618,13 @@ int32_t vmProcessAlterVnodeReplicaReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
snprintf
(
path
,
TSDB_FILENAME_LEN
,
"vnode%svnode%d"
,
TD_DIRSEP
,
vgId
);
dInfo
(
"vgId:%d, start to alter vnode replica at %s"
,
vgId
,
path
);
if
(
vnodeAlterReplica
(
path
,
&
alterReq
,
pMgmt
->
pTfs
)
<
0
)
{
if
(
vnodeAlterReplica
(
path
,
&
alterReq
,
diskPrimary
,
pMgmt
->
pTfs
)
<
0
)
{
dError
(
"vgId:%d, failed to alter vnode at %s since %s"
,
vgId
,
path
,
terrstr
());
return
-
1
;
}
dInfo
(
"vgId:%d, begin to open vnode"
,
vgId
);
SVnode
*
pImpl
=
vnodeOpen
(
path
,
pMgmt
->
pTfs
,
pMgmt
->
msgCb
);
SVnode
*
pImpl
=
vnodeOpen
(
path
,
diskPrimary
,
pMgmt
->
pTfs
,
pMgmt
->
msgCb
);
if
(
pImpl
==
NULL
)
{
dError
(
"vgId:%d, failed to open vnode at %s since %s"
,
vgId
,
path
,
terrstr
());
return
-
1
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
b21e6034
...
...
@@ -17,6 +17,12 @@
#include "vmInt.h"
#include "vnd.h"
int32_t
vmAllocPrimaryDisk
(
SVnodeMgmt
*
pMgmt
,
int32_t
vgId
)
{
// search fs
// alloc
return
0
;
}
SVnodeObj
*
vmAcquireVnode
(
SVnodeMgmt
*
pMgmt
,
int32_t
vgId
)
{
SVnodeObj
*
pVnode
=
NULL
;
...
...
@@ -52,6 +58,7 @@ int32_t vmOpenVnode(SVnodeMgmt *pMgmt, SWrapperCfg *pCfg, SVnode *pImpl) {
pVnode
->
vgId
=
pCfg
->
vgId
;
pVnode
->
vgVersion
=
pCfg
->
vgVersion
;
pVnode
->
diskPrimary
=
pCfg
->
diskPrimary
;
pVnode
->
refCount
=
0
;
pVnode
->
dropped
=
0
;
pVnode
->
path
=
taosStrdup
(
pCfg
->
path
);
...
...
@@ -169,7 +176,8 @@ static int32_t vmRestoreVgroupId(SWrapperCfg *pCfg, STfs *pTfs) {
snprintf
(
srcPath
,
TSDB_FILENAME_LEN
,
"vnode%svnode%d"
,
TD_DIRSEP
,
srcVgId
);
snprintf
(
dstPath
,
TSDB_FILENAME_LEN
,
"vnode%svnode%d"
,
TD_DIRSEP
,
dstVgId
);
int32_t
vgId
=
vnodeRestoreVgroupId
(
srcPath
,
dstPath
,
srcVgId
,
dstVgId
,
pTfs
);
int32_t
diskPrimary
=
pCfg
->
diskPrimary
;
int32_t
vgId
=
vnodeRestoreVgroupId
(
srcPath
,
dstPath
,
srcVgId
,
dstVgId
,
diskPrimary
,
pTfs
);
if
(
vgId
<=
0
)
{
dError
(
"vgId:%d, failed to restore vgroup id. srcPath: %s"
,
pCfg
->
vgId
,
srcPath
);
return
-
1
;
...
...
@@ -205,9 +213,10 @@ static void *vmOpenVnodeInThread(void *param) {
pThread
->
updateVnodesList
=
true
;
}
int32_t
diskPrimary
=
pCfg
->
diskPrimary
;
snprintf
(
path
,
TSDB_FILENAME_LEN
,
"vnode%svnode%d"
,
TD_DIRSEP
,
pCfg
->
vgId
);
SVnode
*
pImpl
=
vnodeOpen
(
path
,
pMgmt
->
pTfs
,
pMgmt
->
msgCb
);
SVnode
*
pImpl
=
vnodeOpen
(
path
,
diskPrimary
,
pMgmt
->
pTfs
,
pMgmt
->
msgCb
);
if
(
pImpl
==
NULL
)
{
dError
(
"vgId:%d, failed to open vnode by thread:%d"
,
pCfg
->
vgId
,
pThread
->
threadIndex
);
pThread
->
failed
++
;
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
b21e6034
...
...
@@ -51,12 +51,14 @@ extern const SVnodeCfg vnodeCfgDefault;
int32_t
vnodeInit
(
int32_t
nthreads
);
void
vnodeCleanup
();
int32_t
vnodeCreate
(
const
char
*
path
,
SVnodeCfg
*
pCfg
,
STfs
*
pTfs
);
int32_t
vnodeAlterReplica
(
const
char
*
path
,
SAlterVnodeReplicaReq
*
pReq
,
STfs
*
pTfs
);
int32_t
vnodeAlterHashRange
(
const
char
*
srcPath
,
const
char
*
dstPath
,
SAlterVnodeHashRangeReq
*
pReq
,
STfs
*
pTfs
);
int32_t
vnodeRestoreVgroupId
(
const
char
*
srcPath
,
const
char
*
dstPath
,
int32_t
srcVgId
,
int32_t
dstVgId
,
STfs
*
pTfs
);
int32_t
vnodeCreate
(
const
char
*
path
,
SVnodeCfg
*
pCfg
,
int32_t
diskPrimary
,
STfs
*
pTfs
);
int32_t
vnodeAlterReplica
(
const
char
*
path
,
SAlterVnodeReplicaReq
*
pReq
,
int32_t
diskPrimary
,
STfs
*
pTfs
);
int32_t
vnodeAlterHashRange
(
const
char
*
srcPath
,
const
char
*
dstPath
,
SAlterVnodeHashRangeReq
*
pReq
,
int32_t
diskPrimary
,
STfs
*
pTfs
);
int32_t
vnodeRestoreVgroupId
(
const
char
*
srcPath
,
const
char
*
dstPath
,
int32_t
srcVgId
,
int32_t
dstVgId
,
int32_t
diskPrimary
,
STfs
*
pTfs
);
void
vnodeDestroy
(
const
char
*
path
,
STfs
*
pTfs
);
SVnode
*
vnodeOpen
(
const
char
*
path
,
STfs
*
pTfs
,
SMsgCb
msgCb
);
SVnode
*
vnodeOpen
(
const
char
*
path
,
int32_t
diskPrimary
,
STfs
*
pTfs
,
SMsgCb
msgCb
);
void
vnodePreClose
(
SVnode
*
pVnode
);
void
vnodePostClose
(
SVnode
*
pVnode
);
void
vnodeSyncCheckTimeout
(
SVnode
*
pVnode
);
...
...
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
b21e6034
...
...
@@ -87,7 +87,7 @@ void vnodeBufPoolAddToFreeList(SVBufPool* pPool);
int32_t
vnodeBufPoolRecycle
(
SVBufPool
*
pPool
);
// vnodeOpen.c
int32_t
vnodeGetPrimaryDir
(
const
char
*
relPath
,
STfs
*
pTfs
,
char
*
buf
,
size_t
bufLen
);
int32_t
vnodeGetPrimaryDir
(
const
char
*
relPath
,
int32_t
diskPrimary
,
STfs
*
pTfs
,
char
*
buf
,
size_t
bufLen
);
// vnodeQuery.c
int32_t
vnodeQueryOpen
(
SVnode
*
pVnode
);
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
b21e6034
...
...
@@ -385,6 +385,7 @@ struct SVnode {
SVState
state
;
SVStatis
statis
;
STfs
*
pTfs
;
int32_t
diskPrimary
;
SMsgCb
msgCb
;
// Buffer Pool
...
...
source/dnode/vnode/src/meta/metaOpen.c
浏览文件 @
b21e6034
...
...
@@ -41,7 +41,7 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
*
ppMeta
=
NULL
;
// create handle
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
pTfs
,
path
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
diskPrimary
,
pVnode
->
pTfs
,
path
,
TSDB_FILENAME_LEN
);
offset
=
strlen
(
path
);
snprintf
(
path
+
offset
,
TSDB_FILENAME_LEN
-
offset
-
1
,
"%s%s"
,
TD_DIRSEP
,
VNODE_META_DIR
);
...
...
source/dnode/vnode/src/sma/smaUtil.c
浏览文件 @
b21e6034
...
...
@@ -26,7 +26,7 @@ void tdRSmaGetDirName(SVnode *pVnode, STfs *pTfs, bool endWithSep, char *outputN
int32_t
offset
=
0
;
// vnode
vnodeGetPrimaryDir
(
pVnode
->
path
,
pTfs
,
outputName
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
pVnode
->
path
,
p
Vnode
->
diskPrimary
,
p
Tfs
,
outputName
,
TSDB_FILENAME_LEN
);
offset
=
strlen
(
outputName
);
// rsma
...
...
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
b21e6034
...
...
@@ -59,7 +59,7 @@ typedef struct {
static
void
tsdbGetRocksPath
(
STsdb
*
pTsdb
,
char
*
path
)
{
SVnode
*
pVnode
=
pTsdb
->
pVnode
;
vnodeGetPrimaryDir
(
pTsdb
->
path
,
pVnode
->
pTfs
,
path
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
pTsdb
->
path
,
pVnode
->
diskPrimary
,
pVnode
->
pTfs
,
path
,
TSDB_FILENAME_LEN
);
int32_t
offset
=
strlen
(
path
);
snprintf
(
path
+
offset
,
TSDB_FILENAME_LEN
-
offset
-
1
,
"%scache.rdb"
,
TD_DIRSEP
);
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
b21e6034
...
...
@@ -276,14 +276,14 @@ static void tsdbGetCurrentFName(STsdb *pTsdb, char *current, char *current_t) {
// CURRENT
if
(
current
)
{
vnodeGetPrimaryDir
(
pTsdb
->
path
,
pVnode
->
pTfs
,
current
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
pTsdb
->
path
,
pVnode
->
diskPrimary
,
pVnode
->
pTfs
,
current
,
TSDB_FILENAME_LEN
);
offset
=
strlen
(
current
);
snprintf
(
current
+
offset
,
TSDB_FILENAME_LEN
-
offset
-
1
,
"%sCURRENT"
,
TD_DIRSEP
);
}
// CURRENT.t
if
(
current_t
)
{
vnodeGetPrimaryDir
(
pTsdb
->
path
,
pVnode
->
pTfs
,
current_t
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
pTsdb
->
path
,
pVnode
->
diskPrimary
,
pVnode
->
pTfs
,
current_t
,
TSDB_FILENAME_LEN
);
offset
=
strlen
(
current_t
);
snprintf
(
current_t
+
offset
,
TSDB_FILENAME_LEN
-
offset
-
1
,
"%sCURRENT.t"
,
TD_DIRSEP
);
}
...
...
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
b21e6034
...
...
@@ -284,8 +284,9 @@ int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet) {
// SDelFile ===============================================
void
tsdbDelFileName
(
STsdb
*
pTsdb
,
SDelFile
*
pFile
,
char
fname
[])
{
int32_t
offset
=
0
;
SVnode
*
pVnode
=
pTsdb
->
pVnode
;
vnodeGetPrimaryDir
(
pTsdb
->
path
,
p
Tsdb
->
pVnode
->
pTfs
,
fname
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
pTsdb
->
path
,
p
Vnode
->
diskPrimary
,
pVnode
->
pTfs
,
fname
,
TSDB_FILENAME_LEN
);
offset
=
strlen
(
fname
);
snprintf
((
char
*
)
fname
+
offset
,
TSDB_FILENAME_LEN
-
offset
-
1
,
"%sv%dver%"
PRId64
".del"
,
TD_DIRSEP
,
TD_VID
(
pTsdb
->
pVnode
),
pFile
->
commitID
);
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
b21e6034
...
...
@@ -290,7 +290,7 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
pInfo
->
txn
=
metaGetTxn
(
pVnode
->
pMeta
);
// save info
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
diskPrimary
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vDebug
(
"vgId:%d, save config while prepare commit"
,
TD_VID
(
pVnode
));
if
(
vnodeSaveInfo
(
dir
,
&
pInfo
->
info
)
<
0
)
{
...
...
@@ -428,7 +428,7 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
return
-
1
;
}
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
diskPrimary
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
syncBeginSnapshot
(
pVnode
->
sync
,
pInfo
->
info
.
state
.
committed
);
...
...
@@ -492,7 +492,7 @@ bool vnodeShouldRollback(SVnode *pVnode) {
char
tFName
[
TSDB_FILENAME_LEN
]
=
{
0
};
int32_t
offset
=
0
;
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
pTfs
,
tFName
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
diskPrimary
,
pVnode
->
pTfs
,
tFName
,
TSDB_FILENAME_LEN
);
offset
=
strlen
(
tFName
);
snprintf
(
tFName
+
offset
,
TSDB_FILENAME_LEN
-
offset
-
1
,
"%s%s"
,
TD_DIRSEP
,
VND_INFO_FNAME_TMP
);
...
...
@@ -503,7 +503,7 @@ void vnodeRollback(SVnode *pVnode) {
char
tFName
[
TSDB_FILENAME_LEN
]
=
{
0
};
int32_t
offset
=
0
;
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
pTfs
,
tFName
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
diskPrimary
,
pVnode
->
pTfs
,
tFName
,
TSDB_FILENAME_LEN
);
offset
=
strlen
(
tFName
);
snprintf
(
tFName
+
offset
,
TSDB_FILENAME_LEN
-
offset
-
1
,
"%s%s"
,
TD_DIRSEP
,
VND_INFO_FNAME_TMP
);
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
b21e6034
...
...
@@ -15,9 +15,11 @@
#include "vnd.h"
int32_t
vnodeGetPrimaryDir
(
const
char
*
relPath
,
STfs
*
pTfs
,
char
*
buf
,
size_t
bufLen
)
{
int32_t
vnodeGetPrimaryDir
(
const
char
*
relPath
,
int32_t
diskPrimary
,
STfs
*
pTfs
,
char
*
buf
,
size_t
bufLen
)
{
if
(
pTfs
)
{
snprintf
(
buf
,
bufLen
-
1
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pTfs
),
TD_DIRSEP
,
relPath
);
SDiskID
diskId
=
{
0
};
diskId
.
id
=
diskPrimary
;
snprintf
(
buf
,
bufLen
-
1
,
"%s%s%s"
,
tfsGetDiskPath
(
pTfs
,
diskId
),
TD_DIRSEP
,
relPath
);
}
else
{
snprintf
(
buf
,
bufLen
-
1
,
"%s"
,
relPath
);
}
...
...
@@ -25,7 +27,7 @@ int32_t vnodeGetPrimaryDir(const char *relPath, STfs *pTfs, char *buf, size_t bu
return
0
;
}
int32_t
vnodeCreate
(
const
char
*
path
,
SVnodeCfg
*
pCfg
,
STfs
*
pTfs
)
{
int32_t
vnodeCreate
(
const
char
*
path
,
SVnodeCfg
*
pCfg
,
int32_t
diskPrimary
,
STfs
*
pTfs
)
{
SVnodeInfo
info
=
{
0
};
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
...
...
@@ -36,7 +38,7 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
}
// create vnode env
vnodeGetPrimaryDir
(
path
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
path
,
diskPrimary
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
if
(
taosMkDir
(
dir
))
{
return
TAOS_SYSTEM_ERROR
(
errno
);
}
...
...
@@ -60,12 +62,12 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, STfs *pTfs) {
return
0
;
}
int32_t
vnodeAlterReplica
(
const
char
*
path
,
SAlterVnodeReplicaReq
*
pReq
,
STfs
*
pTfs
)
{
int32_t
vnodeAlterReplica
(
const
char
*
path
,
SAlterVnodeReplicaReq
*
pReq
,
int32_t
diskPrimary
,
STfs
*
pTfs
)
{
SVnodeInfo
info
=
{
0
};
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
int32_t
ret
=
0
;
vnodeGetPrimaryDir
(
path
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
path
,
diskPrimary
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
ret
=
vnodeLoadInfo
(
dir
,
&
info
);
if
(
ret
<
0
)
{
...
...
@@ -133,7 +135,8 @@ static int32_t vnodeVgroupIdLen(int32_t vgId) {
return
strlen
(
tmp
);
}
int32_t
vnodeRenameVgroupId
(
const
char
*
srcPath
,
const
char
*
dstPath
,
int32_t
srcVgId
,
int32_t
dstVgId
,
STfs
*
pTfs
)
{
int32_t
vnodeRenameVgroupId
(
const
char
*
srcPath
,
const
char
*
dstPath
,
int32_t
srcVgId
,
int32_t
dstVgId
,
int32_t
diskPrimary
,
STfs
*
pTfs
)
{
int32_t
ret
=
0
;
char
oldRname
[
TSDB_FILENAME_LEN
]
=
{
0
};
...
...
@@ -183,12 +186,13 @@ int32_t vnodeRenameVgroupId(const char *srcPath, const char *dstPath, int32_t sr
return
ret
;
}
int32_t
vnodeAlterHashRange
(
const
char
*
srcPath
,
const
char
*
dstPath
,
SAlterVnodeHashRangeReq
*
pReq
,
STfs
*
pTfs
)
{
int32_t
vnodeAlterHashRange
(
const
char
*
srcPath
,
const
char
*
dstPath
,
SAlterVnodeHashRangeReq
*
pReq
,
int32_t
diskPrimary
,
STfs
*
pTfs
)
{
SVnodeInfo
info
=
{
0
};
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
int32_t
ret
=
0
;
vnodeGetPrimaryDir
(
srcPath
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
srcPath
,
diskPrimary
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
ret
=
vnodeLoadInfo
(
dir
,
&
info
);
if
(
ret
<
0
)
{
...
...
@@ -232,7 +236,7 @@ int32_t vnodeAlterHashRange(const char *srcPath, const char *dstPath, SAlterVnod
}
vInfo
(
"vgId:%d, rename %s to %s"
,
pReq
->
dstVgId
,
srcPath
,
dstPath
);
ret
=
vnodeRenameVgroupId
(
srcPath
,
dstPath
,
pReq
->
srcVgId
,
pReq
->
dstVgId
,
pTfs
);
ret
=
vnodeRenameVgroupId
(
srcPath
,
dstPath
,
pReq
->
srcVgId
,
pReq
->
dstVgId
,
diskPrimary
,
pTfs
);
if
(
ret
<
0
)
{
vError
(
"vgId:%d, failed to rename vnode from %s to %s since %s"
,
pReq
->
dstVgId
,
srcPath
,
dstPath
,
tstrerror
(
terrno
));
...
...
@@ -243,11 +247,12 @@ int32_t vnodeAlterHashRange(const char *srcPath, const char *dstPath, SAlterVnod
return
0
;
}
int32_t
vnodeRestoreVgroupId
(
const
char
*
srcPath
,
const
char
*
dstPath
,
int32_t
srcVgId
,
int32_t
dstVgId
,
STfs
*
pTfs
)
{
int32_t
vnodeRestoreVgroupId
(
const
char
*
srcPath
,
const
char
*
dstPath
,
int32_t
srcVgId
,
int32_t
dstVgId
,
int32_t
diskPrimary
,
STfs
*
pTfs
)
{
SVnodeInfo
info
=
{
0
};
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
vnodeGetPrimaryDir
(
dstPath
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
dstPath
,
diskPrimary
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
if
(
vnodeLoadInfo
(
dir
,
&
info
)
==
0
)
{
if
(
info
.
config
.
vgId
!=
dstVgId
)
{
vError
(
"vgId:%d, unexpected vnode config.vgId:%d"
,
dstVgId
,
info
.
config
.
vgId
);
...
...
@@ -256,7 +261,7 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s
return
dstVgId
;
}
vnodeGetPrimaryDir
(
srcPath
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
srcPath
,
diskPrimary
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
if
(
vnodeLoadInfo
(
dir
,
&
info
)
<
0
)
{
vError
(
"vgId:%d, failed to read vnode config from %s since %s"
,
srcVgId
,
srcPath
,
tstrerror
(
terrno
));
return
-
1
;
...
...
@@ -271,7 +276,7 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s
}
vInfo
(
"vgId:%d, rename %s to %s"
,
dstVgId
,
srcPath
,
dstPath
);
if
(
vnodeRenameVgroupId
(
srcPath
,
dstPath
,
srcVgId
,
dstVgId
,
pTfs
)
<
0
)
{
if
(
vnodeRenameVgroupId
(
srcPath
,
dstPath
,
srcVgId
,
dstVgId
,
diskPrimary
,
pTfs
)
<
0
)
{
vError
(
"vgId:%d, failed to rename vnode from %s to %s since %s"
,
dstVgId
,
srcPath
,
dstPath
,
tstrerror
(
terrno
));
return
-
1
;
}
...
...
@@ -284,14 +289,14 @@ void vnodeDestroy(const char *path, STfs *pTfs) {
tfsRmdir
(
pTfs
,
path
);
}
SVnode
*
vnodeOpen
(
const
char
*
path
,
STfs
*
pTfs
,
SMsgCb
msgCb
)
{
SVnode
*
vnodeOpen
(
const
char
*
path
,
int32_t
diskPrimary
,
STfs
*
pTfs
,
SMsgCb
msgCb
)
{
SVnode
*
pVnode
=
NULL
;
SVnodeInfo
info
=
{
0
};
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tdir
[
TSDB_FILENAME_LEN
*
2
]
=
{
0
};
int32_t
ret
=
0
;
vnodeGetPrimaryDir
(
path
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
path
,
diskPrimary
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
info
.
config
=
vnodeCfgDefault
;
...
...
source/dnode/vnode/src/vnd/vnodeRetention.c
浏览文件 @
b21e6034
...
...
@@ -35,7 +35,7 @@ static int32_t vnodePrepareRentention(SVnode *pVnode, SRetentionInfo *pInfo) {
pInfo
->
commitID
=
++
pVnode
->
state
.
commitID
;
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
diskPrimary
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
if
(
vnodeLoadInfo
(
dir
,
&
pInfo
->
info
)
<
0
)
{
code
=
terrno
;
...
...
@@ -60,7 +60,7 @@ static int32_t vnodeRetentionTask(void *param) {
SVnode
*
pVnode
=
pInfo
->
pVnode
;
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
diskPrimary
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
// save info
pInfo
->
info
.
state
.
commitID
=
pInfo
->
commitID
;
...
...
source/dnode/vnode/src/vnd/vnodeSnapshot.c
浏览文件 @
b21e6034
...
...
@@ -86,6 +86,7 @@ void vnodeSnapReaderClose(SVSnapReader *pReader) {
int32_t
vnodeSnapRead
(
SVSnapReader
*
pReader
,
uint8_t
**
ppData
,
uint32_t
*
nData
)
{
int32_t
code
=
0
;
SVnode
*
pVnode
=
pReader
->
pVnode
;
// CONFIG ==============
// FIXME: if commit multiple times and the config changed?
...
...
@@ -93,7 +94,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
char
fName
[
TSDB_FILENAME_LEN
];
int32_t
offset
=
0
;
vnodeGetPrimaryDir
(
p
Reader
->
pVnode
->
path
,
pReader
->
pVnode
->
pTfs
,
fName
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
p
Vnode
->
path
,
pVnode
->
diskPrimary
,
pVnode
->
pTfs
,
fName
,
TSDB_FILENAME_LEN
);
offset
=
strlen
(
fName
);
snprintf
(
fName
+
offset
,
TSDB_FILENAME_LEN
-
offset
-
1
,
"%s%s"
,
TD_DIRSEP
,
VND_INFO_FNAME
);
...
...
@@ -343,7 +344,7 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot *
.
applyTerm
=
pWriter
->
info
.
state
.
commitTerm
};
pVnode
->
statis
=
pWriter
->
info
.
statis
;
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
pVnode
->
path
,
pVnode
->
diskPrimary
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vnodeCommitInfo
(
dir
);
}
else
{
...
...
@@ -381,7 +382,7 @@ _exit:
static
int32_t
vnodeSnapWriteInfo
(
SVSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
)
{
int32_t
code
=
0
;
SVnode
*
pVnode
=
pWriter
->
pVnode
;
SSnapDataHdr
*
pHdr
=
(
SSnapDataHdr
*
)
pData
;
// decode info
...
...
@@ -395,10 +396,9 @@ static int32_t vnodeSnapWriteInfo(SVSnapWriter *pWriter, uint8_t *pData, uint32_
// modify info as needed
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
vnodeGetPrimaryDir
(
p
Writer
->
pVnode
->
path
,
pWriter
->
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vnodeGetPrimaryDir
(
p
Vnode
->
path
,
pVnode
->
diskPrimary
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
SVnodeStats
vndStats
=
pWriter
->
info
.
config
.
vndStats
;
SVnode
*
pVnode
=
pWriter
->
pVnode
;
pWriter
->
info
.
config
=
pVnode
->
config
;
pWriter
->
info
.
config
.
vndStats
=
vndStats
;
vDebug
(
"vgId:%d, save config while write snapshot"
,
pWriter
->
pVnode
->
config
.
vgId
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录