From 4d8e5f8e25ee526bafe03c514476d44f7f256406 Mon Sep 17 00:00:00 2001 From: zhengchao Date: Sun, 11 Feb 2018 14:09:38 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8Dbug=E3=80=91?= =?UTF-8?q?=E5=90=91maat=20redis=E5=86=99=E5=85=A5=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E9=85=8D=E7=BD=AEID=E6=97=B6=EF=BC=8C=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E4=BC=9A=E5=A2=9E=E5=8A=A0=EF=BC=8C=E4=BD=86MAAT=5FUP?= =?UTF-8?q?DATE=5FSTATUS=E4=B8=AD=E6=B2=A1=E6=9C=89=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=8F=98=E5=8C=96=E8=AE=B0=E5=BD=95=E3=80=82=E5=BD=93MAAT=5FOP?= =?UTF-8?q?T=5FCUMULATIVE=5FUPDATE=5FOFF=E6=89=93=E5=BC=80=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E4=BC=9A=E5=AF=BC=E8=87=B4=E9=85=8D=E7=BD=AE=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=BA=BF=E7=A8=8B=E5=8D=A1=E6=AD=BB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entry/Maat_command.cpp | 44 ++++++++++++++++++++++++-------------- src/entry/Maat_rule.cpp | 2 +- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/entry/Maat_command.cpp b/src/entry/Maat_command.cpp index add90d9..2a6fb45 100644 --- a/src/entry/Maat_command.cpp +++ b/src/entry/Maat_command.cpp @@ -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; char err_buff[256]; 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; unsigned int i=0,full_idx =0,append_cmd_cnt=0; struct serial_rule_t *s_rule=NULL; @@ -405,26 +406,37 @@ int get_rm_key_list(long long version,redisContext *c,struct serial_rule_t** lis } 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. //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) + { + __redis_strerror_r(errno,err_buff,sizeof(err_buff)); + MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_redis_monitor, + "GET %s failed %s.",rm_status_sset,err_buff); + return -1; + } + assert(reply->type==REDIS_REPLY_ARRAY); + rule_num=reply->elements; + if(reply->elements==0) + { + //a duplicate rule_id would induce this error. + freeReplyObject(reply); + } + target_version++; + }while(rule_num==0&&target_version<=version_in_redis&&cumulative_off==1); + if(rule_num==0) { - __redis_strerror_r(errno,err_buff,sizeof(err_buff)); - MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_redis_monitor, - "GET %s failed %s.",rm_status_sset,err_buff); - return -1; - } - assert(reply->type==REDIS_REPLY_ARRAY); - if(reply->elements==0) - { - //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); + 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; } tmp_reply=_wrap_redisCommand(c, "ZSCORE %s %s",rm_status_sset,reply->element[0]->str); diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index 560bf94..80cdf57 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -30,7 +30,7 @@ #include "stream_fuzzy_hash.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", "unicode_ascii_esc","unicode_ascii_aligned","unicode_ncr_dec","unicode_ncr_hex","url_encode_gb2312","url_encode_utf8",""};