You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
113行 local info = usertable[idx] 下面添加: local shat_key = {idx,"-",info}
注释: local ups = cache:get(info) 替换添加: local ups = cache:get(table.concat(shat_key))
bug:多级分流造成的 shdict key 名冲突
url如: http://api.xxx.com/prod/test/xxx-service/passService/payCallback
uri /prod/test/xxx-service/passService/payCallback
一级策略为: 第二段URL的值对应返回 后端upstream
转发规则: test == 》 up:test dev ==> up:dev
二级策略为: 第一段URL的值对应返回 后端upstream
转发规则: prod == 》 up: pord release ==>release
问题:
当 uri 为: /prod/prod/paytem-service/swiftpassService/payCallback
转发up为: prod 正常
在shat key 过期前访问
uri 为: /release/prod/paytem-service/swiftpassService/payCallback
转发up为: prod 不正常 正确应是 release
原因:
文件: diversion\diversion.lua +356
setUpstream 的时候 key用的是 策略匹配后得出来的值,这里得出来的是: 第一次key是 prod ,第二次key是 release(当前没有set的直接读到缓存))。对应的第一级分流的值为 -1,第二级分流的值为 prod和release(第二次)
文件:diversion\diversion.lua +248
文件:abtesting\utils\cache.lua +118
_M.getUpstream get key 的时候用的是策略匹配出来的值作为key, 第一次是 prod ,第二次应该是 release
因为匹配缓存中的Upstream使用的是for循环进行多级分流匹配,第一级分流(first)get 到了upstream(返回了prod) 第二级分流(second)没有匹配到upstream(release应该是nil)。
但匹配到 first级别的upstream 后就直接返回了,此时的upstream是错误的,正确的应该是 second级别的内容。
解决: 将 分级的 shdict key名进行区分
文件: diversion\diversion.lua
upstreamCache:setUpstream 处,将key名修改成不能使用 ”策略匹配后得出来的值“我这里使用的是:
334行local info下面添加:local shat_key = {idx,"-",info}
注释 upstreamCache:setUpstream(info, -1) 替换添加:upstreamCache:setUpstream(table.concat(shat_key), -1)
注释 upstreamCache:setUpstream(info, upstream) 替换添加:upstreamCache:setUpstream(table.concat(shat_key), upstream)
文件:abtesting\utils\cache.lua +118
113行 local info = usertable[idx] 下面添加: local shat_key = {idx,"-",info}
注释: local ups = cache:get(info) 替换添加: local ups = cache:get(table.concat(shat_key))
不知这样解决是否有问题,目前我还在自行测试 @BG2BKK
The text was updated successfully, but these errors were encountered: