Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6702061f
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看板
提交
6702061f
编写于
8月 11, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/develop' into feature/os
上级
49944faf
fe6f96b1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
76 addition
and
23 deletion
+76
-23
src/balance/CMakeLists.txt
src/balance/CMakeLists.txt
+2
-2
src/tsdb/inc/tsdbMain.h
src/tsdb/inc/tsdbMain.h
+1
-0
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+67
-20
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+5
-0
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+1
-1
未找到文件。
src/balance/CMakeLists.txt
浏览文件 @
6702061f
...
...
@@ -3,11 +3,11 @@ PROJECT(TDengine)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/mnode/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/dnode/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/sdb/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/
t
sdb/inc
)
INCLUDE_DIRECTORIES
(
${
TD_ENTERPRISE_DIR
}
/src/inc
)
INCLUDE_DIRECTORIES
(
inc
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
IF
(
TD_LINUX
)
ADD_LIBRARY
(
balance
${
SRC
}
)
ENDIF
()
\ No newline at end of file
ENDIF
()
src/tsdb/inc/tsdbMain.h
浏览文件 @
6702061f
...
...
@@ -186,6 +186,7 @@ typedef struct {
typedef
struct
{
int
fileId
;
int
state
;
// 0 for health, 1 for problem
SFile
files
[
TSDB_FILE_TYPE_MAX
];
}
SFileGroup
;
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
6702061f
...
...
@@ -13,6 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include <regex.h>
#include "os.h"
#include "talgo.h"
#include "tchecksum.h"
...
...
@@ -23,10 +25,11 @@
const
char
*
tsdbFileSuffix
[]
=
{
".head"
,
".data"
,
".last"
,
".stat"
,
".h"
,
".d"
,
".l"
,
".s"
};
static
int
tsdbInitFile
(
SFile
*
pFile
,
STsdbRepo
*
pRepo
,
int
fid
,
int
type
);
static
void
tsdbDestroyFile
(
SFile
*
pFile
);
static
int
compFGroup
(
const
void
*
arg1
,
const
void
*
arg2
);
static
int
keyFGroupCompFunc
(
const
void
*
key
,
const
void
*
fgroup
);
static
int
tsdbInitFile
(
SFile
*
pFile
,
STsdbRepo
*
pRepo
,
int
fid
,
int
type
);
static
void
tsdbDestroyFile
(
SFile
*
pFile
);
static
int
compFGroup
(
const
void
*
arg1
,
const
void
*
arg2
);
static
int
keyFGroupCompFunc
(
const
void
*
key
,
const
void
*
fgroup
);
static
void
tsdbInitFileGroup
(
SFileGroup
*
pFGroup
,
STsdbRepo
*
pRepo
);
// ---------------- INTERNAL FUNCTIONS ----------------
STsdbFileH
*
tsdbNewFileH
(
STsdbCfg
*
pCfg
)
{
...
...
@@ -69,12 +72,14 @@ void tsdbFreeFileH(STsdbFileH *pFileH) {
int
tsdbOpenFileH
(
STsdbRepo
*
pRepo
)
{
ASSERT
(
pRepo
!=
NULL
&&
pRepo
->
tsdbFileH
!=
NULL
);
char
*
tDataDir
=
NULL
;
DIR
*
dir
=
NULL
;
int
fid
=
0
;
int
vid
=
0
;
char
*
tDataDir
=
NULL
;
DIR
*
dir
=
NULL
;
int
fid
=
0
;
int
vid
=
0
;
regex_t
regex1
,
regex2
;
int
code
=
0
;
SFileGroup
fileGroup
=
{
0
};
SFileGroup
fileGroup
=
{
0
};
STsdbFileH
*
pFileH
=
pRepo
->
tsdbFileH
;
tDataDir
=
tsdbGetDataDirName
(
pRepo
->
rootDir
);
...
...
@@ -90,28 +95,56 @@ int tsdbOpenFileH(STsdbRepo *pRepo) {
goto
_err
;
}
code
=
regcomp
(
&
regex1
,
"^v[0-9]+f[0-9]+
\\
.(head|data|last|stat)$"
,
REG_EXTENDED
);
if
(
code
!=
0
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_err
;
}
code
=
regcomp
(
&
regex2
,
"^v[0-9]+f[0-9]+
\\
.(h|d|l|s)$"
,
REG_EXTENDED
);
if
(
code
!=
0
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_err
;
}
struct
dirent
*
dp
=
NULL
;
while
((
dp
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strncmp
(
dp
->
d_name
,
"."
,
1
)
==
0
||
strncmp
(
dp
->
d_name
,
".."
,
2
)
==
0
)
continue
;
sscanf
(
dp
->
d_name
,
"v%df%d"
,
&
vid
,
&
fid
);
if
(
tsdbSearchFGroup
(
pRepo
->
tsdbFileH
,
fid
,
TD_EQ
)
!=
NULL
)
continue
;
if
(
strcmp
(
dp
->
d_name
,
"."
)
==
0
||
strcmp
(
dp
->
d_name
,
".."
)
==
0
)
continue
;
code
=
regexec
(
&
regex1
,
dp
->
d_name
,
0
,
NULL
,
0
);
if
(
code
==
0
)
{
sscanf
(
dp
->
d_name
,
"v%df%d"
,
&
vid
,
&
fid
);
if
(
vid
!=
REPO_ID
(
pRepo
))
{
tsdbError
(
"vgId:%d invalid file %s exists, ignore it"
,
REPO_ID
(
pRepo
),
dp
->
d_name
);
continue
;
}
memset
((
void
*
)(
&
fileGroup
),
0
,
sizeof
(
SFileGroup
));
fileGroup
.
fileId
=
fid
;
for
(
int
type
=
0
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
if
(
tsdbInitFile
(
&
fileGroup
.
files
[
type
],
pRepo
,
fid
,
type
)
<
0
)
{
tsdbError
(
"vgId:%d failed to init file fid %d type %d"
,
REPO_ID
(
pRepo
),
fid
,
type
);
if
(
tsdbSearchFGroup
(
pFileH
,
fid
,
TD_EQ
)
!=
NULL
)
continue
;
memset
((
void
*
)(
&
fileGroup
),
0
,
sizeof
(
SFileGroup
));
fileGroup
.
fileId
=
fid
;
tsdbInitFileGroup
(
&
fileGroup
,
pRepo
);
}
else
if
(
code
==
REG_NOMATCH
)
{
code
=
regexec
(
&
regex2
,
dp
->
d_name
,
0
,
NULL
,
0
);
if
(
code
==
0
)
{
tsdbDebug
(
"vgId:%d invalid file %s exists, remove it"
,
REPO_ID
(
pRepo
),
dp
->
d_name
);
remove
(
dp
->
d_name
);
}
else
if
(
code
==
REG_NOMATCH
)
{
tsdbError
(
"vgId:%d invalid file %s exists, ignore it"
,
REPO_ID
(
pRepo
),
dp
->
d_name
);
continue
;
}
else
{
goto
_err
;
}
}
else
{
goto
_err
;
}
tsdbDebug
(
"vgId:%d file group %d init"
,
REPO_ID
(
pRepo
),
fid
);
pFileH
->
pFGroup
[
pFileH
->
nFGroups
++
]
=
fileGroup
;
qsort
((
void
*
)(
pFileH
->
pFGroup
),
pFileH
->
nFGroups
,
sizeof
(
SFileGroup
),
compFGroup
);
}
regfree
(
&
regex1
);
regfree
(
&
regex2
);
taosTFree
(
tDataDir
);
closedir
(
dir
);
return
0
;
...
...
@@ -119,6 +152,9 @@ int tsdbOpenFileH(STsdbRepo *pRepo) {
_err:
for
(
int
type
=
0
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
tsdbDestroyFile
(
&
fileGroup
.
files
[
type
]);
regfree
(
&
regex1
);
regfree
(
&
regex2
);
taosTFree
(
tDataDir
);
if
(
dir
!=
NULL
)
closedir
(
dir
);
tsdbCloseFileH
(
pRepo
);
...
...
@@ -450,3 +486,14 @@ static int keyFGroupCompFunc(const void *key, const void *fgroup) {
return
fid
>
pFGroup
->
fileId
?
1
:
-
1
;
}
}
static
void
tsdbInitFileGroup
(
SFileGroup
*
pFGroup
,
STsdbRepo
*
pRepo
)
{
for
(
int
type
=
0
;
type
<
TSDB_FILE_TYPE_MAX
;
type
++
)
{
if
(
tsdbInitFile
(
&
pFGroup
->
files
[
type
],
pRepo
,
pFGroup
->
fileId
,
type
)
<
0
)
{
memset
(
&
pFGroup
->
files
[
type
].
info
,
0
,
sizeof
(
STsdbFileInfo
));
pFGroup
->
files
[
type
].
info
.
magic
=
TSDB_FILE_INIT_MAGIC
;
pFGroup
->
state
=
1
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
}
}
}
\ No newline at end of file
src/tsdb/src/tsdbMain.c
浏览文件 @
6702061f
...
...
@@ -71,6 +71,8 @@ static void tsdbStopStream(STsdbRepo *pRepo);
// Function declaration
int32_t
tsdbCreateRepo
(
char
*
rootDir
,
STsdbCfg
*
pCfg
)
{
taosRemoveDir
(
rootDir
);
if
(
mkdir
(
rootDir
,
0755
)
<
0
)
{
tsdbError
(
"vgId:%d failed to create rootDir %s since %s"
,
pCfg
->
tsdbId
,
rootDir
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
...
@@ -95,6 +97,8 @@ TSDB_REPO_T *tsdbOpenRepo(char *rootDir, STsdbAppH *pAppH) {
STsdbCfg
config
=
{
0
};
STsdbRepo
*
pRepo
=
NULL
;
terrno
=
TSDB_CODE_SUCCESS
;
if
(
tsdbLoadConfig
(
rootDir
,
&
config
)
<
0
)
{
tsdbError
(
"failed to open repo in rootDir %s since %s"
,
rootDir
,
tstrerror
(
terrno
));
return
NULL
;
...
...
@@ -799,6 +803,7 @@ static int tsdbRestoreInfo(STsdbRepo *pRepo) {
tsdbInitFileGroupIter
(
pFileH
,
&
iter
,
TSDB_ORDER_DESC
);
while
((
pFGroup
=
tsdbGetFileGroupNext
(
&
iter
))
!=
NULL
)
{
if
(
pFGroup
->
state
)
continue
;
if
(
tsdbSetAndOpenHelperFile
(
&
rhelper
,
pFGroup
)
<
0
)
goto
_err
;
if
(
tsdbLoadCompIdx
(
&
rhelper
,
NULL
)
<
0
)
goto
_err
;
for
(
int
i
=
1
;
i
<
pMeta
->
maxTables
;
i
++
)
{
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
6702061f
...
...
@@ -257,7 +257,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
if
(
pVnode
->
tsdb
==
NULL
)
{
vnodeCleanUp
(
pVnode
);
return
terrno
;
}
else
if
(
terrno
!=
0
&&
pVnode
->
syncCfg
.
replica
<=
1
)
{
}
else
if
(
terrno
!=
TSDB_CODE_SUCCESS
&&
pVnode
->
syncCfg
.
replica
<=
1
)
{
vError
(
"vgId:%d, failed to open tsdb, replica:%d reason:%s"
,
pVnode
->
vgId
,
pVnode
->
syncCfg
.
replica
,
tstrerror
(
terrno
));
vnodeCleanUp
(
pVnode
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录