diff --git a/ChangeLog b/ChangeLog index a9fd660..93b7b50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2019-06-21 Alibaba Cloud. + * VERSION: 1.6.9 + * IMPROVE: support Lua and transaction when target is open source cluster + version. + * IMPROVE: support filter Lua: `filter.lua` 2019-06-21 Alibaba Cloud. * VERSION: 1.6.8 * IMPROVE: add hypervisor. diff --git a/conf/redis-shake.conf b/conf/redis-shake.conf index d8c6f71..8acf1a7 100644 --- a/conf/redis-shake.conf +++ b/conf/redis-shake.conf @@ -119,6 +119,10 @@ filter.key = # used in `sync`. # 指定过滤slot,只让指定的slot通过 filter.slot = +# filter lua script. true means not pass. However, in redis 5.0, the lua +# converts to transaction(multi+{commands}+exec) which will be passed. +# 控制不让lua脚本通过,true表示不通过 +filter.lua = false # big key threshold, the default is 500 * 1024 * 1024 bytes. If the value is bigger than # this given value, all the field will be spilt and write into the target in order. diff --git a/src/redis-shake/common/filter.go b/src/redis-shake/common/filter.go new file mode 100644 index 0000000..a4a1adc --- /dev/null +++ b/src/redis-shake/common/filter.go @@ -0,0 +1,16 @@ +package utils + +import "strings" + +// return true means not pass +func FilterCommands(cmd string, luaFilter bool) bool { + if strings.EqualFold(cmd, "opinfo") { + return true + } + + if luaFilter && (strings.EqualFold(cmd, "eval") || strings.EqualFold(cmd, "script")) { + return true + } + + return false +} \ No newline at end of file diff --git a/src/redis-shake/common/utils.go b/src/redis-shake/common/utils.go index 8314cd5..5623ac9 100644 --- a/src/redis-shake/common/utils.go +++ b/src/redis-shake/common/utils.go @@ -733,9 +733,11 @@ func RestoreRdbEntry(c redigo.Conn, e *rdb.BinEntry) { // load lua script if e.Type == rdb.RdbFlagAUX && string(e.Key) == "lua" { - _, err := c.Do("script", "load", e.Value) - if err != nil { - log.Panicf(err.Error()) + if conf.Options.FilterLua == false { + _, err := c.Do("script", "load", e.Value) + if err != nil { + log.Panicf(err.Error()) + } } return } diff --git a/src/redis-shake/configure/configure.go b/src/redis-shake/configure/configure.go index 6676231..3ffc31d 100644 --- a/src/redis-shake/configure/configure.go +++ b/src/redis-shake/configure/configure.go @@ -36,6 +36,7 @@ type Configuration struct { FilterDB string `config:"filter.db"` FilterKey []string `config:"filter.key"` FilterSlot []string `config:"filter.slot"` + FilterLua bool `config:"filter.lua"` BigKeyThreshold uint64 `config:"big_key_threshold"` Psync bool `config:"psync"` Metric bool `config:"metric"` diff --git a/src/redis-shake/sync.go b/src/redis-shake/sync.go index f53a83c..1da67a1 100644 --- a/src/redis-shake/sync.go +++ b/src/redis-shake/sync.go @@ -613,7 +613,7 @@ func (ds *dbSyncer) syncCommand(reader *bufio.Reader, target []string, auth_type } bypass = !base.AcceptDB(uint32(n)) isselect = true - } else if strings.EqualFold(scmd, "opinfo") { + } else if utils.FilterCommands(scmd, conf.Options.FilterLua) { ignorecmd = true } if bypass || ignorecmd { diff --git a/src/vendor/vendor.json b/src/vendor/vendor.json index 82240fa..6303482 100644 --- a/src/vendor/vendor.json +++ b/src/vendor/vendor.json @@ -159,10 +159,10 @@ "revisionTime": "2019-03-04T09:57:49Z" }, { - "checksumSHA1": "uma2AeftGc7LC/UB0QY2JSnxl3w=", + "checksumSHA1": "ZT2d9cNq14zxFxnzA2kaqj8tfJY=", "path": "github.com/vinllen/redis-go-cluster", - "revision": "b6031aad42dc289f4696f835b2fe6dc0da49c8ee", - "revisionTime": "2019-05-25T06:57:32Z" + "revision": "bdcf6ff491eca6a29ba905300253a65d88eb1ad6", + "revisionTime": "2019-06-24T08:07:27Z" }, { "checksumSHA1": "TM3Neoy1xRAKyZYMGzKc41sDFW4=", @@ -170,5 +170,6 @@ "revision": "a96e63847dc3c67d17befa69c303767e2f84e54f", "revisionTime": "2017-05-31T16:03:50Z" } - ] + ], + "rootPath": "/Users/vinllen-ali/code/redis-shake-inner/redis-shake/src" }