CNSRE / ABTestingGateway

MIT License
2.36k stars 768 forks source link

policy_del 删除某个策略时候有bug 会导致其他策略被删! #97

Closed Toifyx closed 6 years ago

Toifyx commented 6 years ago

abtesting/adapter/policy.lua 文件

_M.del 方法

local policyLib = baseLibrary .. ':' .. id local keys, err = database:keys(policyLib..'*')

当id=1 时,keys匹配到得是 ab:policies:1* ,实际上会删除 10、11、12、13.....等开头得方法

实际想删除的方法只有两个: "ab:policies:1:divdata" "ab:policies:1:divtype"

` _M.del = function(self, id) local database = self.database local baseLibrary = self.baseLibrary local policyLib = baseLibrary .. ':' .. id local divdata = policyLib .. ':divdata' local divtype = policyLib .. ':divtype'

--local keys, err = database:keys(policyLib..'*')
--if not keys then
--    error{ERRORINFO.REDIS_ERROR, err}
--end

database:init_pipeline()
--for _i, key in pairs(keys) do
--    database:del(key)
--end
database:del(divdata)
database:del(divtype)

local ok, err = database:commit_pipeline()
if not ok then error{ERRORINFO.REDIS_ERROR, err} end

end`

BG2BKK commented 6 years ago

确认,多谢指出。 线上使用中,策略管理不是通过这里来的,有相应的配管中心增删策略。 已改正,非常感谢!

BG2BKK commented 6 years ago

https://github.com/CNSRE/ABTestingGateway/commit/834e8afe99fcf20b20e48829527cf7f0130fb879