增加日志:记录redis事务里,主版本号和预备版本号的变化。

This commit is contained in:
zhengchao
2019-02-20 15:16:04 +06:00
parent 42c6c45ae4
commit dd98aaa2db
2 changed files with 18 additions and 8 deletions

View File

@@ -1255,7 +1255,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() 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); struct expected_reply *expected_reply=(struct expected_reply*)calloc(sizeof(struct expected_reply), max_multi_cmd_num);
long long new_version=0; long long new_version=0, transaction_finished_version=0;
int renew_num=0,ret=0; int renew_num=0,ret=0;
for(i=0;i<serial_rule_num;i++) for(i=0;i<serial_rule_num;i++)
{ {
@@ -1266,7 +1266,7 @@ int exec_serial_rule(redisContext* ctx,struct serial_rule_t* s_rule, unsigned in
} }
ret=_exec_serial_rule_begin(ctx,serial_rule_num,renew_num, &renew_allowed, &new_version); ret=_exec_serial_rule_begin(ctx,serial_rule_num,renew_num, &renew_allowed, &new_version);
if(ret!=0)//Preconditions of transaction is not qualified. if(ret!=0)//Preconditions for transaction are not satisfied.
{ {
success_cnt=-1; success_cnt=-1;
goto error_out; goto error_out;
@@ -1293,10 +1293,10 @@ int exec_serial_rule(redisContext* ctx,struct serial_rule_t* s_rule, unsigned in
continue; continue;
} }
rule_seq=expected_reply[i].srule_seq; rule_seq=expected_reply[i].srule_seq;
MESA_handle_runtime_log(logger,RLOG_LV_FATAL,maat_command MESA_handle_runtime_log(logger, RLOG_LV_FATAL, maat_command,
,"%s %s %d failed, rule id maybe conflict or not exist." "%s %s %d failed, rule id maybe conflict or not exist.",
,mr_op_str[s_rule[rule_seq].op] mr_op_str[s_rule[rule_seq].op],
,s_rule[rule_seq].table_name,s_rule[rule_seq].rule_id); s_rule[rule_seq].table_name,s_rule[rule_seq].rule_id);
success_cnt--; success_cnt--;
last_failed=rule_seq; last_failed=rule_seq;
} }
@@ -1305,6 +1305,16 @@ int exec_serial_rule(redisContext* ctx,struct serial_rule_t* s_rule, unsigned in
{ {
success_cnt=-1; success_cnt=-1;
} }
if(new_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_finished_version,
transaction_finished_version==new_version?"OK":"Weird");
}
freeReplyObject(transaction_reply); freeReplyObject(transaction_reply);
error_out: error_out:

View File

@@ -32,7 +32,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_6_20190127=1; int MAAT_FRAME_VERSION_2_6_20190220=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",""};