Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f65e3609
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看板
提交
f65e3609
编写于
9月 08, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1263
上级
37922f29
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
32 addition
and
28 deletion
+32
-28
src/common/src/tglobal.c
src/common/src/tglobal.c
+3
-3
src/os/src/detail/osDir.c
src/os/src/detail/osDir.c
+8
-9
src/util/src/tlog.c
src/util/src/tlog.c
+21
-16
未找到文件。
src/common/src/tglobal.c
浏览文件 @
f65e3609
...
...
@@ -1013,18 +1013,18 @@ static void doInitGlobalConfig(void) {
cfg
.
ptr
=
&
tsNumOfLogLines
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_LOG
|
TSDB_CFG_CTYPE_B_CLIENT
;
cfg
.
minValue
=
1000
0
;
cfg
.
minValue
=
1000
;
cfg
.
maxValue
=
2000000000
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"logKeepDays"
;
cfg
.
ptr
=
&
ts
NumOfLogLine
s
;
cfg
.
ptr
=
&
ts
LogKeepDay
s
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_LOG
|
TSDB_CFG_CTYPE_B_CLIENT
;
cfg
.
minValue
=
0
;
cfg
.
maxValue
=
3650
;
cfg
.
maxValue
=
3650
0
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
...
...
src/os/src/detail/osDir.c
浏览文件 @
f65e3609
...
...
@@ -54,9 +54,9 @@ void taosRename(char* oldName, char *newName) {
// if newName in not empty, rename return fail.
// the newName must be empty or does not exist
if
(
rename
(
oldName
,
newName
))
{
uError
(
"
%s is modify to %s fail
, reason:%s"
,
oldName
,
newName
,
strerror
(
errno
));
uError
(
"
failed to rename file %s to %s
, reason:%s"
,
oldName
,
newName
,
strerror
(
errno
));
}
else
{
uInfo
(
"
%s is modify to %s success!
"
,
oldName
,
newName
);
uInfo
(
"
successfully to rename file %s to %s
"
,
oldName
,
newName
);
}
}
...
...
@@ -64,7 +64,7 @@ void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays) {
DIR
*
dir
=
opendir
(
rootDir
);
if
(
dir
==
NULL
)
return
;
int64_t
ms
=
taosGetTimestampMs
();
int64_t
sec
=
taosGetTimestampSec
();
struct
dirent
*
de
=
NULL
;
while
((
de
=
readdir
(
dir
))
!=
NULL
)
{
...
...
@@ -80,20 +80,19 @@ void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays) {
// continue;
// }
int32_t
len
=
strlen
(
filename
);
int64_t
file
Ms
=
0
;
for
(
int
i
=
len
-
1
;
i
>=
0
;
++
i
)
{
int64_t
file
Sec
=
0
;
for
(
int
i
=
len
-
1
;
i
>=
0
;
i
--
)
{
if
(
filename
[
i
]
==
'.'
)
{
file
Ms
=
atoll
(
filename
+
i
+
1
);
file
Sec
=
atoll
(
filename
+
i
+
1
);
break
;
}
}
if
(
file
Ms
<=
0
)
continue
;
int32_t
days
=
(
fileMs
-
ms
)
/
86400
+
1
;
if
(
file
Sec
<=
10
0
)
continue
;
int32_t
days
=
ABS
(
sec
-
fileSec
)
/
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
);
}
...
...
src/util/src/tlog.c
浏览文件 @
f65e3609
...
...
@@ -79,6 +79,7 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, char *msg, int32_t msgLen
static
SLogBuff
*
taosLogBuffNew
(
int32_t
bufSize
);
static
void
taosCloseLogByFd
(
int32_t
oldFd
);
static
int32_t
taosOpenLogFile
(
char
*
fn
,
int32_t
maxLines
,
int32_t
maxFileNum
);
extern
void
taosPrintGlobalCfg
();
static
int32_t
taosStartLog
()
{
pthread_attr_t
threadAttr
;
...
...
@@ -140,11 +141,10 @@ static void taosUnLockFile(int32_t fd) {
static
void
taosKeepOldLog
(
char
*
oldName
)
{
if
(
tsLogKeepDays
<=
0
)
return
;
int64_t
ms
=
taosGetTimestampMs
();
int64_t
fileSec
=
taosGetTimestampSec
();
char
fileName
[
LOG_FILE_NAME_LEN
+
20
];
snprintf
(
fileName
,
LOG_FILE_NAME_LEN
+
20
,
"%s.%"
PRId64
,
tsLogObj
.
logName
,
ms
);
snprintf
(
fileName
,
LOG_FILE_NAME_LEN
+
20
,
"%s.%"
PRId64
,
tsLogObj
.
logName
,
fileSec
);
uInfo
(
"rename log file %s to %s"
,
oldName
,
fileName
);
taosRename
(
oldName
,
fileName
);
taosRemoveOldLogFiles
(
tsLogDir
,
tsLogKeepDays
);
}
...
...
@@ -174,8 +174,10 @@ static void *taosThreadToOpenNewFile(void *param) {
tsLogObj
.
lines
=
0
;
tsLogObj
.
openInProgress
=
0
;
taosCloseLogByFd
(
oldFd
);
uInfo
(
"new log file is opened!!!"
);
uInfo
(
" new log file:%d is opened"
,
tsLogObj
.
flag
);
uInfo
(
"=================================="
);
taosPrintGlobalCfg
();
taosKeepOldLog
(
keepName
);
return
NULL
;
...
...
@@ -282,21 +284,24 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
strcat
(
name
,
".0"
);
}
// if none of the log files exist, open 0, if both exists, open the old one
if
(
stat
(
name
,
&
logstat0
)
<
0
)
{
tsLogObj
.
flag
=
0
;
}
else
{
if
(
strlen
(
fn
)
<
LOG_FILE_NAME_LEN
+
50
-
2
)
{
strcpy
(
name
,
fn
);
strcat
(
name
,
".1"
);
}
if
(
stat
(
name
,
&
logstat1
)
<
0
)
{
bool
log0Exist
=
stat
(
name
,
&
logstat0
)
>=
0
;
bool
log1Exist
=
stat
(
name
,
&
logstat1
)
>=
0
;
// if none of the log files exist, open 0, if both exists, open the old one
if
(
!
log0Exist
&&
!
log1Exist
)
{
tsLogObj
.
flag
=
0
;
}
else
if
(
!
log1Exist
)
{
tsLogObj
.
flag
=
0
;
}
else
if
(
!
log0Exist
)
{
tsLogObj
.
flag
=
1
;
}
else
{
tsLogObj
.
flag
=
(
logstat0
.
st_mtime
>
logstat1
.
st_mtime
)
?
0
:
1
;
}
}
char
fileName
[
LOG_FILE_NAME_LEN
+
50
]
=
"
\0
"
;
sprintf
(
fileName
,
"%s.%d"
,
tsLogObj
.
logName
,
tsLogObj
.
flag
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录