Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
37922f29
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
37922f29
编写于
9月 08, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1263
上级
e69fbd54
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
71 addition
and
36 deletion
+71
-36
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+0
-4
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+0
-1
src/common/src/tglobal.c
src/common/src/tglobal.c
+0
-10
src/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+0
-5
src/os/inc/osDir.h
src/os/inc/osDir.h
+1
-0
src/os/src/alpine/alpineEnv.c
src/os/src/alpine/alpineEnv.c
+0
-1
src/os/src/darwin/darwinEnv.c
src/os/src/darwin/darwinEnv.c
+0
-1
src/os/src/detail/osDir.c
src/os/src/detail/osDir.c
+44
-5
src/os/src/linux/linuxEnv.c
src/os/src/linux/linuxEnv.c
+0
-2
src/os/src/windows/wEnv.c
src/os/src/windows/wEnv.c
+0
-2
src/util/src/tlog.c
src/util/src/tlog.c
+19
-4
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+7
-1
未找到文件。
src/client/src/tscSystem.c
浏览文件 @
37922f29
...
...
@@ -94,10 +94,6 @@ void taos_init_imp(void) {
printf
(
"failed to create log dir:%s
\n
"
,
tsLogDir
);
}
if
(
mkdir
(
tsLogbakDir
,
0755
)
!=
0
&&
errno
!=
EEXIST
)
{
printf
(
"failed to create logbak dir:%s
\n
"
,
tsLogbakDir
);
}
sprintf
(
temp
,
"%s/taoslog"
,
tsLogDir
);
if
(
taosInitLog
(
temp
,
tsNumOfLogLines
,
10
)
<
0
)
{
printf
(
"failed to open log file in directory:%s
\n
"
,
tsLogDir
);
...
...
src/common/inc/tglobal.h
浏览文件 @
37922f29
...
...
@@ -126,7 +126,6 @@ extern char tsDnodeDir[];
extern
char
tsMnodeDir
[];
extern
char
tsDataDir
[];
extern
char
tsLogDir
[];
extern
char
tsLogbakDir
[];
extern
char
tsScriptDir
[];
extern
int64_t
tsMsPerDay
[
3
];
extern
char
tsVnodeBakDir
[];
...
...
src/common/src/tglobal.c
浏览文件 @
37922f29
...
...
@@ -370,16 +370,6 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"logBakDir"
;
cfg
.
ptr
=
tsLogbakDir
;
cfg
.
valType
=
TAOS_CFG_VTYPE_DIRECTORY
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_CLIENT
|
TSDB_CFG_CTYPE_B_LOG
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
0
;
cfg
.
ptrLength
=
TSDB_FILENAME_LEN
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"scriptDir"
;
cfg
.
ptr
=
tsScriptDir
;
cfg
.
valType
=
TAOS_CFG_VTYPE_DIRECTORY
;
...
...
src/dnode/src/dnodeMain.c
浏览文件 @
37922f29
...
...
@@ -106,11 +106,6 @@ int32_t dnodeInitSystem() {
return
-
1
;
}
if
(
dnodeCreateDir
(
tsLogbakDir
)
<
0
)
{
printf
(
"failed to create dir: %s, reason: %s
\n
"
,
tsLogbakDir
,
strerror
(
errno
));
return
-
1
;
}
char
temp
[
TSDB_FILENAME_LEN
];
sprintf
(
temp
,
"%s/taosdlog"
,
tsLogDir
);
if
(
taosInitLog
(
temp
,
tsNumOfLogLines
,
1
)
<
0
)
{
...
...
src/os/inc/osDir.h
浏览文件 @
37922f29
...
...
@@ -24,6 +24,7 @@ extern "C" {
void
taosRemoveDir
(
char
*
rootDir
);
int
taosMkDir
(
const
char
*
pathname
,
mode_t
mode
);
void
taosRename
(
char
*
oldName
,
char
*
newName
);
void
taosRemoveOldLogFiles
(
char
*
rootDir
,
int32_t
keepDays
);
#ifdef __cplusplus
}
...
...
src/os/src/alpine/alpineEnv.c
浏览文件 @
37922f29
...
...
@@ -27,7 +27,6 @@ void osInit() {
strcpy
(
tsMnodeDir
,
""
);
strcpy
(
tsDataDir
,
"/var/lib/taos"
);
strcpy
(
tsLogDir
,
"/var/log/taos"
);
strcpy
(
tsLogbakDir
,
"/var/log/taos/bak"
);
strcpy
(
tsScriptDir
,
"/etc/taos"
);
strcpy
(
tsOsName
,
"Linux"
);
}
\ No newline at end of file
src/os/src/darwin/darwinEnv.c
浏览文件 @
37922f29
...
...
@@ -27,7 +27,6 @@ void osInit() {
strcpy
(
tsMnodeDir
,
""
);
strcpy
(
tsDataDir
,
"~/TDengine/data"
);
strcpy
(
tsLogDir
,
"~/TDengine/log"
);
strcpy
(
tsLogbakDir
,
"~/TDengine/log/bak"
);
strcpy
(
tsScriptDir
,
"~/TDengine/cfg"
);
strcpy
(
tsOsName
,
"Darwin"
);
}
src/os/src/detail/osDir.c
浏览文件 @
37922f29
...
...
@@ -51,11 +51,6 @@ int taosMkDir(const char *path, mode_t mode) {
}
void
taosRename
(
char
*
oldName
,
char
*
newName
)
{
if
(
0
==
tsEnableVnodeBak
)
{
uInfo
(
"vnode backup not enabled"
);
return
;
}
// if newName in not empty, rename return fail.
// the newName must be empty or does not exist
if
(
rename
(
oldName
,
newName
))
{
...
...
@@ -65,4 +60,48 @@ void taosRename(char* oldName, char *newName) {
}
}
void
taosRemoveOldLogFiles
(
char
*
rootDir
,
int32_t
keepDays
)
{
DIR
*
dir
=
opendir
(
rootDir
);
if
(
dir
==
NULL
)
return
;
int64_t
ms
=
taosGetTimestampMs
();
struct
dirent
*
de
=
NULL
;
while
((
de
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strcmp
(
de
->
d_name
,
"."
)
==
0
||
strcmp
(
de
->
d_name
,
".."
)
==
0
)
continue
;
char
filename
[
1024
];
snprintf
(
filename
,
1023
,
"%s/%s"
,
rootDir
,
de
->
d_name
);
if
(
de
->
d_type
&
DT_DIR
)
{
continue
;
}
else
{
// struct stat fState;
// if (stat(fname, &fState) < 0) {
// continue;
// }
int32_t
len
=
strlen
(
filename
);
int64_t
fileMs
=
0
;
for
(
int
i
=
len
-
1
;
i
>=
0
;
++
i
)
{
if
(
filename
[
i
]
==
'.'
)
{
fileMs
=
atoll
(
filename
+
i
+
1
);
break
;
}
}
if
(
fileMs
<=
0
)
continue
;
int32_t
days
=
(
fileMs
-
ms
)
/
86400
+
1
;
if
(
days
>
keepDays
)
{
(
void
)
remove
(
filename
);
uInfo
(
"file:%s is removed, days:%d keepDays:%d"
,
filename
,
days
,
keepDays
);
}
else
{
uTrace
(
"file:%s won't be removed, days:%d keepDays:%d"
,
filename
,
days
,
keepDays
);
}
}
}
closedir
(
dir
);
rmdir
(
rootDir
);
}
#endif
src/os/src/linux/linuxEnv.c
浏览文件 @
37922f29
...
...
@@ -25,7 +25,6 @@ void osInit() {
}
strcpy
(
tsDataDir
,
"/var/lib/power"
);
strcpy
(
tsLogDir
,
"/var/log/power"
);
strcpy
(
tsLogbakDir
,
"/var/log/power/bak"
);
strcpy
(
tsScriptDir
,
"/etc/power"
);
#else
if
(
configDir
[
0
]
==
0
)
{
...
...
@@ -33,7 +32,6 @@ void osInit() {
}
strcpy
(
tsDataDir
,
"/var/lib/taos"
);
strcpy
(
tsLogDir
,
"/var/log/taos"
);
strcpy
(
tsLogbakDir
,
"/var/log/taos/bak"
);
strcpy
(
tsScriptDir
,
"/etc/taos"
);
#endif
...
...
src/os/src/windows/wEnv.c
浏览文件 @
37922f29
...
...
@@ -30,7 +30,6 @@ void osInit() {
strcpy
(
tsVnodeDir
,
"C:/PowerDB/data"
);
strcpy
(
tsDataDir
,
"C:/PowerDB/data"
);
strcpy
(
tsLogDir
,
"C:/PowerDB/log"
);
strcpy
(
tsLogbakDir
,
"C:/PowerDB/log/bak"
);
strcpy
(
tsScriptDir
,
"C:/PowerDB/script"
);
#else
...
...
@@ -41,7 +40,6 @@ void osInit() {
strcpy
(
tsVnodeDir
,
"C:/TDengine/data"
);
strcpy
(
tsDataDir
,
"C:/TDengine/data"
);
strcpy
(
tsLogDir
,
"C:/TDengine/log"
);
strcpy
(
tsLogbakDir
,
"C:/TDengine/log/bak"
);
strcpy
(
tsScriptDir
,
"C:/TDengine/script"
);
#endif
...
...
src/util/src/tlog.c
浏览文件 @
37922f29
...
...
@@ -69,10 +69,8 @@ float tsAvailLogDirGB = 0;
float
tsMinimalLogDirGB
=
0
.
1
f
;
#ifdef _TD_POWER_
char
tsLogDir
[
TSDB_FILENAME_LEN
]
=
"/var/log/power"
;
char
tsLogbakDir
[
TSDB_FILENAME_LEN
]
=
"/var/log/power/bak"
;
#else
char
tsLogDir
[
TSDB_FILENAME_LEN
]
=
"/var/log/taos"
;
char
tsLogbakDir
[
TSDB_FILENAME_LEN
]
=
"/var/log/taos/bak"
;
#endif
static
SLogObj
tsLogObj
=
{
.
fileNum
=
1
};
...
...
@@ -139,11 +137,25 @@ static void taosUnLockFile(int32_t fd) {
}
}
static
void
taosKeepOldLog
(
char
*
oldName
)
{
if
(
tsLogKeepDays
<=
0
)
return
;
int64_t
ms
=
taosGetTimestampMs
();
char
fileName
[
LOG_FILE_NAME_LEN
+
20
];
snprintf
(
fileName
,
LOG_FILE_NAME_LEN
+
20
,
"%s.%"
PRId64
,
tsLogObj
.
logName
,
ms
);
uInfo
(
"rename log file %s to %s"
,
oldName
,
fileName
);
taosRename
(
oldName
,
fileName
);
taosRemoveOldLogFiles
(
tsLogDir
,
tsLogKeepDays
);
}
static
void
*
taosThreadToOpenNewFile
(
void
*
param
)
{
char
name
[
LOG_FILE_NAME_LEN
+
20
];
char
keepName
[
LOG_FILE_NAME_LEN
+
20
];
sprintf
(
keepName
,
"%s.%d"
,
tsLogObj
.
logName
,
tsLogObj
.
flag
);
tsLogObj
.
flag
^=
1
;
tsLogObj
.
lines
=
0
;
char
name
[
LOG_FILE_NAME_LEN
+
20
];
sprintf
(
name
,
"%s.%d"
,
tsLogObj
.
logName
,
tsLogObj
.
flag
);
umask
(
0
);
...
...
@@ -153,6 +165,7 @@ static void *taosThreadToOpenNewFile(void *param) {
uError
(
"open new log file fail! fd:%d reason:%s"
,
fd
,
strerror
(
errno
));
return
NULL
;
}
taosLockFile
(
fd
);
(
void
)
lseek
(
fd
,
0
,
SEEK_SET
);
...
...
@@ -160,9 +173,11 @@ static void *taosThreadToOpenNewFile(void *param) {
tsLogObj
.
logHandle
->
fd
=
fd
;
tsLogObj
.
lines
=
0
;
tsLogObj
.
openInProgress
=
0
;
taosCloseLogByFd
(
oldFd
);
uInfo
(
"new log file is opened!!!"
);
taosCloseLogByFd
(
oldFd
);
taosKeepOldLog
(
keepName
);
return
NULL
;
}
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
37922f29
...
...
@@ -382,7 +382,13 @@ void vnodeRelease(void *pVnodeRaw) {
char
newDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
sprintf
(
rootDir
,
"%s/vnode%d"
,
tsVnodeDir
,
vgId
);
sprintf
(
newDir
,
"%s/vnode%d"
,
tsVnodeBakDir
,
vgId
);
taosRename
(
rootDir
,
newDir
);
if
(
0
==
tsEnableVnodeBak
)
{
vInfo
(
"vgId:%d, vnode backup not enabled"
,
pVnode
->
vgId
);
}
else
{
taosRename
(
rootDir
,
newDir
);
}
taosRemoveDir
(
rootDir
);
dnodeSendStatusMsgToMnode
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录