diff --git a/.gitignore b/.gitignore index 16b099d..543e80e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,13 @@ logs *.yml *.pid *.tar.gz +*.log tags result.db.* +bin/* +!/bin/redis-shake.* +conf/* +!conf/redis-shake.conf dump.data runtime.trace diff --git a/ChangeLog b/ChangeLog index 27036d2..8073bc9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ +2019-03-27 Alibaba Cloud. + * version: 1.2.1 + * IMPROVE: support syncing lua script in RDB syncing. 2019-03-11 Alibaba Cloud. * version: 1.2.0 - * redis-shake: support 5.0. + * IMPROVE: support 5.0. 2019-02-21 Alibaba Cloud. * version: 1.0.0 * redis-shake: initial release. diff --git a/bin/redis-shake.darwin64 b/bin/redis-shake.darwin64 index ba66a03..bc0b97e 100755 Binary files a/bin/redis-shake.darwin64 and b/bin/redis-shake.darwin64 differ diff --git a/src/pkg/rdb/loader.go b/src/pkg/rdb/loader.go index 03997d9..5f84ac9 100644 --- a/src/pkg/rdb/loader.go +++ b/src/pkg/rdb/loader.go @@ -121,10 +121,18 @@ func (l *Loader) NextBinEntry() (*BinEntry, error) { t = rtype } switch t { - case rdbFlagAUX: + case RdbFlagAUX: aux_key, _ := l.ReadString() aux_value, _ := l.ReadString() log.Info("Aux information key:", string(aux_key), " value:", string(aux_value)) + if string(aux_key) == "lua" { + // we should handle the lua script + entry.DB = l.db + entry.Key = aux_key + entry.Type = t + entry.Value = aux_value + return entry, nil + } case rdbFlagResizeDB: db_size, _ := l.ReadLength() expire_size, _ := l.ReadLength() diff --git a/src/pkg/rdb/reader.go b/src/pkg/rdb/reader.go index f608b00..068eb94 100644 --- a/src/pkg/rdb/reader.go +++ b/src/pkg/rdb/reader.go @@ -36,7 +36,7 @@ const ( RDBTypeStreamListPacks = 15 // stream rdbFlagOnlyValue = 0xf9 - rdbFlagAUX = 0xfa + RdbFlagAUX = 0xfa rdbFlagResizeDB = 0xfb rdbFlagExpiryMS = 0xfc rdbFlagExpiry = 0xfd @@ -98,7 +98,7 @@ func (r *rdbReader) readObjectValue(t byte, l *Loader) ([]byte, error) { switch t { default: return nil, errors.Errorf("unknown object-type %02x", t) - case rdbFlagAUX: + case RdbFlagAUX: fallthrough case rdbFlagResizeDB: fallthrough diff --git a/src/redis-shake/common/utils.go b/src/redis-shake/common/utils.go index 483a6ef..f8ef081 100644 --- a/src/redis-shake/common/utils.go +++ b/src/redis-shake/common/utils.go @@ -679,6 +679,15 @@ func RestoreRdbEntry(c redigo.Conn, e *rdb.BinEntry) { return } + // 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()) + } + return + } + // TODO, need to judge big key if e.Type != rdb.RDBTypeStreamListPacks && (uint64(len(e.Value)) > conf.Options.BigKeyThreshold || e.RealMemberCount != 0) {