Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
05e8af48
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
05e8af48
编写于
7月 12, 2023
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: unify handling of vnode primary dir for vnd and tsdb
上级
4c3bf411
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
51 addition
and
76 deletion
+51
-76
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+5
-10
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+16
-17
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+7
-2
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+12
-14
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+1
-5
source/dnode/vnode/src/vnd/vnodeRetention.c
source/dnode/vnode/src/vnd/vnodeRetention.c
+3
-11
source/dnode/vnode/src/vnd/vnodeSnapshot.c
source/dnode/vnode/src/vnd/vnodeSnapshot.c
+7
-17
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
05e8af48
...
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tsdb.h"
#include "vnd.h"
#define ROCKS_BATCH_SIZE (4096)
...
...
@@ -58,16 +59,10 @@ typedef struct {
static
void
tsdbGetRocksPath
(
STsdb
*
pTsdb
,
char
*
path
)
{
SVnode
*
pVnode
=
pTsdb
->
pVnode
;
if
(
pVnode
->
pTfs
)
{
if
(
path
)
{
snprintf
(
path
,
TSDB_FILENAME_LEN
,
"%s%s%s%scache.rdb"
,
tfsGetPrimaryPath
(
pTsdb
->
pVnode
->
pTfs
),
TD_DIRSEP
,
pTsdb
->
path
,
TD_DIRSEP
);
}
}
else
{
if
(
path
)
{
snprintf
(
path
,
TSDB_FILENAME_LEN
,
"%s%scache.rdb"
,
pTsdb
->
path
,
TD_DIRSEP
);
}
}
vnodeGetAbsDir
(
pTsdb
->
path
,
pVnode
->
pTfs
,
path
,
TSDB_FILENAME_LEN
);
int32_t
offset
=
strlen
(
path
);
snprintf
(
path
+
offset
,
TSDB_FILENAME_LEN
-
offset
-
1
,
"%scache.rdb"
,
TD_DIRSEP
);
}
static
const
char
*
myCmpName
(
void
*
state
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
05e8af48
...
...
@@ -14,6 +14,7 @@
*/
#include "tsdb.h"
#include "vnd.h"
// =================================================================================================
static
int32_t
tsdbFSToBinary
(
uint8_t
*
p
,
STsdbFS
*
pFS
)
{
...
...
@@ -271,22 +272,20 @@ int32_t tDFileSetCmprFn(const void *p1, const void *p2) {
static
void
tsdbGetCurrentFName
(
STsdb
*
pTsdb
,
char
*
current
,
char
*
current_t
)
{
SVnode
*
pVnode
=
pTsdb
->
pVnode
;
if
(
pVnode
->
pTfs
)
{
if
(
current
)
{
snprintf
(
current
,
TSDB_FILENAME_LEN
-
1
,
"%s%s%s%sCURRENT"
,
tfsGetPrimaryPath
(
pTsdb
->
pVnode
->
pTfs
),
TD_DIRSEP
,
pTsdb
->
path
,
TD_DIRSEP
);
}
if
(
current_t
)
{
snprintf
(
current_t
,
TSDB_FILENAME_LEN
-
1
,
"%s%s%s%sCURRENT.t"
,
tfsGetPrimaryPath
(
pTsdb
->
pVnode
->
pTfs
),
TD_DIRSEP
,
pTsdb
->
path
,
TD_DIRSEP
);
}
}
else
{
if
(
current
)
{
snprintf
(
current
,
TSDB_FILENAME_LEN
-
1
,
"%s%sCURRENT"
,
pTsdb
->
path
,
TD_DIRSEP
);
}
if
(
current_t
)
{
snprintf
(
current_t
,
TSDB_FILENAME_LEN
-
1
,
"%s%sCURRENT.t"
,
pTsdb
->
path
,
TD_DIRSEP
);
}
int32_t
offset
=
0
;
// CURRENT
if
(
current
)
{
vnodeGetAbsDir
(
pTsdb
->
path
,
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
)
{
vnodeGetAbsDir
(
pTsdb
->
path
,
pVnode
->
pTfs
,
current_t
,
TSDB_FILENAME_LEN
);
offset
=
strlen
(
current_t
);
snprintf
(
current_t
+
offset
,
TSDB_FILENAME_LEN
-
offset
-
1
,
"%sCURRENT.t"
,
TD_DIRSEP
);
}
}
...
...
@@ -1142,4 +1141,4 @@ void tsdbFSUnref(STsdb *pTsdb, STsdbFS *pFS) {
}
taosArrayDestroy
(
pFS
->
aDFileSet
);
}
\ No newline at end of file
}
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
05e8af48
...
...
@@ -14,6 +14,7 @@
*/
#include "tsdb.h"
#include "vnd.h"
int32_t
tPutHeadFile
(
uint8_t
*
p
,
SHeadFile
*
pHeadFile
)
{
int32_t
n
=
0
;
...
...
@@ -282,8 +283,12 @@ int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet) {
// SDelFile ===============================================
void
tsdbDelFileName
(
STsdb
*
pTsdb
,
SDelFile
*
pFile
,
char
fname
[])
{
snprintf
(
fname
,
TSDB_FILENAME_LEN
-
1
,
"%s%s%s%sv%dver%"
PRId64
"%s"
,
tfsGetPrimaryPath
(
pTsdb
->
pVnode
->
pTfs
),
TD_DIRSEP
,
pTsdb
->
path
,
TD_DIRSEP
,
TD_VID
(
pTsdb
->
pVnode
),
pFile
->
commitID
,
".del"
);
int32_t
offset
=
0
;
vnodeGetAbsDir
(
pTsdb
->
path
,
pTsdb
->
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
);
}
int32_t
tPutDelFile
(
uint8_t
*
p
,
SDelFile
*
pDelFile
)
{
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
05e8af48
...
...
@@ -290,11 +290,7 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
pInfo
->
txn
=
metaGetTxn
(
pVnode
->
pMeta
);
// save info
if
(
pVnode
->
pTfs
)
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
);
}
else
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s"
,
pVnode
->
path
);
}
vnodeGetAbsDir
(
pVnode
->
path
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vDebug
(
"vgId:%d, save config while prepare commit"
,
TD_VID
(
pVnode
));
if
(
vnodeSaveInfo
(
dir
,
&
pInfo
->
info
)
<
0
)
{
...
...
@@ -427,11 +423,7 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) {
return
-
1
;
}
if
(
pVnode
->
pTfs
)
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
);
}
else
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s"
,
pVnode
->
path
);
}
vnodeGetAbsDir
(
pVnode
->
path
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
syncBeginSnapshot
(
pVnode
->
sync
,
pInfo
->
info
.
state
.
committed
);
...
...
@@ -493,16 +485,22 @@ _exit:
bool
vnodeShouldRollback
(
SVnode
*
pVnode
)
{
char
tFName
[
TSDB_FILENAME_LEN
]
=
{
0
};
snprintf
(
tFName
,
TSDB_FILENAME_LEN
,
"%s%s%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
,
TD_DIRSEP
,
VND_INFO_FNAME_TMP
);
int32_t
offset
=
0
;
vnodeGetAbsDir
(
pVnode
->
path
,
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
);
return
taosCheckExistFile
(
tFName
);
}
void
vnodeRollback
(
SVnode
*
pVnode
)
{
char
tFName
[
TSDB_FILENAME_LEN
]
=
{
0
};
snprintf
(
tFName
,
TSDB_FILENAME_LEN
,
"%s%s%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
,
TD_DIRSEP
,
VND_INFO_FNAME_TMP
);
int32_t
offset
=
0
;
vnodeGetAbsDir
(
pVnode
->
path
,
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
);
(
void
)
taosRemoveFile
(
tFName
);
}
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
05e8af48
...
...
@@ -291,11 +291,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
char
tdir
[
TSDB_FILENAME_LEN
*
2
]
=
{
0
};
int32_t
ret
=
0
;
if
(
pTfs
)
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pTfs
),
TD_DIRSEP
,
path
);
}
else
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s"
,
path
);
}
vnodeGetAbsDir
(
path
,
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
info
.
config
=
vnodeCfgDefault
;
...
...
source/dnode/vnode/src/vnd/vnodeRetention.c
浏览文件 @
05e8af48
...
...
@@ -35,11 +35,7 @@ static int32_t vnodePrepareRentention(SVnode *pVnode, SRetentionInfo *pInfo) {
pInfo
->
commitID
=
++
pVnode
->
state
.
commitID
;
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
if
(
pVnode
->
pTfs
)
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
);
}
else
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s"
,
pVnode
->
path
);
}
vnodeGetAbsDir
(
pVnode
->
path
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
if
(
vnodeLoadInfo
(
dir
,
&
pInfo
->
info
)
<
0
)
{
code
=
terrno
;
...
...
@@ -64,11 +60,7 @@ static int32_t vnodeRetentionTask(void *param) {
SVnode
*
pVnode
=
pInfo
->
pVnode
;
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
if
(
pVnode
->
pTfs
)
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
);
}
else
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s"
,
pVnode
->
path
);
}
vnodeGetAbsDir
(
pVnode
->
path
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
// save info
pInfo
->
info
.
state
.
commitID
=
pInfo
->
commitID
;
...
...
@@ -127,4 +119,4 @@ _exit:
vInfo
(
"vgId:%d %s done"
,
TD_VID
(
pInfo
->
pVnode
),
__func__
);
}
return
0
;
}
\ No newline at end of file
}
source/dnode/vnode/src/vnd/vnodeSnapshot.c
浏览文件 @
05e8af48
...
...
@@ -91,12 +91,11 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData)
// FIXME: if commit multiple times and the config changed?
if
(
!
pReader
->
cfgDone
)
{
char
fName
[
TSDB_FILENAME_LEN
];
if
(
pReader
->
pVnode
->
pTfs
)
{
snprintf
(
fName
,
TSDB_FILENAME_LEN
,
"%s%s%s%s%s"
,
tfsGetPrimaryPath
(
pReader
->
pVnode
->
pTfs
),
TD_DIRSEP
,
pReader
->
pVnode
->
path
,
TD_DIRSEP
,
VND_INFO_FNAME
);
}
else
{
snprintf
(
fName
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
pReader
->
pVnode
->
path
,
TD_DIRSEP
,
VND_INFO_FNAME
);
}
int32_t
offset
=
0
;
vnodeGetAbsDir
(
pReader
->
pVnode
->
path
,
pReader
->
pVnode
->
pTfs
,
fName
,
TSDB_FILENAME_LEN
);
offset
=
strlen
(
fName
);
snprintf
(
fName
+
offset
,
TSDB_FILENAME_LEN
-
offset
-
1
,
"%s%s"
,
TD_DIRSEP
,
VND_INFO_FNAME
);
TdFilePtr
pFile
=
taosOpenFile
(
fName
,
TD_FILE_READ
);
if
(
NULL
==
pFile
)
{
...
...
@@ -344,11 +343,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
};
if
(
pWriter
->
pVnode
->
pTfs
)
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
);
}
else
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s"
,
pWriter
->
pVnode
->
path
);
}
vnodeGetAbsDir
(
pVnode
->
path
,
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
vnodeCommitInfo
(
dir
);
}
else
{
...
...
@@ -400,12 +395,7 @@ static int32_t vnodeSnapWriteInfo(SVSnapWriter *pWriter, uint8_t *pData, uint32_
// modify info as needed
char
dir
[
TSDB_FILENAME_LEN
]
=
{
0
};
if
(
pWriter
->
pVnode
->
pTfs
)
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s%s%s"
,
tfsGetPrimaryPath
(
pWriter
->
pVnode
->
pTfs
),
TD_DIRSEP
,
pWriter
->
pVnode
->
path
);
}
else
{
snprintf
(
dir
,
TSDB_FILENAME_LEN
,
"%s"
,
pWriter
->
pVnode
->
path
);
}
vnodeGetAbsDir
(
pWriter
->
pVnode
->
path
,
pWriter
->
pVnode
->
pTfs
,
dir
,
TSDB_FILENAME_LEN
);
SVnodeStats
vndStats
=
pWriter
->
info
.
config
.
vndStats
;
SVnode
*
pVnode
=
pWriter
->
pVnode
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录