故障注入框架重写适配
This commit is contained in:
@ -7147,6 +7147,7 @@ static bool check_ss_work_thread_pool_attr(char** newval, void** extra, GucSourc
|
||||
}
|
||||
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
extern ss_dms_func_t g_ss_dms_func;
|
||||
static bool parse_ss_fi_entry_list(char *value, uint32 *entry_list, uint32 *count)
|
||||
{
|
||||
char* value_tmp = strdup(value);
|
||||
@ -7154,19 +7155,19 @@ static bool parse_ss_fi_entry_list(char *value, uint32 *entry_list, uint32 *coun
|
||||
while (p != NULL) {
|
||||
for (uint32 i = 0; i < strlen(p); i++) {
|
||||
if (!isdigit(p[i])) {
|
||||
ereport(ERROR, (errmsg("The para %s does not meet the environment(0 .. %d).", p, FI_ENTRY_END)));
|
||||
ereport(ERROR, (errmsg("The para %s does not meet the environment(0 .. %d).", p, DDES_FI_ENTRY_END)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
uint32 entry_point = atoi(p);
|
||||
if (entry_point >= FI_ENTRY_END || entry_point < 0) {
|
||||
if (entry_point >= DDES_FI_ENTRY_END || entry_point < 0) {
|
||||
ereport(ERROR, (errmsg("%d is outside the valid range for parameter"
|
||||
"(0 .. %d).", entry_point, FI_ENTRY_END)));
|
||||
"(0 .. %d).", entry_point, DDES_FI_ENTRY_END)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*count >= MAX_FI_ENTRY_COUNT) {
|
||||
ereport(ERROR, (errmsg("The number of fault points exceeds the maximum %d.", MAX_FI_ENTRY_COUNT)));
|
||||
if (*count >= DDES_FI_ENTRY_COUNT) {
|
||||
ereport(ERROR, (errmsg("The number of fault points exceeds the maximum %d.", DDES_FI_ENTRY_COUNT)));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -7188,10 +7189,9 @@ static bool parse_ss_fi_entry_list(char *value, uint32 *entry_list, uint32 *coun
|
||||
return true;
|
||||
}
|
||||
|
||||
extern ss_dms_func_t g_ss_dms_func;
|
||||
static bool check_ss_fi_packet_loss_entries(char** newval, void** extra, GucSource source)
|
||||
{
|
||||
uint32 entry_list[MAX_FI_ENTRY_COUNT] = {0};
|
||||
uint32 entry_list[DDES_FI_ENTRY_COUNT_PER_TYPE] = {0};
|
||||
uint32 count = 0;
|
||||
|
||||
if (!g_ss_dms_func.inited) {
|
||||
@ -7202,8 +7202,8 @@ static bool check_ss_fi_packet_loss_entries(char** newval, void** extra, GucSour
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dms_fi_set_entries(DMS_FI_TYPE_PACKET_LOSS, entry_list, count) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("set parameter ss_fi_packet_loss_entries fail")));
|
||||
if (ss_fi_set_entries(DDES_FI_TYPE_PACKET_LOSS, entry_list, count) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("[DMS]set parameter ss_fi_packet_loss_entries fail")));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -7211,7 +7211,7 @@ static bool check_ss_fi_packet_loss_entries(char** newval, void** extra, GucSour
|
||||
|
||||
static bool check_ss_fi_net_latency_entries(char** newval, void** extra, GucSource source)
|
||||
{
|
||||
uint32 entry_list[MAX_FI_ENTRY_COUNT] = {0};
|
||||
uint32 entry_list[DDES_FI_ENTRY_COUNT_PER_TYPE] = {0};
|
||||
uint32 count = 0;
|
||||
|
||||
if (!g_ss_dms_func.inited) {
|
||||
@ -7222,8 +7222,8 @@ static bool check_ss_fi_net_latency_entries(char** newval, void** extra, GucSour
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dms_fi_set_entries(DMS_FI_TYPE_NET_LATENCY, entry_list, count) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("set parameter ss_fi_net_latency_entries fail")));
|
||||
if (ss_fi_set_entries(DDES_FI_TYPE_NET_LATENCY, entry_list, count) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("[DMS]set parameter ss_fi_net_latency_entries fail")));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -7231,19 +7231,34 @@ static bool check_ss_fi_net_latency_entries(char** newval, void** extra, GucSour
|
||||
|
||||
static bool check_ss_fi_cpu_latency_entries(char** newval, void** extra, GucSource source)
|
||||
{
|
||||
uint32 entry_list[MAX_FI_ENTRY_COUNT] = {0};
|
||||
uint32 entry_list[DDES_FI_ENTRY_COUNT_PER_TYPE] = {0};
|
||||
uint32 count = 0;
|
||||
|
||||
if (!g_ss_dms_func.inited) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (g_instance.shared_fi_ctx == NULL) {
|
||||
int32 shared_fi_ctx_size = ss_fi_get_context_size();
|
||||
if (shared_fi_ctx_size <= 0) {
|
||||
ereport(FATAL, (errmsg("failed to get fi context size")));
|
||||
return false;
|
||||
}
|
||||
g_instance.shared_fi_ctx = malloc(shared_fi_ctx_size);
|
||||
if (g_instance.shared_fi_ctx == NULL) {
|
||||
ereport(FATAL, (errmsg("failed to alloc fi context")));
|
||||
return false;
|
||||
}
|
||||
|
||||
ss_fi_set_and_init_context(g_instance.shared_fi_ctx);
|
||||
}
|
||||
|
||||
if (!parse_ss_fi_entry_list(*newval, entry_list, &count)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dms_fi_set_entries(DMS_FI_TYPE_CPU_LATENCY, entry_list, count) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("set parameter ss_fi_cpu_latency_entries fail")));
|
||||
if (ss_fi_set_entries(DDES_FI_TYPE_NET_LATENCY, entry_list, count) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("[DMS]set parameter ss_fi_net_latency_entries fail")));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -7251,7 +7266,7 @@ static bool check_ss_fi_cpu_latency_entries(char** newval, void** extra, GucSour
|
||||
|
||||
static bool check_ss_fi_process_fault_entries(char** newval, void** extra, GucSource source)
|
||||
{
|
||||
uint32 entry_list[MAX_FI_ENTRY_COUNT] = {0};
|
||||
uint32 entry_list[DDES_FI_ENTRY_COUNT_PER_TYPE] = {0};
|
||||
uint32 count = 0;
|
||||
|
||||
if (!g_ss_dms_func.inited) {
|
||||
@ -7262,8 +7277,8 @@ static bool check_ss_fi_process_fault_entries(char** newval, void** extra, GucSo
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dms_fi_set_entries(DMS_FI_TYPE_PROCESS_FAULT, entry_list, count) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("set parameter ss_fi_process_fault_entries fail")));
|
||||
if (ss_fi_set_entries(DDES_FI_TYPE_PROCESS_FAULT, entry_list, count) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("[DMS]set parameter ss_fi_process_fault_entries fail")));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -7271,7 +7286,7 @@ static bool check_ss_fi_process_fault_entries(char** newval, void** extra, GucSo
|
||||
|
||||
static bool check_ss_fi_custom_fault_entries(char** newval, void** extra, GucSource source)
|
||||
{
|
||||
uint32 entry_list[MAX_FI_ENTRY_COUNT] = {0};
|
||||
uint32 entry_list[DDES_FI_ENTRY_COUNT_PER_TYPE] = {0};
|
||||
uint32 count = 0;
|
||||
|
||||
if (!g_ss_dms_func.inited) {
|
||||
@ -7282,8 +7297,8 @@ static bool check_ss_fi_custom_fault_entries(char** newval, void** extra, GucSou
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dms_fi_set_entries(DMS_FI_TYPE_CUSTOM_FAULT, entry_list, count) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("set parameter ss_fi_custom_fault_entries fail")));
|
||||
if (ss_fi_set_entries(DDES_FI_TYPE_CUSTOM_FAULT, entry_list, count) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("[DMS]set parameter ss_fi_custom_fault_entries fail")));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -7298,8 +7313,8 @@ static bool check_ss_fi_packet_loss_prob(int* newval, void** extra, GucSource so
|
||||
return true;
|
||||
}
|
||||
|
||||
if (dms_fi_set_entry_value(DMS_FI_TYPE_PACKET_LOSS, (unsigned int)int_val) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("set parameter ss_fi_packet_loss_prob fail")));
|
||||
if (ss_fi_set_entry_value(DDES_FI_TYPE_PACKET_LOSS, (unsigned int)int_val) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("[DMS]set parameter ss_fi_packet_loss_prob fail")));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -7315,8 +7330,8 @@ static bool check_ss_fi_net_latency_ms(int* newval, void** extra, GucSource sour
|
||||
return true;
|
||||
}
|
||||
|
||||
if (dms_fi_set_entry_value(DMS_FI_TYPE_NET_LATENCY, (unsigned int)int_val) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("set parameter ss_fi_net_latency_ms fail")));
|
||||
if (ss_fi_set_entry_value(DDES_FI_TYPE_NET_LATENCY, (unsigned int)int_val) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("[DMS]set parameter ss_fi_net_latency_ms fail")));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -7332,8 +7347,8 @@ static bool check_ss_fi_cpu_latency_ms(int* newval, void** extra, GucSource sour
|
||||
return true;
|
||||
}
|
||||
|
||||
if (dms_fi_set_entry_value(DMS_FI_TYPE_CPU_LATENCY, (unsigned int)int_val) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("set parameter ss_fi_cpu_latency_ms fail")));
|
||||
if (ss_fi_set_entry_value(DDES_FI_TYPE_CPU_LATENCY, (unsigned int)int_val) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("[DMS]set parameter ss_fi_cpu_latency_ms fail")));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -7349,8 +7364,8 @@ static bool check_ss_fi_process_fault_prob(int* newval, void** extra, GucSource
|
||||
return true;
|
||||
}
|
||||
|
||||
if (dms_fi_set_entry_value(DMS_FI_TYPE_PROCESS_FAULT, (unsigned int)int_val) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("set parameter ss_fi_process_fault_prob fail")));
|
||||
if (ss_fi_set_entry_value(DDES_FI_TYPE_PROCESS_FAULT, (unsigned int)int_val) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("[DMS]set parameter ss_fi_process_fault_prob fail")));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -7366,8 +7381,8 @@ static bool check_ss_fi_custom_fault_param(int* newval, void** extra, GucSource
|
||||
return true;
|
||||
}
|
||||
|
||||
if (dms_fi_set_entry_value(DMS_FI_TYPE_CUSTOM_FAULT, (unsigned int)int_val) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("set parameter ss_fi_custom_fault_param fail")));
|
||||
if (ss_fi_set_entry_value(DDES_FI_TYPE_CUSTOM_FAULT, (unsigned int)int_val) != DMS_SUCCESS) {
|
||||
ereport(ERROR, (errmsg("[DMS]set parameter ss_fi_custom_fault_param fail")));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -137,12 +137,16 @@ int ss_dms_func_init()
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(dms_req_opengauss_immediate_ckpt));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(dms_fsync_logfile));
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(dms_fi_set_entries));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(dms_fi_set_entry_value));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(dms_fi_get_tls_trigger_custom));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(dms_fi_set_tls_trigger_custom));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(fault_injection_call));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(dms_fi_entry_custom_valid));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(ddes_fi_get_context_size));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(ddes_fi_set_and_init_context));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(ddes_fi_set_entries));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(ddes_fi_get_entry_value));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(ddes_fi_set_entry_value));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(ddes_fi_get_tls_trigger_custom));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(ddes_fi_set_tls_trigger_custom));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(ddes_fi_entry_custom_valid));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(ddes_fi_call));
|
||||
SS_RETURN_IFERR(DMS_LOAD_SYMBOL_FUNC(ddes_fi_call_ex));
|
||||
#endif
|
||||
|
||||
g_ss_dms_func.inited = true;
|
||||
|
||||
@ -854,8 +854,8 @@ static int CBInvalidatePage(void *db_handle, char pageid[DMS_PAGEID_SIZE], unsig
|
||||
(void)PinBuffer(buf_desc, NULL);
|
||||
}
|
||||
|
||||
SS_FAULT_INJECTION_CALL(DB_FI_CHANGE_BUFFERTAG_BLOCKNUM, dms_fi_change_buffertag_blocknum);
|
||||
FAULT_INJECTION_ACTION_TRIGGER_CUSTOM(DB_FI_CHANGE_BUFFERTAG_BLOCKNUM, tag->blockNum += 1);
|
||||
SS_FAULT_INJECTION_CALL(DB_FI_CHANGE_BUFFERTAG_BLOCKNUM, ss_fi_change_buffertag_blocknum);
|
||||
SS_FAULT_INJECTION_ACTION_TRIGGER_CUSTOM(DB_FI_CHANGE_BUFFERTAG_BLOCKNUM, tag->blockNum += 1);
|
||||
if (!BUFFERTAGS_PTR_EQUAL(&buf_desc->tag, tag)) {
|
||||
DmsReleaseBuffer(buf_id + 1, IsSegmentBufferID(buf_id));
|
||||
buftag_equal = false;
|
||||
|
||||
@ -27,54 +27,87 @@
|
||||
#include "storage/file/fio_device_com.h"
|
||||
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
int dms_fi_set_entries(unsigned int type, unsigned int *entries, unsigned int count)
|
||||
// for alloc fi context with size return size
|
||||
int ss_fi_get_context_size(void)
|
||||
{
|
||||
if (g_ss_dms_func.inited) {
|
||||
return g_ss_dms_func.dms_fi_set_entries(type, entries, count);
|
||||
return g_ss_dms_func.ddes_fi_get_context_size();
|
||||
}
|
||||
return GS_ERROR;
|
||||
}
|
||||
|
||||
int dms_fi_set_entry_value(unsigned int type, unsigned int value)
|
||||
// set the fi context with the context, and init the context, the context alloced by DB
|
||||
void ss_fi_set_and_init_context(void *context)
|
||||
{
|
||||
if (g_ss_dms_func.inited) {
|
||||
return g_ss_dms_func.dms_fi_set_entry_value(type, value);
|
||||
return g_ss_dms_func.ddes_fi_set_and_init_context(context);
|
||||
}
|
||||
}
|
||||
|
||||
int ss_fi_set_entries(unsigned int type, unsigned int *entries, unsigned int count)
|
||||
{
|
||||
if (g_ss_dms_func.inited) {
|
||||
return g_ss_dms_func.ddes_fi_set_entries(type, entries, count);
|
||||
}
|
||||
return GS_ERROR;
|
||||
}
|
||||
|
||||
int dms_fi_get_tls_trigger_custom()
|
||||
int ss_fi_get_entry_value(unsigned int type)
|
||||
{
|
||||
if (g_ss_dms_func.inited) {
|
||||
return g_ss_dms_func.dms_fi_get_tls_trigger_custom();
|
||||
return g_ss_dms_func.ddes_fi_get_entry_value(type);
|
||||
}
|
||||
return GS_ERROR;
|
||||
}
|
||||
|
||||
void dms_fi_set_tls_trigger_custom(int val)
|
||||
int ss_fi_set_entry_value(unsigned int type, unsigned int value)
|
||||
{
|
||||
if (g_ss_dms_func.inited) {
|
||||
return g_ss_dms_func.dms_fi_set_tls_trigger_custom(val);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char dms_fi_entry_custom_valid(unsigned int point)
|
||||
{
|
||||
if (g_ss_dms_func.inited) {
|
||||
return g_ss_dms_func.dms_fi_entry_custom_valid(point);
|
||||
return g_ss_dms_func.ddes_fi_set_entry_value(type, value);
|
||||
}
|
||||
return GS_ERROR;
|
||||
}
|
||||
|
||||
void dms_fi_change_buffertag_blocknum(const dms_fi_entry *entry, va_list args)
|
||||
int ss_fi_get_tls_trigger_custom(void)
|
||||
{
|
||||
dms_fi_set_tls_trigger_custom(TRUE);
|
||||
if (g_ss_dms_func.inited) {
|
||||
return g_ss_dms_func.ddes_fi_get_tls_trigger_custom();
|
||||
}
|
||||
return GS_ERROR;
|
||||
}
|
||||
|
||||
void ss_fi_set_tls_trigger_custom(int val)
|
||||
{
|
||||
if (g_ss_dms_func.inited) {
|
||||
return g_ss_dms_func.ddes_fi_set_tls_trigger_custom(val);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char ss_fi_entry_custom_valid(unsigned int point)
|
||||
{
|
||||
if (g_ss_dms_func.inited) {
|
||||
return g_ss_dms_func.ddes_fi_entry_custom_valid(point);
|
||||
}
|
||||
return GS_ERROR;
|
||||
}
|
||||
|
||||
void ss_fi_call_ex(unsigned int point, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, point);
|
||||
|
||||
if (g_ss_dms_func.inited) {
|
||||
return g_ss_dms_func.ddes_fi_call_ex(point, args);
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
void ss_fi_change_buffertag_blocknum(const void *ddes_fi_entry, va_list args)
|
||||
{
|
||||
ss_fi_set_tls_trigger_custom(TRUE);
|
||||
}
|
||||
#else
|
||||
int dms_fi_set_entries(unsigned int type, unsigned int *entries, unsigned int count) {return GS_ERROR;}
|
||||
int dms_fi_set_entry_value(unsigned int type, unsigned int value) {return GS_ERROR;}
|
||||
int dms_fi_get_tls_trigger_custom() {return GS_ERROR;}
|
||||
void dms_fi_set_tls_trigger_custom(int val) {}
|
||||
unsigned char dms_fi_entry_custom_valid(unsigned int point) {return GS_ERROR;}
|
||||
void dms_fi_change_buffertag_blocknum(const dms_fi_entry *entry, va_list args) {};
|
||||
void ss_fi_change_buffertag_blocknum(const void *ddes_fi_entry, va_list args) {}
|
||||
#endif
|
||||
@ -377,18 +377,23 @@ static void SetWorkThreadpoolConfig(dms_profile_t *profile)
|
||||
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
static void set_dms_fi()
|
||||
{
|
||||
{
|
||||
knl_session_attr_dms* attr = &u_sess->attr.attr_storage.dms_attr;
|
||||
dms_fi_set_entries(DMS_FI_TYPE_PACKET_LOSS, attr->packet_loss.ss_fi_cfg.entries, attr->packet_loss.ss_fi_cfg.count);
|
||||
dms_fi_set_entry_value(DMS_FI_TYPE_PACKET_LOSS, attr->packet_loss.ss_fi_cfg.fault_value);
|
||||
dms_fi_set_entries(DMS_FI_TYPE_NET_LATENCY, attr->net_latency.ss_fi_cfg.entries, attr->net_latency.ss_fi_cfg.count);
|
||||
dms_fi_set_entry_value(DMS_FI_TYPE_NET_LATENCY, attr->net_latency.ss_fi_cfg.fault_value);
|
||||
dms_fi_set_entries(DMS_FI_TYPE_CPU_LATENCY, attr->cpu_latency.ss_fi_cfg.entries, attr->cpu_latency.ss_fi_cfg.count);
|
||||
dms_fi_set_entry_value(DMS_FI_TYPE_CPU_LATENCY, attr->cpu_latency.ss_fi_cfg.fault_value);
|
||||
dms_fi_set_entries(DMS_FI_TYPE_PROCESS_FAULT, attr->process_fault.ss_fi_cfg.entries, attr->process_fault.ss_fi_cfg.count);
|
||||
dms_fi_set_entry_value(DMS_FI_TYPE_PROCESS_FAULT, attr->process_fault.ss_fi_cfg.fault_value);
|
||||
dms_fi_set_entries(DMS_FI_TYPE_CUSTOM_FAULT, attr->custom_fault.ss_fi_cfg.entries, attr->custom_fault.ss_fi_cfg.count);
|
||||
dms_fi_set_entry_value(DMS_FI_TYPE_CUSTOM_FAULT, attr->custom_fault.ss_fi_cfg.fault_value);
|
||||
ss_fi_set_entries(DDES_FI_TYPE_PACKET_LOSS, (unsigned int *)attr->packet_loss.fi_entries,
|
||||
attr->packet_loss.ss_fi_cfg.count);
|
||||
ss_fi_set_entry_value(DDES_FI_TYPE_PACKET_LOSS, attr->packet_loss.fi_value);
|
||||
ss_fi_set_entries(DDES_FI_TYPE_NET_LATENCY, (unsigned int *)attr->net_latency.fi_entries,
|
||||
attr->net_latency.ss_fi_cfg.count);
|
||||
ss_fi_set_entry_value(DDES_FI_TYPE_NET_LATENCY, attr->net_latency.fi_value);
|
||||
ss_fi_set_entries(DDES_FI_TYPE_CPU_LATENCY, (unsigned int *)attr->cpu_latency.fi_entries,
|
||||
attr->cpu_latency.ss_fi_cfg.count);
|
||||
ss_fi_set_entry_value(DDES_FI_TYPE_CPU_LATENCY, attr->cpu_latency.fi_value);
|
||||
ss_fi_set_entries(DDES_FI_TYPE_PROCESS_FAULT, (unsigned int *)attr->process_fault.fi_entries,
|
||||
attr->process_fault.ss_fi_cfg.count);
|
||||
ss_fi_set_entry_value(DDES_FI_TYPE_PROCESS_FAULT, attr->process_fault.fi_value);
|
||||
ss_fi_set_entries(DDES_FI_TYPE_CUSTOM_FAULT, (unsigned int *)attr->custom_fault.fi_entries,
|
||||
attr->custom_fault.ss_fi_cfg.count);
|
||||
ss_fi_set_entry_value(DDES_FI_TYPE_CUSTOM_FAULT, attr->custom_fault.fi_value);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
dms_commit_id=3718cc4fb90f76573f25ee7bf6a99979e5afe12d
|
||||
dss_commit_id=083e52af8c7f965856f319554d6332b14f6b2c99
|
||||
cbb_commit_id=935d52372d18881a5310e9d7f8623d6a539ba0a0
|
||||
dms_commit_id=5f2ea70cbe331bba7592bec494a1e9d0e1ddbb91
|
||||
dss_commit_id=8c107efa9d665d7231ac862f0a37d5976669c931
|
||||
cbb_commit_id=8c0777b6e70359ff350bfbf8da005199a17a3215
|
||||
|
||||
81
src/include/ddes/dms/ddes_fault_injection_defs.h
Normal file
81
src/include/ddes/dms/ddes_fault_injection_defs.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Technologies Co.,Ltd.
|
||||
*
|
||||
* openGauss is licensed under Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
*
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
* ---------------------------------------------------------------------------------------
|
||||
*
|
||||
* ddes_fault_injection_def.h
|
||||
*
|
||||
* Defines the DMS fault injection function
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* src/gausskernel/ddes/adapter/ddes_fault_injection_def.h
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef __DDES_FAULT_INJECTION_DEFS_H__
|
||||
#define __DDES_FAULT_INJECTION_DEFS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum e_ddes_fi_type {
|
||||
DDES_FI_TYPE_BEGIN = 0,
|
||||
DDES_FI_TYPE_PACKET_LOSS = DDES_FI_TYPE_BEGIN,
|
||||
DDES_FI_TYPE_NET_LATENCY,
|
||||
DDES_FI_TYPE_CPU_LATENCY,
|
||||
DDES_FI_TYPE_PROCESS_FAULT,
|
||||
DDES_FI_TYPE_CUSTOM_FAULT,
|
||||
DDES_FI_TYPE_END,
|
||||
} ddes_fi_type_e;
|
||||
|
||||
#define DDES_FI_ENTRY_BEGIN 0
|
||||
#define DDES_FI_ENTRY_COUNT 11024
|
||||
#define DDES_FI_ENTRY_END (DDES_FI_ENTRY_BEGIN + DDES_FI_ENTRY_COUNT)
|
||||
#define DDES_FI_ENTRY_COUNT_PER_TYPE 2000 // set count per time
|
||||
|
||||
// uplayer should NOT define entry id between [DDES_FI_ENTRY_RESERVE_BEGIN, DDES_FI_ENTRY_RESERVE_END],
|
||||
// they are reserved for cbb functions
|
||||
#define DDES_FI_ENTRY_RESERVE_BEGIN 2000
|
||||
#define DDES_FI_ENTRY_RESERVE_COUNT 2000
|
||||
#define DDES_FI_ENTRY_RESERVE_END (DDES_FI_ENTRY_RESERVE_BEGIN + DDES_FI_ENTRY_RESERVE_COUNT)
|
||||
|
||||
/*
|
||||
* the follow defines SHOULD be the same as the defines in cbb/ddes_fi_ddes_fault_injection.h
|
||||
|
||||
// begin: SHOULD call these by caller to init fi context before using other interfaces
|
||||
DDES_DECLARE int ddes_fi_get_context_size(void);
|
||||
DDES_DECLARE void ddes_fi_set_and_init_context(void *context);
|
||||
DDES_DECLARE void ddes_fi_set_context(void *context);
|
||||
// end: SHOULD call these by caller to init fi context before using other interfaces
|
||||
|
||||
DDES_DECLARE int ddes_fi_set_entries(unsigned int type, unsigned int *entries, unsigned int count);
|
||||
DDES_DECLARE int ddes_fi_parse_and_set_entry_list(unsigned int type, char *value);
|
||||
DDES_DECLARE unsigned int ddes_fi_get_entry_value(unsigned int type);
|
||||
DDES_DECLARE int ddes_fi_set_entry_value(unsigned int type, unsigned int value);
|
||||
DDES_DECLARE int ddes_fi_get_tls_trigger(void);
|
||||
DDES_DECLARE void ddes_fi_set_tls_trigger(int val);
|
||||
DDES_DECLARE int ddes_fi_get_tls_trigger_custom(void);
|
||||
DDES_DECLARE void ddes_fi_set_tls_trigger_custom(int val);
|
||||
DDES_DECLARE void ddes_fi_call(unsigned int point, ...);
|
||||
DDES_DECLARE void ddes_fi_call_ex(unsigned int point, va_list args);
|
||||
DDES_DECLARE bool8 ddes_fi_entry_custom_valid(unsigned int point);
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DDES_FAULT_INJECTION_DEFS_H__ */
|
||||
@ -26,6 +26,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -34,7 +35,7 @@ extern "C" {
|
||||
#define DMS_LOCAL_MINOR_VER_WEIGHT 1000
|
||||
#define DMS_LOCAL_MAJOR_VERSION 0
|
||||
#define DMS_LOCAL_MINOR_VERSION 0
|
||||
#define DMS_LOCAL_VERSION 165
|
||||
#define DMS_LOCAL_VERSION 167
|
||||
|
||||
#define DMS_SUCCESS 0
|
||||
#define DMS_ERROR (-1)
|
||||
@ -66,11 +67,6 @@ extern "C" {
|
||||
#define DMS_MAX_XA_BASE16_GTRID_LEN (128)
|
||||
#define DMS_MAX_XA_BASE16_BQUAL_LEN (128)
|
||||
|
||||
#define DB_FI_ENTRY_BEGIN 10000
|
||||
#define DB_FI_ENTRY_COUNT 1024
|
||||
#define FI_ENTRY_END (DB_FI_ENTRY_BEGIN + DB_FI_ENTRY_COUNT)
|
||||
#define MAX_FI_ENTRY_COUNT 2000
|
||||
|
||||
#define MAX_DMS_THREAD_NUM 512
|
||||
|
||||
typedef enum en_dms_online_status {
|
||||
@ -618,6 +614,7 @@ typedef enum en_dms_wait_event {
|
||||
DMS_EVT_REQ_CKPT,
|
||||
DMS_EVT_PROC_GENERIC_REQ,
|
||||
DMS_EVT_PROC_REFORM_REQ,
|
||||
DMS_EVT_DCS_TRANSTER_PAGE_LSNDWAIT,
|
||||
|
||||
// add new enum at tail, or make adaptations to openGauss
|
||||
DMS_EVT_COUNT,
|
||||
@ -806,8 +803,6 @@ typedef struct st_dms_msg_stats {
|
||||
dms_stat_by_cmd_t stat_cmd[DMS_STAT_CMD_COUNT];
|
||||
} dms_msg_stats_t;
|
||||
|
||||
typedef struct dms_fi_entry dms_fi_entry;
|
||||
typedef int(*dms_fi_callback_func)(const dms_fi_entry *entry, va_list args);
|
||||
typedef int(*dms_get_list_stable)(void *db_handle, unsigned long long *list_stable, unsigned char *reformer_id);
|
||||
typedef int(*dms_save_list_stable)(void *db_handle, unsigned long long list_stable, unsigned char reformer_id,
|
||||
unsigned long long list_in, unsigned int save_ctrl);
|
||||
@ -899,6 +894,7 @@ typedef void (*dms_log_output)(dms_log_id_t log_type, dms_log_level_t log_level,
|
||||
unsigned int code_line_num, const char *module_name, const char *format, ...);
|
||||
typedef int (*dms_log_flush)(void *db_handle, unsigned long long *lsn);
|
||||
typedef int (*dms_log_conditional_flush)(void *db_handle, unsigned long long lfn, unsigned long long *lsn);
|
||||
typedef void (*dms_lsnd_wait)(void *db_handle, unsigned long long lfn);
|
||||
typedef int(*dms_process_edp)(void *db_handle, dms_edp_info_t *pages, unsigned int count);
|
||||
typedef void (*dms_clean_ctrl_edp)(void *db_handle, dms_buf_ctrl_t *dms_ctrl);
|
||||
typedef char *(*dms_display_pageid)(char *display_buf, unsigned int count, char *pageid);
|
||||
@ -1105,6 +1101,7 @@ typedef struct st_dms_callback {
|
||||
dms_log_output log_output;
|
||||
dms_log_flush log_flush;
|
||||
dms_log_conditional_flush log_conditional_flush;
|
||||
dms_lsnd_wait lsnd_wait;
|
||||
dms_process_edp ckpt_edp;
|
||||
dms_process_edp clean_edp;
|
||||
dms_ckpt_session ckpt_session;
|
||||
@ -1204,12 +1201,6 @@ typedef struct st_dms_instance_net_addr {
|
||||
unsigned char reserved[1];
|
||||
} dms_instance_net_addr_t;
|
||||
|
||||
typedef struct dms_fi_config {
|
||||
unsigned int entries[MAX_FI_ENTRY_COUNT];
|
||||
unsigned int count;
|
||||
unsigned int fault_value;
|
||||
} dms_fi_config_t;
|
||||
|
||||
typedef struct st_dms_profile {
|
||||
unsigned int inst_id;
|
||||
unsigned long long inst_map;
|
||||
@ -1317,23 +1308,17 @@ typedef enum en_reform_callback_stat {
|
||||
REFORM_CALLBACK_STAT_GET_DATAFILE_SIZE,
|
||||
REFORM_CALLBACK_STAT_OPEN_CTRLFILE,
|
||||
REFORM_CALLBACK_STAT_GET_CTRLFILE_SIZE,
|
||||
REFORM_CALLBACK_STAT_OPEN_DW_FILE,
|
||||
REFORM_CALLBACK_STAT_READ_DW_FILE,
|
||||
REFORM_CALLBACK_STAT_CHECK_REDO,
|
||||
REFORM_CALLBACK_STAT_SPC_DW_FLUSH,
|
||||
REFORM_CALLBACK_STAT_COUNT
|
||||
} reform_callback_stat_e;
|
||||
|
||||
typedef enum e_dms_fi_type {
|
||||
DMS_FI_TYPE_BEGIN = 0,
|
||||
DMS_FI_TYPE_PACKET_LOSS = DMS_FI_TYPE_BEGIN,
|
||||
DMS_FI_TYPE_NET_LATENCY,
|
||||
DMS_FI_TYPE_CPU_LATENCY,
|
||||
DMS_FI_TYPE_PROCESS_FAULT,
|
||||
DMS_FI_TYPE_CUSTOM_FAULT,
|
||||
DMS_FI_TYPE_END,
|
||||
} dms_fi_type_e;
|
||||
|
||||
typedef enum en_db_call_dms_trigger_fi_point_name {
|
||||
// call in db, trigger in dms, point range[10800, DB_FI_ENTRY_END]
|
||||
// call in db, trigger in dms, point range[10800, 11024]
|
||||
DB_FI_CHANGE_STATUS_AFTER_TRANSFER_PAGE = 10800,
|
||||
DB_FI_ENTRY_END = FI_ENTRY_END
|
||||
DB_FI_ENTRY_END = 11024, // which should be <= DDES_FI_ENTRY_COUNT
|
||||
} db_call_dms_trigger_fi_point_name;
|
||||
|
||||
typedef enum en_dms_call_db_trigger_fi_point_name {
|
||||
@ -1342,13 +1327,6 @@ typedef enum en_dms_call_db_trigger_fi_point_name {
|
||||
DMS_FI_ENTRY_END
|
||||
} dms_call_db_trigger_fi_point_name;
|
||||
|
||||
struct dms_fi_entry {
|
||||
int pointId;
|
||||
unsigned int faultFlags;
|
||||
int calledCount;
|
||||
dms_fi_callback_func func;
|
||||
};
|
||||
|
||||
typedef struct st_dms_tlock_info {
|
||||
dms_drid_t resid;
|
||||
unsigned char lock_mode;
|
||||
|
||||
@ -93,12 +93,20 @@ typedef struct st_ss_dms_func {
|
||||
void (*dms_get_cmd_stat)(int index, wait_cmd_stat_result_t *cmd_stat_result);
|
||||
int (*dms_req_opengauss_immediate_ckpt)(dms_context_t *dms_ctx, unsigned long long *ckpt_loc);
|
||||
void (*dms_fsync_logfile)(void);
|
||||
int (*dms_fi_set_entries)(unsigned int type, unsigned int *entries, unsigned int count);
|
||||
int (*dms_fi_set_entry_value)(unsigned int type, unsigned int value);
|
||||
int (*dms_fi_get_tls_trigger_custom)(void);
|
||||
void (*dms_fi_set_tls_trigger_custom)(int val);
|
||||
void (*fault_injection_call)(unsigned int point, ...);
|
||||
unsigned char (*dms_fi_entry_custom_valid)(unsigned int point);
|
||||
|
||||
int (*ddes_fi_get_context_size)(void);
|
||||
void (*ddes_fi_set_and_init_context)(void *context);
|
||||
int (*ddes_fi_set_entries)(unsigned int type, unsigned int *entries, unsigned int count);
|
||||
unsigned int (*ddes_fi_get_entry_value)(unsigned int type);
|
||||
int (*ddes_fi_set_entry_value)(unsigned int type, unsigned int value);
|
||||
int (*ddes_fi_get_tls_trigger_custom)(void);
|
||||
void (*ddes_fi_set_tls_trigger_custom)(int val);
|
||||
unsigned char (*ddes_fi_entry_custom_valid)(unsigned int point);
|
||||
|
||||
// this is for macro calling
|
||||
void (*ddes_fi_call)(unsigned int point, ...);
|
||||
// this is for function calling
|
||||
void (*ddes_fi_call_ex)(unsigned int point, va_list args);
|
||||
} ss_dms_func_t;
|
||||
|
||||
int ss_dms_func_init();
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#define __SS_DMS_FI_H__
|
||||
|
||||
#include "dms_api.h"
|
||||
#include "ddes/dms/ddes_fault_injection_defs.h"
|
||||
#include "ddes/dms/ss_dms.h"
|
||||
#include "utils/elog.h"
|
||||
|
||||
@ -33,23 +34,33 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DB_FI_ENTRY_BEGIN 10000
|
||||
#define DB_FI_ENTRY_COUNT 1024
|
||||
|
||||
typedef enum en_db_fi_point_name {
|
||||
// if CALL and TRIGGER both in kernel point range [10001, 10799]
|
||||
// if CALL and TRIGGER both in kernel point range [10001, 10799]DDES_FI_ENTRY_END
|
||||
DB_FI_CHANGE_BUFFERTAG_BLOCKNUM = DB_FI_ENTRY_BEGIN + 1,
|
||||
} db_fi_point_name;
|
||||
|
||||
int dms_fi_set_entries(unsigned int type, unsigned int *entries, unsigned int count);
|
||||
int dms_fi_set_entry_value(unsigned int type, unsigned int value);
|
||||
int dms_fi_get_tls_trigger_custom(void);
|
||||
void dms_fi_set_tls_trigger_custom(int val);
|
||||
unsigned char dms_fi_entry_custom_valid(unsigned int point);
|
||||
void dms_fi_change_buffertag_blocknum(const dms_fi_entry *entry, va_list args);
|
||||
// for alloc fi context with size return size
|
||||
int ss_fi_get_context_size(void);
|
||||
// set the fi context with the context, and init the context, the context alloced by DB
|
||||
void ss_fi_set_and_init_context(void *context);
|
||||
|
||||
int ss_fi_set_entries(unsigned int type, unsigned int *entries, unsigned int count);
|
||||
int ss_fi_get_entry_value(unsigned int type);
|
||||
int ss_fi_set_entry_value(unsigned int type, unsigned int value);
|
||||
int ss_fi_get_tls_trigger_custom(void);
|
||||
void ss_fi_set_tls_trigger_custom(int val);
|
||||
unsigned char ss_fi_entry_custom_valid(unsigned int point);
|
||||
|
||||
void ss_fi_change_buffertag_blocknum(const void *ddes_fi_entry, va_list args);
|
||||
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
#define FAULT_INJECTION_ACTION_TRIGGER_CUSTOM(point, action) \
|
||||
#define SS_FAULT_INJECTION_ACTION_TRIGGER_CUSTOM(point, action) \
|
||||
do { \
|
||||
if (dms_fi_entry_custom_valid(point) && dms_fi_get_tls_trigger_custom() == TRUE) { \
|
||||
dms_fi_set_tls_trigger_custom(FALSE); \
|
||||
if (ss_fi_entry_custom_valid(point) && ss_fi_get_tls_trigger_custom() == TRUE) { \
|
||||
ss_fi_set_tls_trigger_custom(FALSE); \
|
||||
ereport(DEBUG1, (errmsg("[KERNEL_FI] fi custom action happens at %s", __FUNCTION__))); \
|
||||
action; \
|
||||
} \
|
||||
@ -58,12 +69,12 @@ void dms_fi_change_buffertag_blocknum(const dms_fi_entry *entry, va_list args);
|
||||
#define SS_FAULT_INJECTION_CALL(point, ...) \
|
||||
do { \
|
||||
if (g_ss_dms_func.inited) { \
|
||||
g_ss_dms_func.fault_injection_call(point, ##__VA_ARGS__); \
|
||||
g_ss_dms_func.ddes_fi_call(point, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
#define FAULT_INJECTION_ACTION_TRIGGER_CUSTOM(point, action)
|
||||
#define SS_FAULT_INJECTION_ACTION_TRIGGER_CUSTOM(point, action)
|
||||
#define SS_FAULT_INJECTION_CALL(point, ...)
|
||||
#endif
|
||||
|
||||
|
||||
@ -59,13 +59,13 @@ typedef struct knl_session_attr_dcf {
|
||||
int dcf_truncate_threshold;
|
||||
} knl_session_attr_dcf;
|
||||
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
typedef struct knl_sess_attr_dms_fi_cfg {
|
||||
unsigned int entries[MAX_DMS_FI_ENTRY_COUNT];
|
||||
unsigned int count;
|
||||
unsigned int fault_value;
|
||||
} knl_sess_attr_dms_fi_cfg;
|
||||
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
typedef struct knl_session_attr_dms_fi {
|
||||
char* fi_entries;
|
||||
int32 fi_value;
|
||||
|
||||
@ -1449,6 +1449,9 @@ typedef struct knl_instance_context {
|
||||
#ifdef USE_SPQ
|
||||
knl_g_spq_context spq_cxt;
|
||||
#endif
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
void *shared_fi_ctx;
|
||||
#endif
|
||||
} knl_instance_context;
|
||||
|
||||
extern long random();
|
||||
|
||||
Reference in New Issue
Block a user