Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
33c8ddd4
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
提交
33c8ddd4
编写于
7月 13, 2020
作者:
S
Shuduo Sang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add --random-file-fail-output argument to support redirect debug info to a file.
上级
1e97755d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
58 addition
and
10 deletion
+58
-10
src/dnode/src/dnodeSystem.c
src/dnode/src/dnodeSystem.c
+7
-1
src/util/inc/tfile.h
src/util/inc/tfile.h
+7
-6
src/util/src/tfile.c
src/util/src/tfile.c
+44
-3
未找到文件。
src/dnode/src/dnodeSystem.c
浏览文件 @
33c8ddd4
...
@@ -70,7 +70,13 @@ int32_t main(int32_t argc, char *argv[]) {
...
@@ -70,7 +70,13 @@ int32_t main(int32_t argc, char *argv[]) {
}
}
#endif
#endif
#ifdef TAOS_RANDOM_FILE_FAIL
#ifdef TAOS_RANDOM_FILE_FAIL
else
if
(
strcmp
(
argv
[
i
],
"--random-file-fail-factor"
)
==
0
)
{
else
if
(
strcmp
(
argv
[
i
],
"--random-file-fail-output"
)
==
0
)
{
if
((
i
<
argc
-
1
)
&&
(
argv
[
i
+
1
][
0
]
!=
'-'
))
{
taosSetRandomFileFailOutput
(
argv
[
++
i
]);
}
else
{
taosSetRandomFileFailOutput
(
NULL
);
}
}
else
if
(
strcmp
(
argv
[
i
],
"--random-file-fail-factor"
)
==
0
)
{
if
(
(
i
+
1
)
<
argc
)
{
if
(
(
i
+
1
)
<
argc
)
{
int
factor
=
atoi
(
argv
[
i
+
1
]);
int
factor
=
atoi
(
argv
[
i
+
1
]);
printf
(
"The factor of random failure is %d
\n
"
,
factor
);
printf
(
"The factor of random failure is %d
\n
"
,
factor
);
...
...
src/util/inc/tfile.h
浏览文件 @
33c8ddd4
...
@@ -19,13 +19,14 @@
...
@@ -19,13 +19,14 @@
#ifdef TAOS_RANDOM_FILE_FAIL
#ifdef TAOS_RANDOM_FILE_FAIL
void
taosSetRandomFileFailFactor
(
int
factor
);
void
taosSetRandomFileFailFactor
(
int
factor
);
ssize_t
taos_tread
(
int
fd
,
void
*
buf
,
size_t
count
);
void
taosSetRandomFileFailOutput
(
const
char
*
path
);
ssize_t
taos_twrite
(
int
fd
,
void
*
buf
,
size_t
count
);
ssize_t
taos_tread
(
int
fd
,
void
*
buf
,
size_t
count
,
const
char
*
file
,
uint32_t
line
);
off_t
taos_lseek
(
int
fd
,
off_t
offset
,
int
whence
);
ssize_t
taos_twrite
(
int
fd
,
void
*
buf
,
size_t
count
,
const
char
*
file
,
uint32_t
line
);
off_t
taos_lseek
(
int
fd
,
off_t
offset
,
int
whence
,
const
char
*
file
,
uint32_t
line
);
#define tread(fd, buf, count) taos_tread(fd, buf, count)
#define tread(fd, buf, count) taos_tread(fd, buf, count
, __FILE__, __LINE__
)
#define twrite(fd, buf, count) taos_twrite(fd, buf, count)
#define twrite(fd, buf, count) taos_twrite(fd, buf, count
, __FILE__, __LINE__
)
#define lseek(fd, offset, whence) taos_lseek(fd, offset, whence)
#define lseek(fd, offset, whence) taos_lseek(fd, offset, whence
, __FILE__, __LINE__
)
#endif // TAOS_RANDOM_FILE_FAIL
#endif // TAOS_RANDOM_FILE_FAIL
...
...
src/util/src/tfile.c
浏览文件 @
33c8ddd4
...
@@ -29,14 +29,55 @@
...
@@ -29,14 +29,55 @@
#ifdef TAOS_RANDOM_FILE_FAIL
#ifdef TAOS_RANDOM_FILE_FAIL
static
int
random_file_fail_factor
=
20
;
static
int
random_file_fail_factor
=
20
;
static
FILE
*
fpRandomFileFailOutput
=
NULL
;
void
taosSetRandomFileFailFactor
(
int
factor
)
void
taosSetRandomFileFailFactor
(
int
factor
)
{
{
random_file_fail_factor
=
factor
;
random_file_fail_factor
=
factor
;
}
}
static
void
close_random_file_fail_output
()
{
if
(
fpRandomFileFailOutput
!=
NULL
)
{
if
(
fpRandomFileFailOutput
!=
stdout
)
{
fclose
(
fpRandomFileFailOutput
);
}
fpRandomFileFailOutput
=
NULL
;
}
}
static
void
random_file_fail_output_sig
(
int
sig
)
{
fprintf
(
fpRandomFileFailOutput
,
"signal %d received.
\n
"
,
sig
);
struct
sigaction
act
=
{
0
};
act
.
sa_handler
=
SIG_DFL
;
sigaction
(
sig
,
&
act
,
NULL
);
close_random_file_fail_output
();
exit
(
EXIT_FAILURE
);
}
void
taosSetRandomFileFailOutput
(
const
char
*
path
)
{
if
(
path
==
NULL
)
{
fpRandomFileFailOutput
=
stdout
;
}
else
if
((
fpRandomFileFailOutput
=
fopen
(
path
,
"w"
))
!=
NULL
)
{
atexit
(
close_random_file_fail_output
);
}
else
{
printf
(
"failed to open random file fail log file '%s', errno=%d
\n
"
,
path
,
errno
);
return
;
}
struct
sigaction
act
=
{
0
};
act
.
sa_handler
=
random_file_fail_output_sig
;
sigaction
(
SIGFPE
,
&
act
,
NULL
);
sigaction
(
SIGSEGV
,
&
act
,
NULL
);
sigaction
(
SIGILL
,
&
act
,
NULL
);
}
#endif
#endif
ssize_t
taos_tread
(
int
fd
,
void
*
buf
,
size_t
count
)
ssize_t
taos_tread
(
int
fd
,
void
*
buf
,
size_t
count
,
const
char
*
file
,
uint32_t
line
)
{
{
#ifdef TAOS_RANDOM_FILE_FAIL
#ifdef TAOS_RANDOM_FILE_FAIL
if
(
random_file_fail_factor
>
0
)
{
if
(
random_file_fail_factor
>
0
)
{
...
@@ -49,7 +90,7 @@ ssize_t taos_tread(int fd, void *buf, size_t count)
...
@@ -49,7 +90,7 @@ ssize_t taos_tread(int fd, void *buf, size_t count)
return
tread
(
fd
,
buf
,
count
);
return
tread
(
fd
,
buf
,
count
);
}
}
ssize_t
taos_twrite
(
int
fd
,
void
*
buf
,
size_t
count
)
ssize_t
taos_twrite
(
int
fd
,
void
*
buf
,
size_t
count
,
const
char
*
file
,
uint32_t
line
)
{
{
#ifdef TAOS_RANDOM_FILE_FAIL
#ifdef TAOS_RANDOM_FILE_FAIL
if
(
random_file_fail_factor
>
0
)
{
if
(
random_file_fail_factor
>
0
)
{
...
@@ -62,7 +103,7 @@ ssize_t taos_twrite(int fd, void *buf, size_t count)
...
@@ -62,7 +103,7 @@ ssize_t taos_twrite(int fd, void *buf, size_t count)
return
twrite
(
fd
,
buf
,
count
);
return
twrite
(
fd
,
buf
,
count
);
}
}
off_t
taos_lseek
(
int
fd
,
off_t
offset
,
int
whence
)
off_t
taos_lseek
(
int
fd
,
off_t
offset
,
int
whence
,
const
char
*
file
,
uint32_t
line
)
{
{
#ifdef TAOS_RANDOM_FILE_FAIL
#ifdef TAOS_RANDOM_FILE_FAIL
if
(
random_file_fail_factor
>
0
)
{
if
(
random_file_fail_factor
>
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录