diff --git a/src/entry/Maat_api.cpp b/src/entry/Maat_api.cpp index 583b2b2..16a936a 100644 --- a/src/entry/Maat_api.cpp +++ b/src/entry/Maat_api.cpp @@ -1342,6 +1342,11 @@ int Maat_full_scan_string_detail(Maat_feather_t feather,int table_id { return 0; } + my_scanner=_feather->scanner; + if(my_scanner==NULL) + { + return 0; + } if(_feather->perf_on==1) { clock_gettime(CLOCK_MONOTONIC,&start); @@ -1372,11 +1377,7 @@ int Maat_full_scan_string_detail(Maat_feather_t feather,int table_id scan_data.text_data.text=data; scan_data.text_data.tlen=data_len; scan_data.text_data.toffset=0; - my_scanner=_feather->scanner; - if(my_scanner==NULL) - { - return 0; - } + struct Maat_table_runtime* table_rt=my_scanner->table_rt[table_id]; if(table_rt->origin_rule_num==0) { diff --git a/src/entry/Maat_command.cpp b/src/entry/Maat_command.cpp index b3ddf22..51bc977 100644 --- a/src/entry/Maat_command.cpp +++ b/src/entry/Maat_command.cpp @@ -1056,7 +1056,7 @@ int mr_operation_success(redisReply* actual_reply, struct expected_reply* expect } -long long _exec_serial_rule_begin(redisContext* ctx,int rule_num, int renew_rule_num,int *renew_allowed, long long *maat_redis_version) +long long _exec_serial_rule_begin(redisContext* ctx,int rule_num, int renew_rule_num,int *renew_allowed, long long *transaction_version) { int ret=-1; redisReply* data_reply=NULL; @@ -1071,9 +1071,9 @@ long long _exec_serial_rule_begin(redisContext* ctx,int rule_num, int renew_rule if(rule_num>renew_rule_num) { data_reply=_wrap_redisCommand(ctx, "INCRBY MAAT_PRE_VER 1"); - *maat_redis_version=read_redis_integer(data_reply); + *transaction_version=read_redis_integer(data_reply); freeReplyObject(data_reply); - if(*maat_redis_version<0) + if(*transaction_version<0) { return -1; } @@ -1097,7 +1097,7 @@ if(maat_version~=transaction_version) then\ redis.call(\'zadd\', KEYS[2], maat_version, v);\ end;\ end;\ -redis.call(\'zadd\', KEYS[3], maat_version, ARGV[2]);\ +redis.call(\'zadd\', KEYS[3], ARGV[2], maat_version);\ 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) @@ -1323,11 +1323,13 @@ int exec_serial_rule(redisContext* ctx,struct serial_rule_t* s_rule, unsigned in 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", + if(transaction_finished_version!=transaction_version) + { + MESA_handle_runtime_log(logger, RLOG_LV_INFO, maat_command, + "Race condition of redis transaction (MAAT_PRE_VER != MAAT_VERSION) : %lld != %lld , need manually intervention when occurrent frequently.", transaction_version, - transaction_finished_version, - transaction_finished_version==transaction_version?"OK":"Weird"); + transaction_finished_version); + } } freeReplyObject(transaction_reply); diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index cf85263..63d5bde 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_20190221=1; +int MAAT_FRAME_VERSION_2_6_20190222=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",""}; diff --git a/test/test_maatframe.cpp b/test/test_maatframe.cpp index e00183c..eb5c66b 100644 --- a/test/test_maatframe.cpp +++ b/test/test_maatframe.cpp @@ -1271,7 +1271,8 @@ protected: Maat_cmd_flushDB(_shared_feather); Maat_initiate_feather(_shared_feather); - + //For simulating race condition. + Maat_cmd_incrby(_shared_feather, "MAAT_PRE_VER", 1); } static void TearDownTestCase() {