Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5be089b8
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
5be089b8
编写于
6月 28, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: rsma restore
上级
1bcdca11
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
325 addition
and
321 deletion
+325
-321
source/dnode/vnode/src/inc/sma.h
source/dnode/vnode/src/inc/sma.h
+12
-11
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-1
source/dnode/vnode/src/sma/smaOpen.c
source/dnode/vnode/src/sma/smaOpen.c
+1
-7
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+286
-281
source/dnode/vnode/src/sma/smaUtil.c
source/dnode/vnode/src/sma/smaUtil.c
+23
-19
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+2
-2
未找到文件。
source/dnode/vnode/src/inc/sma.h
浏览文件 @
5be089b8
...
...
@@ -28,7 +28,8 @@ extern "C" {
#define smaError(...) do { if (smaDebugFlag & DEBUG_ERROR) { taosPrintLog("SMA ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
#define smaWarn(...) do { if (smaDebugFlag & DEBUG_WARN) { taosPrintLog("SMA WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
#define smaInfo(...) do { if (smaDebugFlag & DEBUG_INFO) { taosPrintLog("SMA ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
#define smaDebug(...) do { if (smaDebugFlag & DEBUG_DEBUG) { taosPrintLog("SMA ", DEBUG_DEBUG, tsdbDebugFlag, __VA_ARGS__); }} while(0)
// #define smaDebug(...) do { if (smaDebugFlag & DEBUG_DEBUG) { taosPrintLog("SMA ", DEBUG_DEBUG, tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define smaDebug(...) do { if (smaDebugFlag & DEBUG_WARN) { taosPrintLog("SMA WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
#define smaTrace(...) do { if (smaDebugFlag & DEBUG_TRACE) { taosPrintLog("SMA ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
// clang-format on
...
...
@@ -205,16 +206,16 @@ struct STFile {
uint8_t
state
;
};
#define TD_FILE_F(tf) (&((tf)->f))
#define TD_FILE_PFILE(tf) ((tf)->pFile)
#define TD_
FILE_OPENED(tf) (TD_
FILE_PFILE(tf) != NULL)
#define TD_
FILE_FULL_NAME(tf) (TD_
FILE_F(tf)->aname)
#define TD_
FILE_REL_NAME(tf) (TD_
FILE_F(tf)->rname)
#define TD_
FILE_OPENED(tf) (TD_
FILE_PFILE(tf) != NULL)
#define TD_
FILE_CLOSED(tf) (!TD_
FILE_OPENED(tf))
#define TD_
FILE_SET_CLOSED(f) (TD_
FILE_PFILE(f) = NULL)
#define TD_FILE_SET_STATE(tf, s) ((tf)->state = (s))
#define TD_
FILE_DID(tf) (TD_
FILE_F(tf)->did)
#define TD_
T
FILE_F(tf) (&((tf)->f))
#define TD_
T
FILE_PFILE(tf) ((tf)->pFile)
#define TD_
TFILE_OPENED(tf) (TD_T
FILE_PFILE(tf) != NULL)
#define TD_
TFILE_FULL_NAME(tf) (TD_T
FILE_F(tf)->aname)
#define TD_
TFILE_REL_NAME(tf) (TD_T
FILE_F(tf)->rname)
#define TD_
TFILE_OPENED(tf) (TD_T
FILE_PFILE(tf) != NULL)
#define TD_
TFILE_CLOSED(tf) (!TD_T
FILE_OPENED(tf))
#define TD_
TFILE_SET_CLOSED(f) (TD_T
FILE_PFILE(f) = NULL)
#define TD_
T
FILE_SET_STATE(tf, s) ((tf)->state = (s))
#define TD_
TFILE_DID(tf) (TD_T
FILE_F(tf)->did)
int32_t
tdInitTFile
(
STFile
*
pTFile
,
STfs
*
pTfs
,
const
char
*
fname
);
int32_t
tdCreateTFile
(
STFile
*
pTFile
,
STfs
*
pTfs
,
bool
updateHeader
,
int8_t
fType
);
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
5be089b8
...
...
@@ -64,6 +64,7 @@ typedef struct STsdbSnapshotReader STsdbSnapshotReader;
#define VNODE_TQ_DIR "tq"
#define VNODE_WAL_DIR "wal"
#define VNODE_TSMA_DIR "tsma"
#define VNODE_RSMA_DIR "rsma"
#define VNODE_RSMA0_DIR "tsdb"
#define VNODE_RSMA1_DIR "rsma1"
#define VNODE_RSMA2_DIR "rsma2"
...
...
@@ -161,7 +162,6 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool
// sma
int32_t
smaOpen
(
SVnode
*
pVnode
);
int32_t
smaClose
(
SSma
*
pSma
);
int32_t
smaCloseEnv
(
SSma
*
pSma
);
int32_t
smaCloseEx
(
SSma
*
pSma
);
...
...
source/dnode/vnode/src/sma/smaOpen.c
浏览文件 @
5be089b8
...
...
@@ -123,7 +123,7 @@ int32_t smaOpen(SVnode *pVnode) {
}
// restore the rsma
#if
0
#if
1
if
(
rsmaRestore
(
pSma
)
<
0
)
{
goto
_err
;
}
...
...
@@ -154,12 +154,6 @@ int32_t smaCloseEx(SSma *pSma) {
return
0
;
}
int32_t
smaClose
(
SSma
*
pSma
)
{
smaCloseEnv
(
pSma
);
smaCloseEx
(
pSma
);
return
0
;
}
/**
* @brief rsma env restore
*
...
...
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
5be089b8
此差异已折叠。
点击以展开。
source/dnode/vnode/src/sma/smaUtil.c
浏览文件 @
5be089b8
...
...
@@ -22,7 +22,6 @@
#define TD_FILE_INIT_MAGIC 0xFFFFFFFF
static
int32_t
tdEncodeTFInfo
(
void
**
buf
,
STFInfo
*
pInfo
);
static
void
*
tdDecodeTFInfo
(
void
*
buf
,
STFInfo
*
pInfo
);
...
...
@@ -46,7 +45,7 @@ static void *tdDecodeTFInfo(void *buf, STFInfo *pInfo) {
}
int64_t
tdWriteTFile
(
STFile
*
pTFile
,
void
*
buf
,
int64_t
nbyte
)
{
ASSERT
(
TD_FILE_OPENED
(
pTFile
));
ASSERT
(
TD_
T
FILE_OPENED
(
pTFile
));
int64_t
nwrite
=
taosWriteFile
(
pTFile
->
pFile
,
buf
,
nbyte
);
if
(
nwrite
<
nbyte
)
{
...
...
@@ -58,9 +57,9 @@ int64_t tdWriteTFile(STFile *pTFile, void *buf, int64_t nbyte) {
}
int64_t
tdSeekTFile
(
STFile
*
pTFile
,
int64_t
offset
,
int
whence
)
{
ASSERT
(
TD_FILE_OPENED
(
pTFile
));
ASSERT
(
TD_
T
FILE_OPENED
(
pTFile
));
int64_t
loffset
=
taosLSeekFile
(
TD_FILE_PFILE
(
pTFile
),
offset
,
whence
);
int64_t
loffset
=
taosLSeekFile
(
TD_
T
FILE_PFILE
(
pTFile
),
offset
,
whence
);
if
(
loffset
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
...
...
@@ -70,12 +69,12 @@ int64_t tdSeekTFile(STFile *pTFile, int64_t offset, int whence) {
}
int64_t
tdGetTFileSize
(
STFile
*
pTFile
,
int64_t
*
size
)
{
ASSERT
(
TD_FILE_OPENED
(
pTFile
));
ASSERT
(
TD_
T
FILE_OPENED
(
pTFile
));
return
taosFStatFile
(
pTFile
->
pFile
,
size
,
NULL
);
}
int64_t
tdReadTFile
(
STFile
*
pTFile
,
void
*
buf
,
int64_t
nbyte
)
{
ASSERT
(
TD_FILE_OPENED
(
pTFile
));
ASSERT
(
TD_
T
FILE_OPENED
(
pTFile
));
int64_t
nread
=
taosReadFile
(
pTFile
->
pFile
,
buf
,
nbyte
);
if
(
nread
<
0
)
{
...
...
@@ -108,7 +107,7 @@ int32_t tdLoadTFileHeader(STFile *pTFile, STFInfo *pInfo) {
char
buf
[
TD_FILE_HEAD_SIZE
]
=
"
\0
"
;
uint32_t
_version
;
ASSERT
(
TD_FILE_OPENED
(
pTFile
));
ASSERT
(
TD_
T
FILE_OPENED
(
pTFile
));
if
(
tdSeekTFile
(
pTFile
,
0
,
SEEK_SET
)
<
0
)
{
return
-
1
;
...
...
@@ -133,7 +132,7 @@ void tdUpdateTFileMagic(STFile *pTFile, void *pCksm) {
}
int64_t
tdAppendTFile
(
STFile
*
pTFile
,
void
*
buf
,
int64_t
nbyte
,
int64_t
*
offset
)
{
ASSERT
(
TD_FILE_OPENED
(
pTFile
));
ASSERT
(
TD_
T
FILE_OPENED
(
pTFile
));
int64_t
toffset
;
...
...
@@ -141,6 +140,11 @@ int64_t tdAppendTFile(STFile *pTFile, void *buf, int64_t nbyte, int64_t *offset)
return
-
1
;
}
#if 1
smaDebug
(
"append to file %s, offset:%"
PRIi64
" + nbyte:%"
PRIi64
" =%"
PRIi64
,
TD_TFILE_FULL_NAME
(
pTFile
),
toffset
,
nbyte
,
toffset
+
nbyte
);
#endif
ASSERT
(
pTFile
->
info
.
fsize
==
toffset
);
if
(
offset
)
{
...
...
@@ -157,9 +161,9 @@ int64_t tdAppendTFile(STFile *pTFile, void *buf, int64_t nbyte, int64_t *offset)
}
int32_t
tdOpenTFile
(
STFile
*
pTFile
,
int
flags
)
{
ASSERT
(
!
TD_FILE_OPENED
(
pTFile
));
ASSERT
(
!
TD_
T
FILE_OPENED
(
pTFile
));
pTFile
->
pFile
=
taosOpenFile
(
TD_FILE_FULL_NAME
(
pTFile
),
flags
);
pTFile
->
pFile
=
taosOpenFile
(
TD_
T
FILE_FULL_NAME
(
pTFile
),
flags
);
if
(
pTFile
->
pFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
...
...
@@ -169,9 +173,9 @@ int32_t tdOpenTFile(STFile *pTFile, int flags) {
}
void
tdCloseTFile
(
STFile
*
pTFile
)
{
if
(
TD_FILE_OPENED
(
pTFile
))
{
if
(
TD_
T
FILE_OPENED
(
pTFile
))
{
taosCloseFile
(
&
pTFile
->
pFile
);
TD_FILE_SET_CLOSED
(
pTFile
);
TD_
T
FILE_SET_CLOSED
(
pTFile
);
}
}
...
...
@@ -183,8 +187,8 @@ int32_t tdInitTFile(STFile *pTFile, STfs *pTfs, const char *fname) {
char
fullname
[
TSDB_FILENAME_LEN
];
SDiskID
did
=
{
0
};
TD_FILE_SET_STATE
(
pTFile
,
TD_FILE_STATE_OK
);
TD_FILE_SET_CLOSED
(
pTFile
);
TD_
T
FILE_SET_STATE
(
pTFile
,
TD_FILE_STATE_OK
);
TD_
T
FILE_SET_CLOSED
(
pTFile
);
memset
(
&
(
pTFile
->
info
),
0
,
sizeof
(
pTFile
->
info
));
pTFile
->
info
.
magic
=
TD_FILE_INIT_MAGIC
;
...
...
@@ -202,18 +206,18 @@ int32_t tdInitTFile(STFile *pTFile, STfs *pTfs, const char *fname) {
int32_t
tdCreateTFile
(
STFile
*
pTFile
,
STfs
*
pTfs
,
bool
updateHeader
,
int8_t
fType
)
{
ASSERT
(
pTFile
->
info
.
fsize
==
0
&&
pTFile
->
info
.
magic
==
TD_FILE_INIT_MAGIC
);
pTFile
->
pFile
=
taosOpenFile
(
TD_FILE_FULL_NAME
(
pTFile
),
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
pTFile
->
pFile
=
taosOpenFile
(
TD_
T
FILE_FULL_NAME
(
pTFile
),
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pTFile
->
pFile
==
NULL
)
{
if
(
errno
==
ENOENT
)
{
// Try to create directory recursively
char
*
s
=
strdup
(
TD_FILE_REL_NAME
(
pTFile
));
if
(
tfsMkdirRecurAt
(
pTfs
,
taosDirName
(
s
),
TD_FILE_DID
(
pTFile
))
<
0
)
{
char
*
s
=
strdup
(
TD_
T
FILE_REL_NAME
(
pTFile
));
if
(
tfsMkdirRecurAt
(
pTfs
,
taosDirName
(
s
),
TD_
T
FILE_DID
(
pTFile
))
<
0
)
{
taosMemoryFreeClear
(
s
);
return
-
1
;
}
taosMemoryFreeClear
(
s
);
pTFile
->
pFile
=
taosOpenFile
(
TD_FILE_FULL_NAME
(
pTFile
),
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
pTFile
->
pFile
=
taosOpenFile
(
TD_
T
FILE_FULL_NAME
(
pTFile
),
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pTFile
->
pFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
...
...
@@ -240,7 +244,7 @@ int32_t tdCreateTFile(STFile *pTFile, STfs *pTfs, bool updateHeader, int8_t fTyp
return
0
;
}
int32_t
tdRemoveTFile
(
STFile
*
pTFile
)
{
return
tfsRemoveFile
(
TD_FILE_F
(
pTFile
));
}
int32_t
tdRemoveTFile
(
STFile
*
pTFile
)
{
return
tfsRemoveFile
(
TD_
T
FILE_F
(
pTFile
));
}
// smaXXXUtil ================
// ...
\ No newline at end of file
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
5be089b8
...
...
@@ -152,14 +152,14 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
return
pVnode
;
_err:
if
(
pVnode
->
pSma
)
smaClose
(
pVnode
->
pSma
);
if
(
pVnode
->
pSma
)
smaClose
Env
(
pVnode
->
pSma
);
if
(
pVnode
->
pQuery
)
vnodeQueryClose
(
pVnode
);
if
(
pVnode
->
pTq
)
tqClose
(
pVnode
->
pTq
);
if
(
pVnode
->
pWal
)
walClose
(
pVnode
->
pWal
);
if
(
pVnode
->
pTsdb
)
tsdbClose
(
&
pVnode
->
pTsdb
);
if
(
pVnode
->
pSma
)
smaCloseEx
(
pVnode
->
pSma
);
if
(
pVnode
->
pMeta
)
metaClose
(
pVnode
->
pMeta
);
tsem_destroy
(
&
(
pVnode
->
canCommit
));
taosMemoryFree
(
pVnode
);
return
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录