Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
b2c1c911
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看板
未验证
提交
b2c1c911
编写于
9月 08, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
9月 08, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3430 from taosdata/feature/crash
Feature/crash
上级
ed008d51
a098ad9c
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
127 addition
and
72 deletion
+127
-72
packaging/cfg/taos.cfg
packaging/cfg/taos.cfg
+3
-0
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+1
-0
src/common/src/tglobal.c
src/common/src/tglobal.c
+12
-2
src/os/inc/osDir.h
src/os/inc/osDir.h
+1
-0
src/os/inc/osWindows.h
src/os/inc/osWindows.h
+1
-2
src/os/src/detail/osDir.c
src/os/src/detail/osDir.c
+44
-10
src/os/src/windows/wDir.c
src/os/src/windows/wDir.c
+0
-31
src/os/src/windows/wString.c
src/os/src/windows/wString.c
+17
-8
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+1
-1
src/util/src/tconfig.c
src/util/src/tconfig.c
+3
-3
src/util/src/tlog.c
src/util/src/tlog.c
+37
-14
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+7
-1
未找到文件。
packaging/cfg/taos.cfg
浏览文件 @
b2c1c911
...
@@ -189,6 +189,9 @@
...
@@ -189,6 +189,9 @@
# max number of rows per log filters
# max number of rows per log filters
# numOfLogLines 10000000
# numOfLogLines 10000000
# time of keeping log files, days
# logKeepDays 0
# enable/disable async log
# enable/disable async log
# asyncLog 1
# asyncLog 1
...
...
src/common/inc/tglobal.h
浏览文件 @
b2c1c911
...
@@ -158,6 +158,7 @@ extern char buildinfo[];
...
@@ -158,6 +158,7 @@ extern char buildinfo[];
// log
// log
extern
int32_t
tsAsyncLog
;
extern
int32_t
tsAsyncLog
;
extern
int32_t
tsNumOfLogLines
;
extern
int32_t
tsNumOfLogLines
;
extern
int32_t
tsLogKeepDays
;
extern
int32_t
dDebugFlag
;
extern
int32_t
dDebugFlag
;
extern
int32_t
vDebugFlag
;
extern
int32_t
vDebugFlag
;
extern
int32_t
mDebugFlag
;
extern
int32_t
mDebugFlag
;
...
...
src/common/src/tglobal.c
浏览文件 @
b2c1c911
...
@@ -254,7 +254,7 @@ bool taosCfgDynamicOptions(char *msg) {
...
@@ -254,7 +254,7 @@ bool taosCfgDynamicOptions(char *msg) {
//if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_LOG)) continue;
//if (!(cfg->cfgType & TSDB_CFG_CTYPE_B_LOG)) continue;
if
(
cfg
->
valType
!=
TAOS_CFG_VTYPE_INT32
)
continue
;
if
(
cfg
->
valType
!=
TAOS_CFG_VTYPE_INT32
)
continue
;
int32_t
cfgLen
=
strlen
(
cfg
->
option
);
int32_t
cfgLen
=
(
int32_t
)
strlen
(
cfg
->
option
);
if
(
cfgLen
!=
olen
)
continue
;
if
(
cfgLen
!=
olen
)
continue
;
if
(
strncasecmp
(
option
,
cfg
->
option
,
olen
)
!=
0
)
continue
;
if
(
strncasecmp
(
option
,
cfg
->
option
,
olen
)
!=
0
)
continue
;
*
((
int32_t
*
)
cfg
->
ptr
)
=
vint
;
*
((
int32_t
*
)
cfg
->
ptr
)
=
vint
;
...
@@ -1013,12 +1013,22 @@ static void doInitGlobalConfig(void) {
...
@@ -1013,12 +1013,22 @@ static void doInitGlobalConfig(void) {
cfg
.
ptr
=
&
tsNumOfLogLines
;
cfg
.
ptr
=
&
tsNumOfLogLines
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT32
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_LOG
|
TSDB_CFG_CTYPE_B_CLIENT
;
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
.
maxValue
=
2000000000
;
cfg
.
ptrLength
=
0
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"logKeepDays"
;
cfg
.
ptr
=
&
tsLogKeepDays
;
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
=
365000
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"asyncLog"
;
cfg
.
option
=
"asyncLog"
;
cfg
.
ptr
=
&
tsAsyncLog
;
cfg
.
ptr
=
&
tsAsyncLog
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT16
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT16
;
...
...
src/os/inc/osDir.h
浏览文件 @
b2c1c911
...
@@ -24,6 +24,7 @@ extern "C" {
...
@@ -24,6 +24,7 @@ extern "C" {
void
taosRemoveDir
(
char
*
rootDir
);
void
taosRemoveDir
(
char
*
rootDir
);
int
taosMkDir
(
const
char
*
pathname
,
mode_t
mode
);
int
taosMkDir
(
const
char
*
pathname
,
mode_t
mode
);
void
taosRename
(
char
*
oldName
,
char
*
newName
);
void
taosRename
(
char
*
oldName
,
char
*
newName
);
void
taosRemoveOldLogFiles
(
char
*
rootDir
,
int32_t
keepDays
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/os/inc/osWindows.h
浏览文件 @
b2c1c911
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
#include <Winsock2.h>
#include <Winsock2.h>
#include <time.h>
#include <time.h>
#include <inttypes.h>
#include <inttypes.h>
#include <conio.h>
#include "msvcProcess.h"
#include "msvcProcess.h"
#include "msvcDirect.h"
#include "msvcDirect.h"
#include "msvcFcntl.h"
#include "msvcFcntl.h"
...
@@ -58,8 +59,6 @@ extern "C" {
...
@@ -58,8 +59,6 @@ extern "C" {
int32_t
BUILDIN_CTZL
(
uint64_t
val
);
int32_t
BUILDIN_CTZL
(
uint64_t
val
);
int32_t
BUILDIN_CTZ
(
uint32_t
val
);
int32_t
BUILDIN_CTZ
(
uint32_t
val
);
#define TAOS_OS_FUNC_DIR
#define TAOS_OS_FUNC_FILE
#define TAOS_OS_FUNC_FILE
#define TAOS_OS_FUNC_FILE_ISREG
#define TAOS_OS_FUNC_FILE_ISREG
#define TAOS_OS_FUNC_FILE_ISDIR
#define TAOS_OS_FUNC_FILE_ISDIR
...
...
src/os/src/detail/osDir.c
浏览文件 @
b2c1c911
...
@@ -18,8 +18,6 @@
...
@@ -18,8 +18,6 @@
#include "tglobal.h"
#include "tglobal.h"
#include "tulog.h"
#include "tulog.h"
#ifndef TAOS_OS_FUNC_DIR
void
taosRemoveDir
(
char
*
rootDir
)
{
void
taosRemoveDir
(
char
*
rootDir
)
{
DIR
*
dir
=
opendir
(
rootDir
);
DIR
*
dir
=
opendir
(
rootDir
);
if
(
dir
==
NULL
)
return
;
if
(
dir
==
NULL
)
return
;
...
@@ -51,18 +49,54 @@ int taosMkDir(const char *path, mode_t mode) {
...
@@ -51,18 +49,54 @@ int taosMkDir(const char *path, mode_t mode) {
}
}
void
taosRename
(
char
*
oldName
,
char
*
newName
)
{
void
taosRename
(
char
*
oldName
,
char
*
newName
)
{
if
(
0
==
tsEnableVnodeBak
)
{
uInfo
(
"vnode backup not enabled"
);
return
;
}
// if newName in not empty, rename return fail.
// if newName in not empty, rename return fail.
// the newName must be empty or does not exist
// the newName must be empty or does not exist
if
(
rename
(
oldName
,
newName
))
{
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
{
}
else
{
uInfo
(
"
%s is modify to %s success!
"
,
oldName
,
newName
);
uInfo
(
"
successfully to rename file %s to %s
"
,
oldName
,
newName
);
}
}
}
}
#endif
void
taosRemoveOldLogFiles
(
char
*
rootDir
,
int32_t
keepDays
)
{
DIR
*
dir
=
opendir
(
rootDir
);
if
(
dir
==
NULL
)
return
;
int64_t
sec
=
taosGetTimestampSec
();
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
=
(
int32_t
)
strlen
(
filename
);
int64_t
fileSec
=
0
;
for
(
int
i
=
len
-
1
;
i
>=
0
;
i
--
)
{
if
(
filename
[
i
]
==
'.'
)
{
fileSec
=
atoll
(
filename
+
i
+
1
);
break
;
}
}
if
(
fileSec
<=
100
)
continue
;
int32_t
days
=
(
int32_t
)(
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
);
}
}
}
closedir
(
dir
);
rmdir
(
rootDir
);
}
src/os/src/windows/wDir.c
已删除
100644 → 0
浏览文件 @
ed008d51
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tulog.h"
void
taosRemoveDir
(
char
*
rootDir
)
{
uError
(
"%s not implemented yet"
,
__FUNCTION__
);
}
int
taosMkDir
(
const
char
*
path
,
mode_t
mode
)
{
uError
(
"%s not implemented yet"
,
__FUNCTION__
);
return
0
;
}
void
taosMvDir
(
char
*
destDir
,
char
*
srcDir
)
{
uError
(
"%s not implemented yet"
,
__FUNCTION__
);
}
src/os/src/windows/wString.c
浏览文件 @
b2c1c911
...
@@ -58,11 +58,20 @@ char *strsep(char **stringp, const char *delim) {
...
@@ -58,11 +58,20 @@ char *strsep(char **stringp, const char *delim) {
char
*
getpass
(
const
char
*
prefix
)
{
char
*
getpass
(
const
char
*
prefix
)
{
static
char
passwd
[
TSDB_KEY_LEN
]
=
{
0
};
static
char
passwd
[
TSDB_KEY_LEN
]
=
{
0
};
memset
(
passwd
,
0
,
TSDB_KEY_LEN
);
printf
(
"%s"
,
prefix
);
printf
(
"%s"
,
prefix
);
scanf
(
"%s"
,
passwd
);
char
n
=
getchar
();
int32_t
index
=
0
;
char
ch
;
while
(
index
<
TSDB_KEY_LEN
)
{
ch
=
getch
();
if
(
ch
==
'\n'
||
ch
==
'\r'
)
{
break
;
}
else
{
passwd
[
index
++
]
=
ch
;
}
}
return
passwd
;
return
passwd
;
}
}
...
@@ -131,11 +140,11 @@ int tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int bytes) {
...
@@ -131,11 +140,11 @@ int tasoUcs4Compare(void *f1_ucs4, void *f2_ucs4, int bytes) {
}
}
/* Copy memory to memory until the specified number of bytes
/* Copy memory to memory until the specified number of bytes
has been copied, return pointer to following byte.
has been copied, return pointer to following byte.
Overlap is NOT handled correctly. */
Overlap is NOT handled correctly. */
void
*
mempcpy
(
void
*
dest
,
const
void
*
src
,
size_t
len
)
{
void
*
mempcpy
(
void
*
dest
,
const
void
*
src
,
size_t
len
)
{
return
(
char
*
)
memcpy
(
dest
,
src
,
len
)
+
len
;
return
(
char
*
)
memcpy
(
dest
,
src
,
len
)
+
len
;
}
}
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
b2c1c911
...
@@ -576,5 +576,5 @@ static TSKEY tsdbGetCurrMinKey(int8_t precision, int32_t keep) {
...
@@ -576,5 +576,5 @@ static TSKEY tsdbGetCurrMinKey(int8_t precision, int32_t keep) {
}
}
static
int
tsdbGetCurrMinFid
(
int8_t
precision
,
int32_t
keep
,
int32_t
days
)
{
static
int
tsdbGetCurrMinFid
(
int8_t
precision
,
int32_t
keep
,
int32_t
days
)
{
return
TSDB_KEY_FILEID
(
tsdbGetCurrMinKey
(
precision
,
keep
),
days
,
precision
);
return
(
int
)(
TSDB_KEY_FILEID
(
tsdbGetCurrMinKey
(
precision
,
keep
),
days
,
precision
)
);
}
}
\ No newline at end of file
src/util/src/tconfig.c
浏览文件 @
b2c1c911
...
@@ -270,7 +270,7 @@ void taosReadGlobalLogCfg() {
...
@@ -270,7 +270,7 @@ void taosReadGlobalLogCfg() {
}
}
wordfree
(
&
full_path
);
wordfree
(
&
full_path
);
taosReadLogOption
(
"
tsL
ogDir"
,
tsLogDir
);
taosReadLogOption
(
"
l
ogDir"
,
tsLogDir
);
sprintf
(
fileName
,
"%s/taos.cfg"
,
configDir
);
sprintf
(
fileName
,
"%s/taos.cfg"
,
configDir
);
fp
=
fopen
(
fileName
,
"r"
);
fp
=
fopen
(
fileName
,
"r"
);
...
@@ -288,9 +288,9 @@ void taosReadGlobalLogCfg() {
...
@@ -288,9 +288,9 @@ void taosReadGlobalLogCfg() {
option
=
value
=
NULL
;
option
=
value
=
NULL
;
olen
=
vlen
=
0
;
olen
=
vlen
=
0
;
taosGetline
(
&
line
,
&
len
,
fp
);
taosGetline
(
&
line
,
&
len
,
fp
);
line
[
len
-
1
]
=
0
;
line
[
len
-
1
]
=
0
;
paGetToken
(
line
,
&
option
,
&
olen
);
paGetToken
(
line
,
&
option
,
&
olen
);
if
(
olen
==
0
)
continue
;
if
(
olen
==
0
)
continue
;
option
[
olen
]
=
0
;
option
[
olen
]
=
0
;
...
...
src/util/src/tlog.c
浏览文件 @
b2c1c911
...
@@ -62,6 +62,7 @@ typedef struct {
...
@@ -62,6 +62,7 @@ typedef struct {
pthread_mutex_t
logMutex
;
pthread_mutex_t
logMutex
;
}
SLogObj
;
}
SLogObj
;
int32_t
tsLogKeepDays
=
0
;
int32_t
tsAsyncLog
=
1
;
int32_t
tsAsyncLog
=
1
;
float
tsTotalLogDirGB
=
0
;
float
tsTotalLogDirGB
=
0
;
float
tsAvailLogDirGB
=
0
;
float
tsAvailLogDirGB
=
0
;
...
@@ -78,6 +79,7 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, char *msg, int32_t msgLen
...
@@ -78,6 +79,7 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, char *msg, int32_t msgLen
static
SLogBuff
*
taosLogBuffNew
(
int32_t
bufSize
);
static
SLogBuff
*
taosLogBuffNew
(
int32_t
bufSize
);
static
void
taosCloseLogByFd
(
int32_t
oldFd
);
static
void
taosCloseLogByFd
(
int32_t
oldFd
);
static
int32_t
taosOpenLogFile
(
char
*
fn
,
int32_t
maxLines
,
int32_t
maxFileNum
);
static
int32_t
taosOpenLogFile
(
char
*
fn
,
int32_t
maxLines
,
int32_t
maxFileNum
);
extern
void
taosPrintGlobalCfg
();
static
int32_t
taosStartLog
()
{
static
int32_t
taosStartLog
()
{
pthread_attr_t
threadAttr
;
pthread_attr_t
threadAttr
;
...
@@ -136,11 +138,24 @@ static void taosUnLockFile(int32_t fd) {
...
@@ -136,11 +138,24 @@ static void taosUnLockFile(int32_t fd) {
}
}
}
}
static
void
taosKeepOldLog
(
char
*
oldName
)
{
if
(
tsLogKeepDays
<=
0
)
return
;
int64_t
fileSec
=
taosGetTimestampSec
();
char
fileName
[
LOG_FILE_NAME_LEN
+
20
];
snprintf
(
fileName
,
LOG_FILE_NAME_LEN
+
20
,
"%s.%"
PRId64
,
tsLogObj
.
logName
,
fileSec
);
taosRename
(
oldName
,
fileName
);
taosRemoveOldLogFiles
(
tsLogDir
,
tsLogKeepDays
);
}
static
void
*
taosThreadToOpenNewFile
(
void
*
param
)
{
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
.
flag
^=
1
;
tsLogObj
.
lines
=
0
;
tsLogObj
.
lines
=
0
;
char
name
[
LOG_FILE_NAME_LEN
+
20
];
sprintf
(
name
,
"%s.%d"
,
tsLogObj
.
logName
,
tsLogObj
.
flag
);
sprintf
(
name
,
"%s.%d"
,
tsLogObj
.
logName
,
tsLogObj
.
flag
);
umask
(
0
);
umask
(
0
);
...
@@ -150,6 +165,7 @@ static void *taosThreadToOpenNewFile(void *param) {
...
@@ -150,6 +165,7 @@ static void *taosThreadToOpenNewFile(void *param) {
uError
(
"open new log file fail! fd:%d reason:%s"
,
fd
,
strerror
(
errno
));
uError
(
"open new log file fail! fd:%d reason:%s"
,
fd
,
strerror
(
errno
));
return
NULL
;
return
NULL
;
}
}
taosLockFile
(
fd
);
taosLockFile
(
fd
);
(
void
)
lseek
(
fd
,
0
,
SEEK_SET
);
(
void
)
lseek
(
fd
,
0
,
SEEK_SET
);
...
@@ -157,9 +173,13 @@ static void *taosThreadToOpenNewFile(void *param) {
...
@@ -157,9 +173,13 @@ static void *taosThreadToOpenNewFile(void *param) {
tsLogObj
.
logHandle
->
fd
=
fd
;
tsLogObj
.
logHandle
->
fd
=
fd
;
tsLogObj
.
lines
=
0
;
tsLogObj
.
lines
=
0
;
tsLogObj
.
openInProgress
=
0
;
tsLogObj
.
openInProgress
=
0
;
uInfo
(
"new log file is opened!!!"
);
taosCloseLogByFd
(
oldFd
);
taosCloseLogByFd
(
oldFd
);
uInfo
(
" new log file:%d is opened"
,
tsLogObj
.
flag
);
uInfo
(
"=================================="
);
taosPrintGlobalCfg
();
taosKeepOldLog
(
keepName
);
return
NULL
;
return
NULL
;
}
}
...
@@ -264,20 +284,23 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
...
@@ -264,20 +284,23 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
strcat
(
name
,
".0"
);
strcat
(
name
,
".0"
);
}
}
if
(
strlen
(
fn
)
<
LOG_FILE_NAME_LEN
+
50
-
2
)
{
strcpy
(
name
,
fn
);
strcat
(
name
,
".1"
);
}
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 none of the log files exist, open 0, if both exists, open the old one
if
(
stat
(
name
,
&
logstat0
)
<
0
)
{
if
(
!
log0Exist
&&
!
log1Exist
)
{
tsLogObj
.
flag
=
0
;
}
else
if
(
!
log1Exist
)
{
tsLogObj
.
flag
=
0
;
tsLogObj
.
flag
=
0
;
}
else
if
(
!
log0Exist
)
{
tsLogObj
.
flag
=
1
;
}
else
{
}
else
{
if
(
strlen
(
fn
)
<
LOG_FILE_NAME_LEN
+
50
-
2
)
{
tsLogObj
.
flag
=
(
logstat0
.
st_mtime
>
logstat1
.
st_mtime
)
?
0
:
1
;
strcpy
(
name
,
fn
);
strcat
(
name
,
".1"
);
}
if
(
stat
(
name
,
&
logstat1
)
<
0
)
{
tsLogObj
.
flag
=
1
;
}
else
{
tsLogObj
.
flag
=
(
logstat0
.
st_mtime
>
logstat1
.
st_mtime
)
?
0
:
1
;
}
}
}
char
fileName
[
LOG_FILE_NAME_LEN
+
50
]
=
"
\0
"
;
char
fileName
[
LOG_FILE_NAME_LEN
+
50
]
=
"
\0
"
;
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
b2c1c911
...
@@ -382,7 +382,13 @@ void vnodeRelease(void *pVnodeRaw) {
...
@@ -382,7 +382,13 @@ void vnodeRelease(void *pVnodeRaw) {
char
newDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
newDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
sprintf
(
rootDir
,
"%s/vnode%d"
,
tsVnodeDir
,
vgId
);
sprintf
(
rootDir
,
"%s/vnode%d"
,
tsVnodeDir
,
vgId
);
sprintf
(
newDir
,
"%s/vnode%d"
,
tsVnodeBakDir
,
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
);
taosRemoveDir
(
rootDir
);
dnodeSendStatusMsgToMnode
();
dnodeSendStatusMsgToMnode
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录