修复bug:在command renew时,_exec_serial_rule_end没有将redlock_unlock计算在append_cmd中。

This commit is contained in:
zhengchao
2018-12-07 13:52:42 +06:00
parent 255f050f74
commit 1607e48d77
2 changed files with 11 additions and 4 deletions

View File

@@ -6,7 +6,7 @@
* to reside in the heart) of the departed would reach the paradise of afterlife * to reside in the heart) of the departed would reach the paradise of afterlife
* successfully. * successfully.
* Author: zhengchao@iie.ac.cn, MESA * Author: zhengchao@iie.ac.cn, MESA
* Version 2018-11-06 Maat Rule Extra Data. * Version 2018-12-07 Plugin Extra Data.
* NOTE: MUST compile with G++ * NOTE: MUST compile with G++
* All right reserved by Institute of Infomation Engineering,Chinese Academic of Science 2014~2018 * All right reserved by Institute of Infomation Engineering,Chinese Academic of Science 2014~2018
********************************************************* *********************************************************

View File

@@ -1064,19 +1064,26 @@ long long _exec_serial_rule_begin(redisContext* ctx,int rule_num, int renew_rule
} }
return ret; return ret;
} }
redisReply* _exec_serial_rule_end(redisContext* ctx,long long maat_redis_version, long long server_time, int renew_allowed) redisReply* _exec_serial_rule_end(redisContext* ctx,long long maat_redis_version, long long server_time, int renew_allowed, struct expected_reply_t* expect_reply, unsigned int *cnt)
{ {
redisReply* data_reply=NULL; redisReply* data_reply=NULL;
if(renew_allowed==1) if(renew_allowed==1)
{ {
redlock_unlock(ctx, rm_expire_lock); redlock_unlock(ctx, rm_expire_lock);
expect_reply[*cnt].srule_seq=-1;
(*cnt)++;
} }
if(maat_redis_version>0) if(maat_redis_version>0)
{ {
data_reply=_wrap_redisCommand(ctx,"ZADD %s NX %d %d",rm_version_sset,server_time,maat_redis_version); data_reply=_wrap_redisCommand(ctx,"ZADD %s NX %d %d",rm_version_sset,server_time,maat_redis_version);
freeReplyObject(data_reply); freeReplyObject(data_reply);
expect_reply[*cnt].srule_seq=-1;
(*cnt)++;
data_reply=_wrap_redisCommand(ctx,"INCRBY MAAT_VERSION 1"); data_reply=_wrap_redisCommand(ctx,"INCRBY MAAT_VERSION 1");
freeReplyObject(data_reply); freeReplyObject(data_reply);
expect_reply[*cnt].srule_seq=-1;
expect_reply[*cnt].reply.type=REDIS_REPLY_INTEGER;
(*cnt)++;
} }
data_reply=_wrap_redisCommand(ctx,"EXEC"); data_reply=_wrap_redisCommand(ctx,"EXEC");
return data_reply; return data_reply;
@@ -1247,10 +1254,10 @@ int exec_serial_rule(redisContext* ctx,struct serial_rule_t* s_rule, unsigned in
assert(multi_cmd_cnt<max_multi_cmd_num); assert(multi_cmd_cnt<max_multi_cmd_num);
success_cnt+=batch_cnt; success_cnt+=batch_cnt;
} }
transaction_reply=_exec_serial_rule_end(ctx,new_version,server_time, renew_allowed); transaction_reply=_exec_serial_rule_end(ctx,new_version,server_time, renew_allowed, expected_reply, &multi_cmd_cnt);
if(1==mr_transaction_success(transaction_reply)) if(1==mr_transaction_success(transaction_reply))
{ {
assert(transaction_reply->elements-2<=multi_cmd_cnt); assert(transaction_reply->elements==multi_cmd_cnt);
for(i=0;i<multi_cmd_cnt;i++) for(i=0;i<multi_cmd_cnt;i++)
{ {
p=transaction_reply->element[i]; p=transaction_reply->element[i];