diff --git a/deps/xredis-gtid b/deps/xredis-gtid index d3d3fe6669a..2cbc573ffe8 160000 --- a/deps/xredis-gtid +++ b/deps/xredis-gtid @@ -1 +1 @@ -Subproject commit d3d3fe6669a21c5b1613b41e5d054de64f55d0b6 +Subproject commit 2cbc573ffe8c90797ebc24b8ee08162c41812faf diff --git a/src/ctrip_swap_cmd.c b/src/ctrip_swap_cmd.c index 6d6453a6b23..757cf2395a6 100644 --- a/src/ctrip_swap_cmd.c +++ b/src/ctrip_swap_cmd.c @@ -40,11 +40,11 @@ struct redisCommand redisCommandTable[SWAP_CMD_COUNT] = { 0,NULL,NULL,SWAP_IN,0,1,1,1,0,0,0}, {"getex",getexCommand,-2, - "write fast @string @swap_string", + "write fast gtid-non-determinism @string @swap_string", 0,NULL,NULL,SWAP_IN,0,1,1,1,0,0,0}, {"getdel",getdelCommand,2, - "write fast @string @swap_string", + "write fast gtid-non-determinism @string @swap_string", 0,NULL,NULL,SWAP_IN,SWAP_IN_DEL,1,1,1,0,0,0}, /* Note that we can't flag set as fast, since it may perform an @@ -58,15 +58,15 @@ struct redisCommand redisCommandTable[SWAP_CMD_COUNT] = { 0,NULL,NULL,SWAP_IN,0,1,1,1,0,0,0}, {"setex",setexCommand,4, - "write use-memory @string @swap_string @swap_keyspace", + "write use-memory gtid-non-determinism @string @swap_string @swap_keyspace", 0,NULL,NULL,SWAP_IN,SWAP_IN_OVERWRITE,1,1,1,0,0,0}, {"psetex",psetexCommand,4, - "write use-memory @string @swap_string @swap_keyspace", + "write use-memory gtid-non-determinism @string @swap_string @swap_keyspace", 0,NULL,NULL,SWAP_IN,SWAP_IN_OVERWRITE,1,1,1,0,0,0}, {"append",appendCommand,3, - "write use-memory fast @string @swap_string", + "write use-memory fast gtid-non-determinism @string @swap_string", 0,NULL,NULL,SWAP_IN,0,1,1,1,0,0,0}, {"strlen",strlenCommand,2, @@ -102,7 +102,7 @@ struct redisCommand redisCommandTable[SWAP_CMD_COUNT] = { 0,NULL,getKeyRequestsBitField,SWAP_IN,0,1,1,1,0,0,0}, {"setrange",setrangeCommand,4, - "write use-memory @string @swap_string", + "write use-memory gtid-non-determinism @string @swap_string", 0,NULL,NULL,SWAP_IN,0,1,1,1,0,0,0}, {"getrange",getrangeCommand,4, @@ -114,11 +114,11 @@ struct redisCommand redisCommandTable[SWAP_CMD_COUNT] = { 0,NULL,NULL,SWAP_IN,0,1,1,1,0,0,0}, {"incr",incrCommand,2, - "write use-memory fast @string @swap_string", + "write use-memory fast gtid-non-determinism @string @swap_string", 0,NULL,NULL,SWAP_IN,0,1,1,1,0,0,0}, {"decr",decrCommand,2, - "write use-memory fast @string @swap_string", + "write use-memory fast gtid-non-determinism @string @swap_string", 0,NULL,NULL,SWAP_IN,0,1,1,1,0,0,0}, {"mget",mgetCommand,-2, @@ -154,19 +154,19 @@ struct redisCommand redisCommandTable[SWAP_CMD_COUNT] = { 0,NULL,getKeyRequestsLpop,SWAP_IN,0,1,1,1,0,0,0}, {"brpop",brpopCommand,-3, - "write no-script @list @blocking @swap_list", + "write no-script gtid-non-determinism @list @blocking @swap_list", 0,NULL,getKeyRequestsBrpop,SWAP_IN,0,1,-2,1,0,0,0}, {"brpoplpush",brpoplpushCommand,4, - "write use-memory no-script @list @blocking @swap_list ", + "write use-memory no-script gtid-non-determinism @list @blocking @swap_list ", 0,NULL,getKeyRequestsRpoplpush,SWAP_IN,0,1,2,1,0,0,0}, {"blmove",blmoveCommand,6, - "write use-memory no-script @list @blocking @swap_list", + "write use-memory no-script gtid-non-determinism @list @blocking @swap_list", 0,NULL,getKeyRequestsLmove,SWAP_IN,0,1,2,1,0,0,0}, {"blpop",blpopCommand,-3, - "write no-script @list @blocking @swap_list", + "write no-script gtid-non-determinism @list @blocking @swap_list", 0,NULL,getKeyRequestsBlpop,SWAP_IN,0,1,-2,1,0,0,0}, {"llen",llenCommand,2, @@ -231,7 +231,7 @@ struct redisCommand redisCommandTable[SWAP_CMD_COUNT] = { 0,NULL,NULL,SWAP_IN,SWAP_IN_META,1,1,1,0,0,0}, {"spop",spopCommand,-2, - "write random fast @set @swap_set", + "write random fast gtid-non-determinism @set @swap_set", 0,NULL,NULL,SWAP_IN,SWAP_IN_DEL,1,1,1,0,0,0}, {"srandmember",srandmemberCommand,-2, @@ -387,11 +387,11 @@ struct redisCommand redisCommandTable[SWAP_CMD_COUNT] = { 0,NULL,NULL,SWAP_IN,SWAP_IN_DEL,1,1,1,0,0,0}, {"bzpopmin",bzpopminCommand,-3, - "write no-script fast @sortedset @blocking @swap_zset", + "write no-script fast gtid-non-determinism @sortedset @blocking @swap_zset", 0,NULL,getKeyRequestsZpopMin,SWAP_IN,SWAP_IN_DEL,1,-2,1,0,0,0}, {"bzpopmax",bzpopmaxCommand,-3, - "write no-script fast @sortedset @blocking @swap_zset", + "write no-script fast gtid-non-determinism @sortedset @blocking @swap_zset", 0,NULL,getKeyRequestsZpopMax,SWAP_IN,SWAP_IN_DEL,1,-2,1,0,0,0}, {"zrandmember",zrandmemberCommand,-2, @@ -419,11 +419,11 @@ struct redisCommand redisCommandTable[SWAP_CMD_COUNT] = { 0,NULL,getKeyRequestsHmget,SWAP_IN,0,1,1,1,0,0,0}, {"hincrby",hincrbyCommand,4, - "write use-memory fast @hash @swap_hash", + "write use-memory fast gtid-non-determinism @hash @swap_hash", 0,NULL,getKeyRequestsHincrby,SWAP_IN,0,1,1,1,0,0,0}, {"hincrbyfloat",hincrbyfloatCommand,4, - "write use-memory fast @hash @swap_hash", + "write use-memory fast gtid-non-determinism @hash @swap_hash", 0,NULL,getKeyRequestsHincrbyfloat,SWAP_IN,0,1,1,1,0,0,0}, {"hdel",hdelCommand,-3, @@ -471,11 +471,11 @@ struct redisCommand redisCommandTable[SWAP_CMD_COUNT] = { 0,NULL,NULL,SWAP_IN,0,1,1,1,0,0,0}, {"incrbyfloat",incrbyfloatCommand,3, - "write use-memory fast @string @swap_string", + "write use-memory fast gtid-non-determinism @string @swap_string", 0,NULL,NULL,SWAP_IN,0,1,1,1,0,0,0}, {"getset",getsetCommand,3, - "write use-memory fast @string @swap_string", + "write use-memory fast gtid-non-determinism @string @swap_string", 0,NULL,NULL,SWAP_IN,0,1,1,1,0,0,0}, {"mset",msetCommand,-3, @@ -517,15 +517,15 @@ struct redisCommand redisCommandTable[SWAP_CMD_COUNT] = { 0,NULL,NULL,SWAP_IN,SWAP_IN_DEL,1,2,1,0,0,0}, {"expire",expireCommand,3, - "write fast @keyspace @swap_keyspace", + "write fast gtid-non-determinism @keyspace @swap_keyspace", 0,NULL,NULL,SWAP_IN,SWAP_IN_META,1,1,1,0,0,0}, {"expireat",expireatCommand,3, - "write fast @keyspace @swap_keyspace", + "write fast gtid-non-determinism @keyspace @swap_keyspace", 0,NULL,NULL,SWAP_IN,SWAP_IN_META,1,1,1,0,0,0}, {"pexpire",pexpireCommand,3, - "write fast @keyspace @swap_keyspace", + "write fast gtid-non-determinism @keyspace @swap_keyspace", 0,NULL,NULL,SWAP_IN,SWAP_IN_META,1,1,1,0,0,0}, {"pexpireat",pexpireatCommand,3, @@ -802,7 +802,7 @@ struct redisCommand redisCommandTable[SWAP_CMD_COUNT] = { 0,NULL,NULL,SWAP_NOP,0,0,0,0,0,0,0}, {"geoadd",geoaddCommand,-5, - "write use-memory @geo @swap_zset", + "write use-memory gtid-non-determinism @geo @swap_zset", 0,NULL,getKeyRequestsGeoAdd,SWAP_IN,SWAP_IN_DEL,1,1,1,0,0,0}, /* GEORADIUS has store options that may write. */ diff --git a/src/module.c b/src/module.c index 0187db35d11..aa56e7bc442 100644 --- a/src/module.c +++ b/src/module.c @@ -810,6 +810,7 @@ int64_t commandFlagsFromString(char *s) { else if (!strcasecmp(t,"may-replicate")) flags |= CMD_MAY_REPLICATE; else if (!strcasecmp(t,"getkeys-api")) flags |= CMD_MODULE_GETKEYS; else if (!strcasecmp(t,"no-cluster")) flags |= CMD_MODULE_NO_CLUSTER; + else if (!strcasecmp(t,"gtid-non-determinism")) flags |= CMD_GTID_NON_DETERMINISM; else break; } sdsfreesplitres(tokens,count); diff --git a/src/server.c b/src/server.c index 58669642dd1..66c22e98c2c 100644 --- a/src/server.c +++ b/src/server.c @@ -202,11 +202,11 @@ struct redisCommand redisCommandTable[] = { 0,NULL,1,1,1,0,0,0}, {"getex",getexCommand,-2, - "write fast @string", + "write fast gtid-non-determinism @string", 0,NULL,1,1,1,0,0,0}, {"getdel",getdelCommand,2, - "write fast @string", + "write fast gtid-non-determinism @string", 0,NULL,1,1,1,0,0,0}, /* Note that we can't flag set as fast, since it may perform an @@ -220,15 +220,15 @@ struct redisCommand redisCommandTable[] = { 0,NULL,1,1,1,0,0,0}, {"setex",setexCommand,4, - "write use-memory @string", + "write use-memory gtid-non-determinism @string", 0,NULL,1,1,1,0,0,0}, {"psetex",psetexCommand,4, - "write use-memory @string", + "write use-memory gtid-non-determinism @string", 0,NULL,1,1,1,0,0,0}, {"append",appendCommand,3, - "write use-memory fast @string", + "write use-memory gtid-non-determinism fast @string", 0,NULL,1,1,1,0,0,0}, {"strlen",strlenCommand,2, @@ -264,7 +264,7 @@ struct redisCommand redisCommandTable[] = { 0,NULL,1,1,1,0,0,0}, {"setrange",setrangeCommand,4, - "write use-memory @string", + "write use-memory gtid-non-determinism @string", 0,NULL,1,1,1,0,0,0}, {"getrange",getrangeCommand,4, @@ -276,11 +276,11 @@ struct redisCommand redisCommandTable[] = { 0,NULL,1,1,1,0,0,0}, {"incr",incrCommand,2, - "write use-memory fast @string", + "write use-memory fast gtid-non-determinism @string", 0,NULL,1,1,1,0,0,0}, {"decr",decrCommand,2, - "write use-memory fast @string", + "write use-memory fast gtid-non-determinism @string", 0,NULL,1,1,1,0,0,0}, {"mget",mgetCommand,-2, @@ -316,19 +316,19 @@ struct redisCommand redisCommandTable[] = { 0,NULL,1,1,1,0,0,0}, {"brpop",brpopCommand,-3, - "write no-script @list @blocking", + "write no-script gtid-non-determinism @list @blocking", 0,NULL,1,-2,1,0,0,0}, {"brpoplpush",brpoplpushCommand,4, - "write use-memory no-script @list @blocking", + "write use-memory no-script gtid-non-determinism @list @blocking", 0,NULL,1,2,1,0,0,0}, {"blmove",blmoveCommand,6, - "write use-memory no-script @list @blocking", + "write use-memory no-script gtid-non-determinism @list @blocking", 0,NULL,1,2,1,0,0,0}, {"blpop",blpopCommand,-3, - "write no-script @list @blocking", + "write no-script gtid-non-determinism @list @blocking", 0,NULL,1,-2,1,0,0,0}, {"llen",llenCommand,2, @@ -392,7 +392,7 @@ struct redisCommand redisCommandTable[] = { 0,NULL,1,1,1,0,0,0}, {"spop",spopCommand,-2, - "write random fast @set", + "write random fast gtid-non-determinism @set", 0,NULL,1,1,1,0,0,0}, {"srandmember",srandmemberCommand,-2, @@ -548,11 +548,11 @@ struct redisCommand redisCommandTable[] = { 0,NULL,1,1,1,0,0,0}, {"bzpopmin",bzpopminCommand,-3, - "write no-script fast @sortedset @blocking", + "write no-script fast gtid-non-determinism @sortedset @blocking", 0,NULL,1,-2,1,0,0,0}, {"bzpopmax",bzpopmaxCommand,-3, - "write no-script fast @sortedset @blocking", + "write no-script fast gtid-non-determinism @sortedset @blocking", 0,NULL,1,-2,1,0,0,0}, {"zrandmember",zrandmemberCommand,-2, @@ -580,11 +580,11 @@ struct redisCommand redisCommandTable[] = { 0,NULL,1,1,1,0,0,0}, {"hincrby",hincrbyCommand,4, - "write use-memory fast @hash", + "write use-memory fast gtid-non-determinism @hash", 0,NULL,1,1,1,0,0,0}, {"hincrbyfloat",hincrbyfloatCommand,4, - "write use-memory fast @hash", + "write use-memory fast gtid-non-determinism @hash", 0,NULL,1,1,1,0,0,0}, {"hdel",hdelCommand,-3, @@ -632,11 +632,11 @@ struct redisCommand redisCommandTable[] = { 0,NULL,1,1,1,0,0,0}, {"incrbyfloat",incrbyfloatCommand,3, - "write use-memory fast @string", + "write use-memory fast gtid-non-determinism @string", 0,NULL,1,1,1,0,0,0}, {"getset",getsetCommand,3, - "write use-memory fast @string", + "write use-memory fast gtid-non-determinism @string", 0,NULL,1,1,1,0,0,0}, {"mset",msetCommand,-3, @@ -678,15 +678,15 @@ struct redisCommand redisCommandTable[] = { 0,NULL,1,2,1,0,0,0}, {"expire",expireCommand,3, - "write fast @keyspace", + "write fast gtid-non-determinism @keyspace", 0,NULL,1,1,1,0,0,0}, {"expireat",expireatCommand,3, - "write fast @keyspace", + "write fast gtid-non-determinism @keyspace", 0,NULL,1,1,1,0,0,0}, {"pexpire",pexpireCommand,3, - "write fast @keyspace", + "write fast gtid-non-determinism @keyspace", 0,NULL,1,1,1,0,0,0}, {"pexpireat",pexpireatCommand,3, @@ -951,7 +951,7 @@ struct redisCommand redisCommandTable[] = { 0,NULL,0,0,0,0,0,0}, {"geoadd",geoaddCommand,-5, - "write use-memory @geo", + "write use-memory gtid-non-determinism @geo", 0,NULL,1,1,1,0,0,0}, /* GEORADIUS has store options that may write. */ @@ -3782,6 +3782,8 @@ int populateCommandTableParseFlags(struct redisCommand *c, char *strflags) { c->flags |= CMD_NO_AUTH; } else if (!strcasecmp(flag,"may-replicate")) { c->flags |= CMD_MAY_REPLICATE; + } else if (!strcasecmp(flag, "gtid-non-determinism")) { + c->flags |= CMD_GTID_NON_DETERMINISM; } else { /* Parse ACL categories here if the flag name starts with @. */ uint64_t catflag; @@ -4933,6 +4935,7 @@ void addReplyCommand(client *c, struct redisCommand *cmd) { flagcount += addReplyCommandFlag(c,cmd,CMD_FAST, "fast"); flagcount += addReplyCommandFlag(c,cmd,CMD_NO_AUTH, "no_auth"); flagcount += addReplyCommandFlag(c,cmd,CMD_MAY_REPLICATE, "may_replicate"); + flagcount += addReplyCommandFlag(c,cmd,CMD_GTID_NON_DETERMINISM, "rewrite_command"); if (cmdHasMovableKeys(cmd)) { addReplyStatus(c, "movablekeys"); flagcount += 1; diff --git a/src/server.h b/src/server.h index a400abdd79a..374f6b66f87 100644 --- a/src/server.h +++ b/src/server.h @@ -234,6 +234,7 @@ extern int configOOMScoreAdjValuesDefaults[CONFIG_OOM_COUNT]; #define CMD_CATEGORY_CONNECTION (1ULL<<37) #define CMD_CATEGORY_TRANSACTION (1ULL<<38) #define CMD_CATEGORY_SCRIPTING (1ULL<<39) +#define CMD_GTID_NON_DETERMINISM (1ULL<<40) /* AOF states */ #define AOF_OFF 0 /* AOF is off */