Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
fd5f11ba
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fd5f11ba
编写于
8月 13, 2020
作者:
H
Heikki Linnakangas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename faultInjectorSlots field for clarity.
上级
81b0e5fd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
14 deletion
+13
-14
src/backend/utils/misc/faultinjector.c
src/backend/utils/misc/faultinjector.c
+11
-12
src/include/utils/faultinjector.h
src/include/utils/faultinjector.h
+2
-2
未找到文件。
src/backend/utils/misc/faultinjector.c
浏览文件 @
fd5f11ba
...
@@ -47,8 +47,7 @@
...
@@ -47,8 +47,7 @@
typedef
struct
FaultInjectorShmem_s
{
typedef
struct
FaultInjectorShmem_s
{
slock_t
lock
;
slock_t
lock
;
int
faultInjectorSlots
;
int
numActiveFaults
;
/* number of fault injections set */
/* number of fault injection set */
HTAB
*
hash
;
HTAB
*
hash
;
}
FaultInjectorShmem_s
;
}
FaultInjectorShmem_s
;
...
@@ -61,9 +60,9 @@ static FaultInjectorShmem_s *faultInjectorShmem = NULL;
...
@@ -61,9 +60,9 @@ static FaultInjectorShmem_s *faultInjectorShmem = NULL;
* faultInjectorSlots_ptr points to this until shmem is initialized. Just to
* faultInjectorSlots_ptr points to this until shmem is initialized. Just to
* keep any FaultInjector_InjectFaultIfSet calls from crashing.
* keep any FaultInjector_InjectFaultIfSet calls from crashing.
*/
*/
static
int
dummy
slots
=
0
;
static
int
dummy
=
0
;
int
*
faultInjectorSlots_ptr
=
&
dummyslots
;
int
*
numActiveFaults_ptr
=
&
dummy
;
static
void
FiLockAcquire
(
void
);
static
void
FiLockAcquire
(
void
);
static
void
FiLockRelease
(
void
);
static
void
FiLockRelease
(
void
);
...
@@ -197,7 +196,7 @@ FaultInjector_ShmemInit(void)
...
@@ -197,7 +196,7 @@ FaultInjector_ShmemInit(void)
(
errmsg
(
"not enough shared memory for fault injector"
))));
(
errmsg
(
"not enough shared memory for fault injector"
))));
}
}
faultInjectorSlots_ptr
=
&
faultInjectorShmem
->
faultInjectorSlo
ts
;
numActiveFaults_ptr
=
&
faultInjectorShmem
->
numActiveFaul
ts
;
if
(
!
foundPtr
)
if
(
!
foundPtr
)
{
{
...
@@ -206,7 +205,7 @@ FaultInjector_ShmemInit(void)
...
@@ -206,7 +205,7 @@ FaultInjector_ShmemInit(void)
SpinLockInit
(
&
faultInjectorShmem
->
lock
);
SpinLockInit
(
&
faultInjectorShmem
->
lock
);
faultInjectorShmem
->
faultInjectorSlo
ts
=
0
;
faultInjectorShmem
->
numActiveFaul
ts
=
0
;
MemSet
(
&
hash_ctl
,
0
,
sizeof
(
hash_ctl
));
MemSet
(
&
hash_ctl
,
0
,
sizeof
(
hash_ctl
));
hash_ctl
.
keysize
=
FAULT_NAME_MAX_LENGTH
;
hash_ctl
.
keysize
=
FAULT_NAME_MAX_LENGTH
;
...
@@ -278,7 +277,7 @@ FaultInjector_InjectFaultIfSet_out_of_line(
...
@@ -278,7 +277,7 @@ FaultInjector_InjectFaultIfSet_out_of_line(
* Although this is a race condition without lock, a false negative is
* Although this is a race condition without lock, a false negative is
* ok given this framework is purely for dev/testing.
* ok given this framework is purely for dev/testing.
*/
*/
if
(
faultInjectorShmem
->
faultInjectorSlo
ts
==
0
)
if
(
faultInjectorShmem
->
numActiveFaul
ts
==
0
)
return
FaultInjectorTypeNotSpecified
;
return
FaultInjectorTypeNotSpecified
;
snprintf
(
databaseNameLocal
,
sizeof
(
databaseNameLocal
),
"%s"
,
databaseName
);
snprintf
(
databaseNameLocal
,
sizeof
(
databaseNameLocal
),
"%s"
,
databaseName
);
...
@@ -613,7 +612,7 @@ FaultInjector_NewHashEntry(
...
@@ -613,7 +612,7 @@ FaultInjector_NewHashEntry(
FiLockAcquire
();
FiLockAcquire
();
if
((
faultInjectorShmem
->
faultInjectorSlo
ts
+
1
)
>=
FAULTINJECTOR_MAX_SLOTS
)
{
if
((
faultInjectorShmem
->
numActiveFaul
ts
+
1
)
>=
FAULTINJECTOR_MAX_SLOTS
)
{
FiLockRelease
();
FiLockRelease
();
status
=
STATUS_ERROR
;
status
=
STATUS_ERROR
;
ereport
(
WARNING
,
ereport
(
WARNING
,
...
@@ -673,7 +672,7 @@ FaultInjector_NewHashEntry(
...
@@ -673,7 +672,7 @@ FaultInjector_NewHashEntry(
entryLocal
->
faultInjectorState
=
FaultInjectorStateWaiting
;
entryLocal
->
faultInjectorState
=
FaultInjectorStateWaiting
;
faultInjectorShmem
->
faultInjectorSlo
ts
++
;
faultInjectorShmem
->
numActiveFaul
ts
++
;
FiLockRelease
();
FiLockRelease
();
...
@@ -760,18 +759,18 @@ FaultInjector_SetFaultInjection(
...
@@ -760,18 +759,18 @@ FaultInjector_SetFaultInjection(
while
((
entryLocal
=
(
FaultInjectorEntry_s
*
)
hash_seq_search
(
&
hash_status
))
!=
NULL
)
{
while
((
entryLocal
=
(
FaultInjectorEntry_s
*
)
hash_seq_search
(
&
hash_status
))
!=
NULL
)
{
isRemoved
=
FaultInjector_RemoveHashEntry
(
entryLocal
->
faultName
);
isRemoved
=
FaultInjector_RemoveHashEntry
(
entryLocal
->
faultName
);
if
(
isRemoved
==
TRUE
)
{
if
(
isRemoved
==
TRUE
)
{
faultInjectorShmem
->
faultInjectorSlo
ts
--
;
faultInjectorShmem
->
numActiveFaul
ts
--
;
}
}
}
}
FiLockRelease
();
FiLockRelease
();
Assert
(
faultInjectorShmem
->
faultInjectorSlo
ts
==
0
);
Assert
(
faultInjectorShmem
->
numActiveFaul
ts
==
0
);
}
}
else
else
{
{
FiLockAcquire
();
FiLockAcquire
();
isRemoved
=
FaultInjector_RemoveHashEntry
(
entry
->
faultName
);
isRemoved
=
FaultInjector_RemoveHashEntry
(
entry
->
faultName
);
if
(
isRemoved
==
TRUE
)
{
if
(
isRemoved
==
TRUE
)
{
faultInjectorShmem
->
faultInjectorSlo
ts
--
;
faultInjectorShmem
->
numActiveFaul
ts
--
;
}
}
FiLockRelease
();
FiLockRelease
();
}
}
...
...
src/include/utils/faultinjector.h
浏览文件 @
fd5f11ba
...
@@ -96,11 +96,11 @@ extern FaultInjectorType_e FaultInjector_InjectFaultIfSet_out_of_line(
...
@@ -96,11 +96,11 @@ extern FaultInjectorType_e FaultInjector_InjectFaultIfSet_out_of_line(
const
char
*
tableName
);
const
char
*
tableName
);
#define FaultInjector_InjectFaultIfSet(faultName, ddlStatement, databaseName, tableName) \
#define FaultInjector_InjectFaultIfSet(faultName, ddlStatement, databaseName, tableName) \
(((*
faultInjectorSlo
ts_ptr) > 0) ? \
(((*
numActiveFaul
ts_ptr) > 0) ? \
FaultInjector_InjectFaultIfSet_out_of_line(faultName, ddlStatement, databaseName, tableName) : \
FaultInjector_InjectFaultIfSet_out_of_line(faultName, ddlStatement, databaseName, tableName) : \
FaultInjectorTypeNotSpecified)
FaultInjectorTypeNotSpecified)
extern
int
*
faultInjectorSlo
ts_ptr
;
extern
int
*
numActiveFaul
ts_ptr
;
extern
char
*
InjectFault
(
extern
char
*
InjectFault
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录