【修复bug】向maat redis写入重复配置ID时,版本号会增加,但MAAT_UPDATE_STATUS中没有配置变化记录。当MAAT_OPT_CUMULATIVE_UPDATE_OFF打开后,会导致配置更新线程卡死。

This commit is contained in:
zhengchao
2018-02-11 14:09:38 +08:00
parent c78be056c0
commit 4d8e5f8e25
2 changed files with 29 additions and 17 deletions

View File

@@ -360,7 +360,8 @@ int get_rm_key_list(long long version,redisContext *c,struct serial_rule_t** lis
redisReply* reply=NULL,*sub_reply=NULL,*tmp_reply=NULL; redisReply* reply=NULL,*sub_reply=NULL,*tmp_reply=NULL;
char err_buff[256]; char err_buff[256];
char op_str[4]; char op_str[4];
long long version_in_redis=0,nearest_rule_version=0; long long version_in_redis=0,target_version=0,nearest_rule_version=0;
int rule_num=0;
int ret=0; int ret=0;
unsigned int i=0,full_idx =0,append_cmd_cnt=0; unsigned int i=0,full_idx =0,append_cmd_cnt=0;
struct serial_rule_t *s_rule=NULL; struct serial_rule_t *s_rule=NULL;
@@ -405,12 +406,16 @@ int get_rm_key_list(long long version,redisContext *c,struct serial_rule_t** lis
} }
if(version_in_redis>version&&cumulative_off==1) if(version_in_redis>version&&cumulative_off==1)
{ {
version_in_redis=version+1; target_version=version+1;
} }
else
{
target_version=version_in_redis;
}
do{
//Returns all the elements in the sorted set at key with a score that version < score <= version_in_redis. //Returns all the elements in the sorted set at key with a score that version < score <= version_in_redis.
//The elements are considered to be ordered from low to high scores(version). //The elements are considered to be ordered from low to high scores(version).
reply=(redisReply*)redisCommand(c, "ZRANGEBYSCORE %s (%lld %lld",rm_status_sset,version,version_in_redis); reply=(redisReply*)redisCommand(c, "ZRANGEBYSCORE %s (%lld %lld",rm_status_sset,version,target_version);
if(reply==NULL) if(reply==NULL)
{ {
@@ -420,11 +425,18 @@ int get_rm_key_list(long long version,redisContext *c,struct serial_rule_t** lis
return -1; return -1;
} }
assert(reply->type==REDIS_REPLY_ARRAY); assert(reply->type==REDIS_REPLY_ARRAY);
rule_num=reply->elements;
if(reply->elements==0) if(reply->elements==0)
{ {
//a duplicate rule_id would induce this error. //a duplicate rule_id would induce this error.
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_redis_monitor,"Got nothing after ZRANGEBYSCORE %s (%lld %lld",rm_status_sset,version,version_in_redis);
freeReplyObject(reply); freeReplyObject(reply);
}
target_version++;
}while(rule_num==0&&target_version<=version_in_redis&&cumulative_off==1);
if(rule_num==0)
{
MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_redis_monitor,"Got nothing after ZRANGEBYSCORE %s (%lld %lld, cumulative=%d"
,rm_status_sset,version,target_version-1,!cumulative_off);
return -1; return -1;
} }
tmp_reply=_wrap_redisCommand(c, "ZSCORE %s %s",rm_status_sset,reply->element[0]->str); tmp_reply=_wrap_redisCommand(c, "ZSCORE %s %s",rm_status_sset,reply->element[0]->str);

View File

@@ -30,7 +30,7 @@
#include "stream_fuzzy_hash.h" #include "stream_fuzzy_hash.h"
#include "gram_index_engine.h" #include "gram_index_engine.h"
int MAAT_FRAME_VERSION_2_1_20180126=1; int MAAT_FRAME_VERSION_2_1_20180209=1;
const char* CHARSET_STRING[]={"NONE","gbk","big5","unicode","utf8","bin", const char* CHARSET_STRING[]={"NONE","gbk","big5","unicode","utf8","bin",
"unicode_ascii_esc","unicode_ascii_aligned","unicode_ncr_dec","unicode_ncr_hex","url_encode_gb2312","url_encode_utf8",""}; "unicode_ascii_esc","unicode_ascii_aligned","unicode_ncr_dec","unicode_ncr_hex","url_encode_gb2312","url_encode_utf8",""};