diff --git a/src/entry/Maat_command.cpp b/src/entry/Maat_command.cpp index c5a8227..b3ddf22 100644 --- a/src/entry/Maat_command.cpp +++ b/src/entry/Maat_command.cpp @@ -591,7 +591,7 @@ int get_rm_key_list(redisContext *c, long long instance_version, long long desir return 0; } MESA_handle_runtime_log(logger, RLOG_LV_INFO, maat_redis_monitor, - "Inc Update form instance_version %lld to %lld (%d entries).",instance_version,target_version,rule_num); + "Inc Update from instance_version %lld to %lld (%d entries).",instance_version,target_version,rule_num); *list=s_rule_array; *update_type=CM_UPDATE_TYPE_INC; *new_version=target_version; @@ -1086,6 +1086,20 @@ long long _exec_serial_rule_begin(redisContext* ctx,int rule_num, int renew_rule } return ret; } +//parameters: 3 keys: MAAT_VERSION MAAT_UPDATE_STATUS MAAT_VERSION_TIMER, 2 args: TRANSACTION_VERSION SERVER_TIME +const char* lua_exec_done= +"\ +local transaction_version=tonumber(ARGV[1])\n\ +local maat_version=redis.call(\'incrby\', KEYS[1], 1)\n\ +if(maat_version~=transaction_version) then\ + local affected=redis.call(\'zrangebyscore\', KEYS[2], transaction_version, transaction_version);\ + for k,v in pairs(affected) do\ + redis.call(\'zadd\', KEYS[2], maat_version, v);\ + end;\ +end;\ +redis.call(\'zadd\', KEYS[3], maat_version, ARGV[2]);\ +return maat_version;\ +"; redisReply* _exec_serial_rule_end(redisContext* ctx,long long maat_redis_version, long long server_time, int renew_allowed, struct expected_reply* expect_reply, unsigned int *cnt) { redisReply* data_reply=NULL; @@ -1097,14 +1111,15 @@ redisReply* _exec_serial_rule_end(redisContext* ctx,long long maat_redis_version } if(maat_redis_version>0) { - data_reply=_wrap_redisCommand(ctx,"ZADD %s NX %d %d",mr_version_sset,server_time,maat_redis_version); + data_reply=_wrap_redisCommand(ctx, "eval %s 3 MAAT_VERSION %s %s %lld %lld", + lua_exec_done, + mr_status_sset, + mr_version_sset, + maat_redis_version, + server_time); freeReplyObject(data_reply); expected_reply_add(expect_reply+*cnt, -1, REDIS_REPLY_INTEGER, 0); (*cnt)++; - data_reply=_wrap_redisCommand(ctx,"INCRBY MAAT_VERSION 1"); - freeReplyObject(data_reply); - expected_reply_add(expect_reply+*cnt, -1, REDIS_REPLY_INTEGER, 0); - (*cnt)++; } data_reply=_wrap_redisCommand(ctx,"EXEC"); return data_reply; @@ -1255,7 +1270,7 @@ int exec_serial_rule(redisContext* ctx,struct serial_rule_t* s_rule, unsigned in unsigned int max_multi_cmd_num=MAX_REDIS_OP_PER_SRULE*serial_rule_num+2;// 2 for operation in _exec_serial_rule_end() struct expected_reply *expected_reply=(struct expected_reply*)calloc(sizeof(struct expected_reply), max_multi_cmd_num); - long long new_version=0, transaction_finished_version=0; + long long transaction_version=0, transaction_finished_version=0; int renew_num=0,ret=0; for(i=0;ielements==multi_cmd_cnt); @@ -1305,14 +1320,14 @@ int exec_serial_rule(redisContext* ctx,struct serial_rule_t* s_rule, unsigned in { success_cnt=-1; } - if(new_version>0) + if(transaction_version>0) { transaction_finished_version=read_redis_integer(transaction_reply->element[multi_cmd_cnt-1]); MESA_handle_runtime_log(logger, RLOG_LV_INFO, maat_command, "Redis transaction version: %lld, transaction finished version: %lld, status: %s", - new_version, + transaction_version, transaction_finished_version, - transaction_finished_version==new_version?"OK":"Weird"); + transaction_finished_version==transaction_version?"OK":"Weird"); } freeReplyObject(transaction_reply); diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index 9017822..cf85263 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -32,7 +32,7 @@ #include "stream_fuzzy_hash.h" #include "gram_index_engine.h" -int MAAT_FRAME_VERSION_2_6_20190220=1; +int MAAT_FRAME_VERSION_2_6_20190221=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",""};