Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b7342525
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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,发现更多精彩内容 >>
提交
b7342525
编写于
10月 18, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
bb59553e
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
50 addition
and
42 deletion
+50
-42
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+1
-1
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+2
-0
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+3
-3
source/dnode/vnode/src/meta/metaOpen.c
source/dnode/vnode/src/meta/metaOpen.c
+1
-1
source/dnode/vnode/src/sma/smaOpen.c
source/dnode/vnode/src/sma/smaOpen.c
+14
-14
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbOpen.c
source/dnode/vnode/src/tsdb/tsdbOpen.c
+2
-2
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+17
-13
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+9
-7
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
b7342525
...
...
@@ -247,7 +247,7 @@ void tsdbSmaFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSmaFile *pSmaF, ch
// SDelFile
void
tsdbDelFileName
(
STsdb
*
pTsdb
,
SDelFile
*
pFile
,
char
fname
[]);
// tsdbFS.c ==============================================================================================
int32_t
tsdbFSOpen
(
STsdb
*
pTsdb
);
int32_t
tsdbFSOpen
(
STsdb
*
pTsdb
,
int8_t
rollback
);
int32_t
tsdbFSClose
(
STsdb
*
pTsdb
);
int32_t
tsdbFSCopy
(
STsdb
*
pTsdb
,
STsdbFS
*
pFS
);
void
tsdbFSDestroy
(
STsdbFS
*
pFS
);
...
...
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
b7342525
...
...
@@ -87,11 +87,13 @@ int32_t vnodeGetBatchMeta(SVnode* pVnode, SRpcMsg* pMsg);
int32_t
vnodeBegin
(
SVnode
*
pVnode
);
int32_t
vnodeShouldCommit
(
SVnode
*
pVnode
);
int32_t
vnodeCommit
(
SVnode
*
pVnode
);
void
vnodeRollback
(
SVnode
*
pVnode
);
int32_t
vnodeSaveInfo
(
const
char
*
dir
,
const
SVnodeInfo
*
pCfg
);
int32_t
vnodeCommitInfo
(
const
char
*
dir
,
const
SVnodeInfo
*
pInfo
);
int32_t
vnodeLoadInfo
(
const
char
*
dir
,
SVnodeInfo
*
pInfo
);
int32_t
vnodeSyncCommit
(
SVnode
*
pVnode
);
int32_t
vnodeAsyncCommit
(
SVnode
*
pVnode
);
bool
vnodeShouldRollback
(
SVnode
*
pVnode
);
// vnodeSync.c
int32_t
vnodeSyncOpen
(
SVnode
*
pVnode
,
char
*
path
);
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
b7342525
...
...
@@ -97,7 +97,7 @@ typedef struct SMCtbCursor SMCtbCursor;
typedef
struct
SMStbCursor
SMStbCursor
;
typedef
struct
STbUidStore
STbUidStore
;
int
metaOpen
(
SVnode
*
pVnode
,
SMeta
**
ppMeta
);
int
metaOpen
(
SVnode
*
pVnode
,
SMeta
**
ppMeta
,
int8_t
rollback
);
int
metaClose
(
SMeta
*
pMeta
);
int
metaBegin
(
SMeta
*
pMeta
,
int8_t
fromSys
);
int
metaCommit
(
SMeta
*
pMeta
);
...
...
@@ -149,7 +149,7 @@ typedef struct {
int32_t
metaGetStbStats
(
SMeta
*
pMeta
,
int64_t
uid
,
SMetaStbStats
*
pInfo
);
// tsdb
int
tsdbOpen
(
SVnode
*
pVnode
,
STsdb
**
ppTsdb
,
const
char
*
dir
,
STsdbKeepCfg
*
pKeepCfg
);
int
tsdbOpen
(
SVnode
*
pVnode
,
STsdb
**
ppTsdb
,
const
char
*
dir
,
STsdbKeepCfg
*
pKeepCfg
,
int8_t
rollback
);
int
tsdbClose
(
STsdb
**
pTsdb
);
int32_t
tsdbBegin
(
STsdb
*
pTsdb
);
int32_t
tsdbCommit
(
STsdb
*
pTsdb
);
...
...
@@ -200,7 +200,7 @@ SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchem
// sma
int32_t
smaInit
();
void
smaCleanUp
();
int32_t
smaOpen
(
SVnode
*
pVnode
);
int32_t
smaOpen
(
SVnode
*
pVnode
,
int8_t
rollback
);
int32_t
smaClose
(
SSma
*
pSma
);
int32_t
smaBegin
(
SSma
*
pSma
);
int32_t
smaSyncPreCommit
(
SSma
*
pSma
);
...
...
source/dnode/vnode/src/meta/metaOpen.c
浏览文件 @
b7342525
...
...
@@ -27,7 +27,7 @@ static int taskIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int k
static
int32_t
metaInitLock
(
SMeta
*
pMeta
)
{
return
taosThreadRwlockInit
(
&
pMeta
->
lock
,
NULL
);
}
static
int32_t
metaDestroyLock
(
SMeta
*
pMeta
)
{
return
taosThreadRwlockDestroy
(
&
pMeta
->
lock
);
}
int
metaOpen
(
SVnode
*
pVnode
,
SMeta
**
ppMeta
)
{
int
metaOpen
(
SVnode
*
pVnode
,
SMeta
**
ppMeta
,
int8_t
rollback
)
{
SMeta
*
pMeta
=
NULL
;
int
ret
;
int
slen
;
...
...
source/dnode/vnode/src/sma/smaOpen.c
浏览文件 @
b7342525
...
...
@@ -29,19 +29,19 @@ static int32_t rsmaRestore(SSma *pSma);
pKeepCfg->days = smaEvalDays(v, pCfg->retentions, l, pCfg->precision, pCfg->days); \
} while (0)
#define SMA_OPEN_RSMA_IMPL(v, l) \
do { \
SRetention *r = (SRetention *)VND_RETENTIONS(v) + l; \
if (!RETENTION_VALID(r)) { \
if (l == 0) { \
goto _err; \
} \
break; \
} \
smaSetKeepCfg(v, &keepCfg, pCfg, TSDB_TYPE_RSMA_L##l); \
if (tsdbOpen(v, &SMA_RSMA_TSDB##l(pSma), VNODE_RSMA##l##_DIR, &keepCfg) < 0) { \
goto _err; \
} \
#define SMA_OPEN_RSMA_IMPL(v, l)
\
do {
\
SRetention *r = (SRetention *)VND_RETENTIONS(v) + l;
\
if (!RETENTION_VALID(r)) {
\
if (l == 0) {
\
goto _err;
\
}
\
break;
\
}
\
smaSetKeepCfg(v, &keepCfg, pCfg, TSDB_TYPE_RSMA_L##l);
\
if (tsdbOpen(v, &SMA_RSMA_TSDB##l(pSma), VNODE_RSMA##l##_DIR, &keepCfg
, rollback
) < 0) { \
goto _err;
\
}
\
} while (0)
/**
...
...
@@ -119,7 +119,7 @@ int smaSetKeepCfg(SVnode *pVnode, STsdbKeepCfg *pKeepCfg, STsdbCfg *pCfg, int ty
return
0
;
}
int32_t
smaOpen
(
SVnode
*
pVnode
)
{
int32_t
smaOpen
(
SVnode
*
pVnode
,
int8_t
rollback
)
{
STsdbCfg
*
pCfg
=
&
pVnode
->
config
.
tsdbCfg
;
ASSERT
(
!
pVnode
->
pSma
);
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
b7342525
...
...
@@ -415,7 +415,7 @@ _err:
}
// EXPOSED APIS ====================================================================================
int32_t
tsdbFSOpen
(
STsdb
*
pTsdb
)
{
int32_t
tsdbFSOpen
(
STsdb
*
pTsdb
,
int8_t
rollback
)
{
int32_t
code
=
0
;
SVnode
*
pVnode
=
pTsdb
->
pVnode
;
...
...
source/dnode/vnode/src/tsdb/tsdbOpen.c
浏览文件 @
b7342525
...
...
@@ -33,7 +33,7 @@ int32_t tsdbSetKeepCfg(STsdb *pTsdb, STsdbCfg *pCfg) {
* @param dir
* @return int
*/
int
tsdbOpen
(
SVnode
*
pVnode
,
STsdb
**
ppTsdb
,
const
char
*
dir
,
STsdbKeepCfg
*
pKeepCfg
)
{
int
tsdbOpen
(
SVnode
*
pVnode
,
STsdb
**
ppTsdb
,
const
char
*
dir
,
STsdbKeepCfg
*
pKeepCfg
,
int8_t
rollback
)
{
STsdb
*
pTsdb
=
NULL
;
int
slen
=
0
;
...
...
@@ -66,7 +66,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
}
// open tsdb
if
(
tsdbFSOpen
(
pTsdb
)
<
0
)
{
if
(
tsdbFSOpen
(
pTsdb
,
rollback
)
<
0
)
{
goto
_err
;
}
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
b7342525
...
...
@@ -20,8 +20,6 @@
static
int
vnodeEncodeInfo
(
const
SVnodeInfo
*
pInfo
,
char
**
ppData
);
static
int
vnodeDecodeInfo
(
uint8_t
*
pData
,
SVnodeInfo
*
pInfo
);
static
int
vnodeStartCommit
(
SVnode
*
pVnode
);
static
int
vnodeEndCommit
(
SVnode
*
pVnode
);
static
int
vnodeCommitImpl
(
void
*
arg
);
static
void
vnodeWaitCommit
(
SVnode
*
pVnode
);
...
...
@@ -241,7 +239,7 @@ int vnodeCommit(SVnode *pVnode) {
// preCommit
// smaSyncPreCommit(pVnode->pSma);
if
(
smaAsyncPreCommit
(
pVnode
->
pSma
)
<
0
)
{
if
(
smaAsyncPreCommit
(
pVnode
->
pSma
)
<
0
)
{
vError
(
"vgId:%d, failed to async pre-commit sma since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
return
-
1
;
}
...
...
@@ -309,6 +307,22 @@ int vnodeCommit(SVnode *pVnode) {
return
0
;
}
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
);
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
);
(
void
)
taosRemoveFile
(
tFName
);
}
static
int
vnodeCommitImpl
(
void
*
arg
)
{
SVnode
*
pVnode
=
(
SVnode
*
)
arg
;
...
...
@@ -321,16 +335,6 @@ static int vnodeCommitImpl(void *arg) {
return
0
;
}
static
int
vnodeStartCommit
(
SVnode
*
pVnode
)
{
// TODO
return
0
;
}
static
int
vnodeEndCommit
(
SVnode
*
pVnode
)
{
// TODO
return
0
;
}
static
FORCE_INLINE
void
vnodeWaitCommit
(
SVnode
*
pVnode
)
{
tsem_wait
(
&
pVnode
->
canCommit
);
}
static
int
vnodeEncodeState
(
const
void
*
pObj
,
SJson
*
pJson
)
{
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
b7342525
...
...
@@ -110,6 +110,8 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
taosThreadMutexInit
(
&
pVnode
->
mutex
,
NULL
);
taosThreadCondInit
(
&
pVnode
->
poolNotEmpty
,
NULL
);
int8_t
rollback
=
vnodeShouldRollback
(
pVnode
);
// open buffer pool
if
(
vnodeOpenBufPool
(
pVnode
)
<
0
)
{
vError
(
"vgId:%d, failed to open vnode buffer pool since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
...
...
@@ -117,19 +119,19 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
}
// open meta
if
(
metaOpen
(
pVnode
,
&
pVnode
->
pMeta
)
<
0
)
{
if
(
metaOpen
(
pVnode
,
&
pVnode
->
pMeta
,
rollback
)
<
0
)
{
vError
(
"vgId:%d, failed to open vnode meta since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open tsdb
if
(
!
VND_IS_RSMA
(
pVnode
)
&&
tsdbOpen
(
pVnode
,
&
VND_TSDB
(
pVnode
),
VNODE_TSDB_DIR
,
NULL
)
<
0
)
{
if
(
!
VND_IS_RSMA
(
pVnode
)
&&
tsdbOpen
(
pVnode
,
&
VND_TSDB
(
pVnode
),
VNODE_TSDB_DIR
,
NULL
,
rollback
)
<
0
)
{
vError
(
"vgId:%d, failed to open vnode tsdb since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open sma
if
(
smaOpen
(
pVnode
))
{
if
(
smaOpen
(
pVnode
,
rollback
))
{
vError
(
"vgId:%d, failed to open vnode sma since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
...
...
@@ -153,14 +155,12 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
goto
_err
;
}
#if !VNODE_AS_LIB
// open query
if
(
vnodeQueryOpen
(
pVnode
))
{
vError
(
"vgId:%d, failed to open vnode query since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
#endif
// vnode begin
if
(
vnodeBegin
(
pVnode
)
<
0
)
{
...
...
@@ -169,13 +169,15 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
goto
_err
;
}
#if !VNODE_AS_LIB
// open sync
if
(
vnodeSyncOpen
(
pVnode
,
dir
))
{
vError
(
"vgId:%d, failed to open sync since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
#endif
if
(
rollback
)
{
vnodeRollback
(
pVnode
);
}
return
pVnode
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录