修复bug:当包含外键的一个配置先无效再有效时,即配置ID重用,外键生成的本地文件会被错误的删除。
This commit is contained in:
@@ -158,8 +158,7 @@ enum MAAT_INIT_OPT
|
||||
//This option also disables background update.
|
||||
MAAT_OPT_ENABLE_UPDATE, //VALUE is interger, SIZE=sizeof(int). 1: Enabled, 0:Disabled. DEFAULT: Backgroud update is enabled. Runtime setting is allowed.
|
||||
MAAT_OPT_ACCEPT_TAGS, //VALUE is a const char*, MUST end with '\0', SIZE= strlen(string+'\0')+1. Format is a JSON, e.g.{"tags":[{"tag":"location","value":"Beijing/ChaoYang/Huayan/22A"},{"tag":"isp","value":"telecom"}]}
|
||||
MAAT_OPT_FOREIGN_CONT_DIR, //VALUE is a const char*, MUST end with '\0', SIZE= strlen(string+'\0')+1. Specifies a local diretory to store foreign content. Default: []table_info_path]_files
|
||||
MAAT_OPT_FOREIGN_CONT_LINGER //VALUE is interger *, SIZE=sizeof(int). Greater than 0: delete after VALUE seconds; 0: delete foreign content right after the notification callbacks; Less than 0: NEVER delete. Default: 0.
|
||||
MAAT_OPT_FOREIGN_CONT_DIR //VALUE is a const char*, MUST end with '\0', SIZE= strlen(string+'\0')+1. Specifies a local diretory to store foreign content. Default: []table_info_path]_files
|
||||
};
|
||||
//return -1 if failed, return 0 on success;
|
||||
int Maat_set_feather_opt(Maat_feather_t feather,enum MAAT_INIT_OPT type,const void* value,int size);
|
||||
|
||||
@@ -543,7 +543,6 @@ Maat_feather_t Maat_feather(int max_thread_num,const char* table_info_path,void*
|
||||
feather->base_rgn_seq=0;
|
||||
feather->AUTO_NUMBERING_ON=1;
|
||||
feather->backgroud_update_enabled=1;
|
||||
feather->foreign_cont_linger=0;
|
||||
snprintf(feather->foreign_cont_dir, sizeof(feather->foreign_cont_dir), "%s_files", table_info_path);
|
||||
pthread_mutex_init(&(feather->background_update_mutex),NULL);
|
||||
snprintf(feather->table_info_fn,sizeof(feather->table_info_fn),"%s",table_info_path);
|
||||
@@ -758,9 +757,6 @@ int Maat_set_feather_opt(Maat_feather_t feather,enum MAAT_INIT_OPT type,const vo
|
||||
_feather->foreign_cont_dir[strlen(_feather->foreign_cont_dir)-1]='\0';
|
||||
}
|
||||
break;
|
||||
case MAAT_OPT_FOREIGN_CONT_LINGER:
|
||||
_feather->foreign_cont_linger=*(int*)value;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1732,10 +1732,25 @@ void _get_foreign_conts(redisContext *ctx, struct serial_rule_t* rule_list, int
|
||||
for(i=0;i<rule_num;i++)
|
||||
{
|
||||
p=rule_list+i;
|
||||
if(p->op==MAAT_OP_DEL||p->n_foreign==0)
|
||||
if(p->n_foreign==0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(p->op==MAAT_OP_DEL)
|
||||
{
|
||||
for(j=0; j<rule_list[i].n_foreign; j++)
|
||||
{
|
||||
ret=system_cmd_rm(rule_list[i].f_keys[j].filename);
|
||||
if(ret==-1)
|
||||
{
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_INFO, maat_module,
|
||||
"Foreign content file %s remove failed.",
|
||||
rule_list[i].f_keys[j].filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(j=0; j<p->n_foreign; j++)
|
||||
{
|
||||
if(p->f_keys[j].is_existed==1)
|
||||
@@ -1750,6 +1765,7 @@ void _get_foreign_conts(redisContext *ctx, struct serial_rule_t* rule_list, int
|
||||
assert(ret==REDIS_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(i=0;i<key_num;i++)
|
||||
{
|
||||
ret=_wrap_redisGetReply(ctx,&reply);
|
||||
@@ -1809,7 +1825,7 @@ void redis_monitor_traverse(long long version, struct source_redis_ctx* m
|
||||
const unsigned char* dec_key,
|
||||
_Maat_feather_t* feather)
|
||||
{
|
||||
int table_id=0,i=0, j=0, rule_num=0,empty_value_num=0, valid_column=-1;
|
||||
int table_id=0, i=0, rule_num=0, empty_value_num=0, valid_column=-1;
|
||||
int ret=0;
|
||||
struct serial_rule_t* rule_list=NULL;
|
||||
int update_type=CM_UPDATE_TYPE_INC;
|
||||
@@ -1928,33 +1944,6 @@ void redis_monitor_traverse(long long version, struct source_redis_ctx* m
|
||||
{
|
||||
rewrite_table_line_with_foreign(rule_list+i);
|
||||
}
|
||||
update(rule_list[i].table_name,rule_list[i].table_line,u_para);
|
||||
if(rule_list[i].n_foreign&&rule_list[i].op==MAAT_OP_DEL)
|
||||
{
|
||||
|
||||
for(j=0; j<rule_list[i].n_foreign; j++)
|
||||
{
|
||||
if(feather->foreign_cont_linger==0)
|
||||
{
|
||||
ret=system_cmd_rm(rule_list[i].f_keys[j].filename);
|
||||
if(ret==-1)
|
||||
{
|
||||
MESA_handle_runtime_log(logger,RLOG_LV_INFO,maat_module,
|
||||
"Foreign content file %s remove failed.",
|
||||
rule_list[i].f_keys[j].filename);
|
||||
}
|
||||
}
|
||||
else if(feather->foreign_cont_linger>0)
|
||||
{
|
||||
garbage_bagging_with_timeout(GARBAGE_FOREIGN_FILE, rule_list[i].f_keys[j].filename, feather->foreign_cont_linger, feather->garbage_q);
|
||||
rule_list[i].f_keys[j].filename=NULL;//transfer owner to garbage collection.
|
||||
}
|
||||
else
|
||||
{
|
||||
//Less than 0, don't delete.
|
||||
}
|
||||
}
|
||||
|
||||
update(rule_list[i].table_name,rule_list[i].table_line,u_para);
|
||||
}
|
||||
finish(u_para);
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "stream_fuzzy_hash.h"
|
||||
#include "gram_index_engine.h"
|
||||
|
||||
int MAAT_FRAME_VERSION_2_8_20190827=1;
|
||||
int MAAT_FRAME_VERSION_2_8_20190919=1;
|
||||
|
||||
int is_valid_table_name(const char* str)
|
||||
{
|
||||
|
||||
@@ -350,7 +350,6 @@ struct _Maat_feather_t
|
||||
int n_tags;
|
||||
|
||||
char foreign_cont_dir[MAX_TABLE_NAME_LEN];
|
||||
int foreign_cont_linger;
|
||||
//internal states
|
||||
long long new_version;
|
||||
|
||||
|
||||
@@ -84,8 +84,6 @@ protected:
|
||||
|
||||
const char* foregin_dir="./foreign_files/";
|
||||
Maat_set_feather_opt(_shared_feather, MAAT_OPT_FOREIGN_CONT_DIR, foregin_dir, strlen(foregin_dir)+1);
|
||||
int linger_timeout=2;
|
||||
Maat_set_feather_opt(_shared_feather, MAAT_OPT_FOREIGN_CONT_LINGER, &linger_timeout, sizeof(linger_timeout));
|
||||
|
||||
Maat_cmd_flushDB(_shared_feather);
|
||||
Maat_initiate_feather(_shared_feather);
|
||||
|
||||
@@ -1630,8 +1630,6 @@ protected:
|
||||
|
||||
const char* foregin_dir="./foreign_files/";
|
||||
Maat_set_feather_opt(_shared_feather, MAAT_OPT_FOREIGN_CONT_DIR,foregin_dir, strlen(foregin_dir)+1);
|
||||
linger_timeout=2;
|
||||
Maat_set_feather_opt(_shared_feather, MAAT_OPT_FOREIGN_CONT_LINGER,&linger_timeout, sizeof(linger_timeout));
|
||||
|
||||
Maat_cmd_flushDB(_shared_feather);
|
||||
Maat_initiate_feather(_shared_feather);
|
||||
|
||||
Reference in New Issue
Block a user