我在 access中设置 ngx.ctx.str = post字符串, 同时cjson decode 该字符串 放入 ngx.ctx.data 中,在content中使用 ngx.ctx.data.id 保存把 ngx.ctx.str 保存到数据库。发现大部分情况没问题,但偶尔会出现错乱,ngx.ctx.data.id 和 ngx.ctx.str文本中的id不一样。很奇怪。谢谢各位,请假 --
hello应该是你自己的代码逻辑问题在 2016年5月12日 下午6:08,renyuxiao <reny...@163.com>写道:我在 access中设置 ngx.ctx.str = post字符串, 同时cjson decode 该字符串 放入 ngx.ctx.data 中,在content中使用 ngx.ctx.data.id 保存把 ngx.ctx.str 保存到数据库。发现大部分情况没问题,但偶尔会出现错乱,ngx.ctx.data.id 和 ngx.ctx.str文本中的id不一样。很奇怪。谢谢各位,请假 -- --
谢谢回复。逻辑问题很难解释几千条里偶尔有1条错乱的几率,另外逻辑很简单就是写log。还有我看了下错乱的id有相差半个小时以上。请问 access(access_by_lua_file) 中设置 ngx.ctx. 在content (content_by_lua_file) 用这个ngx.ctx 是否有使用规范?比如要清掉之类的。会不会因为nginx某些队列或内存满了存在错乱。在 2016-05-15 23:47:36,"DeJiang Zhu" <douj...@gmail.com> 写道: hello应该是你自己的代码逻辑问题在 2016年5月12日 下午6:08,renyuxiao <reny...@163.com>写道:我在 access中设置 ngx.ctx.str = post字符串, 同时cjson decode 该字符串 放入 ngx.ctx.data 中,在content中使用 ngx.ctx.data.id 保存把 ngx.ctx.str 保存到数据库。发现大部分情况没问题,但偶尔会出现错乱,ngx.ctx.data.id 和 ngx.ctx.str文本中的id不一样。很奇怪。谢谢各位,请假 -- -- --
Hello! 2016-05-12 3:08 GMT-07:00 renyuxiao: > 我在 access中设置 ngx.ctx.str = post字符串, 同时cjson decode 该字符串 放入 ngx.ctx.data > 中,在content中使用 ngx.ctx.data.id 保存把 ngx.ctx.str 保存到数据库。 > 发现大部分情况没问题,但偶尔会出现错乱,ngx.ctx.data.id 和 ngx.ctx.str文本中的id不一样。 > > 很奇怪。谢谢各位,请假 > 建议总是使用 lua-releng 工具检查一下你的所有 Lua 代码,以避免误用 Lua 全局变量还导致数据意外跨请求共享的错误: https://github.com/openresty/lua-nginx-module#lua-variable-scope ngx.ctx 表本身总是和当前请求绑定的。 Regards, -agentzh
我在 access中设置 ngx.ctx.str = post字符串, 同时cjson decode 该字符串 放入 ngx.ctx.data 中,在content中使用 ngx.ctx.data.id 保存把 ngx.ctx.str 保存到数据库。发现大部分情况没问题,但偶尔会出现错乱,ngx.ctx.data.id 和 ngx.ctx.str文本中的id不一样。很奇怪。谢谢各位,请假