Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ngx_openresty 的 ngx.location.capture 指令直接调用 nginx-tfs 模块会 blocked 无法返回 #14

Open
harveyzh opened this issue Feb 28, 2013 · 3 comments

Comments

@harveyzh
Copy link

类似的问题:

http://code.taobao.org/p/tfs/issue/1312/

相关信息:

系统信息

$ uname -a
Linux tfs004 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

ngx_openresty 版本

$ ./nginx -V
nginx version: ngx_openresty/1.2.7.1
built by gcc 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/home/server/openresty-debug/nginx --with-debug --with-cc-opt=-O0 --add-module=../ngx_devel_kit-0.2.18 --add-module=../iconv-nginx-module-0.10rc7 --add-module=../echo-nginx-module-0.42 --add-module=../xss-nginx-module-0.03rc9 --add-module=../ngx_coolkit-0.2rc1 --add-module=../set-misc-nginx-module-0.22rc8 --add-module=../form-input-nginx-module-0.07 --add-module=../encrypted-session-nginx-module-0.02 --add-module=../ngx_postgres-1.0rc2 --add-module=../srcache-nginx-module-0.19 --add-module=../ngx_lua-0.7.16 --add-module=../headers-more-nginx-module-0.19 --add-module=../array-var-nginx-module-0.03rc1 --add-module=../memc-nginx-module-0.13rc3 --add-module=../redis2-nginx-module-0.09 --add-module=../redis-nginx-module-0.3.6 --add-module=../auth-request-nginx-module-0.2 --add-module=../rds-json-nginx-module-0.12rc10 --add-module=../rds-csv-nginx-module-0.05rc2 --with-ld-opt=-Wl,-rpath,/home/server/openresty-debug/luajit/lib --with-http_ssl_module --with-http_stub_status_module --add-module=/home/makerpm/git/nginx-auth-ldap --add-module=/home/makerpm/git/nginx_upstream_hash --add-module=/home/makerpm/git/ngx_http_substitutions_filter_module --add-module=/home/makerpm/git/nginx-tfs

nginx-tfs 模块最新的 commit

$ git log -1
commit d1c8349
Merge: dcb7507 83d9a33
Author: Zheng Cen [email protected]
Date: Thu Jan 17 03:03:57 2013 -0800

Merge pull request #12 from monadbobo/fix_upstream

Fix upstream

重现问题的步骤

(1) 使用下面的 nginx.conf 启动 nginx

nginx.conf: https://gist.github.com/harveyzh/5055847#file-nginx-conf

(2) ngx.location.capture 指令直接调用 nginx-tfs 模块会一直 block

测试命令:
$ curl -i 127.0.0.1/test_block
^C

相关配置片段:

    location /test_block {
        content_by_lua '
            res = ngx.location.capture("/v1/tfs/T17yCTByJT1RCvBVdK")

            if res.status == ngx.HTTP_OK then
                ngx.print(res.body)
            else
                ngx.exit(res.status)
            end
        ';
    }

debug log: https://gist.github.com/harveyzh/5055847#file-error-log-block

block时的 debug log 停在

2013/02/28 18:41:06 [debug] 29836#0: *6 http copy filter: 0 "/v1/tfs/T17yCTByJT1RCvBVdK?"
2013/02/28 18:41:06 [debug] 29836#0: *6 http finalize request: 0, "/v1/tfs/T17yCTByJT1RCvBVdK?" a:0, c:2
2013/02/28 18:41:06 [debug] 29836#0: *6 lua run post subrequest handler, rc:0 c:2
2013/02/28 18:41:06 [debug] 29836#0: *6 lua restoring write event handler
2013/02/28 18:41:06 [debug] 29836#0: *6 http wake parent request: "/test_block?"
2013/02/28 18:41:06 [debug] 29836#0: keepalive dummy handler
2013/02/28 18:41:06 [debug] 29836#0: timer delta: 1
2013/02/28 18:41:06 [debug] 29836#0: posted events 0000000000000000
2013/02/28 18:41:06 [debug] 29836#0: worker cycle
2013/02/28 18:41:06 [debug] 29836#0: epoll timer: -1

(3) ngx.location.capture 指令间接通过 proxy_pass 调用 nginx-tfs 模块则 ok

测试命令:
$ curl -i 127.0.0.1/test_ok
HTTP/1.1 200 OK
Server: ngx_openresty
Date: Thu, 28 Feb 2013 10:59:44 GMT
Content-Type: application/octet-stream
Transfer-Encoding: chunked
Connection: keep-alive

test!

相关配置片段:

    location /tfs/ {
        proxy_pass http://127.0.0.1/v1/tfs/;
    }

    location /test_ok {
        content_by_lua '
            res = ngx.location.capture("/tfs/T17yCTByJT1RCvBVdK")

            if res.status == ngx.HTTP_OK then
                ngx.print(res.body)
            else
                ngx.exit(res.status)
            end
        ';
    }

debug log: https://gist.github.com/harveyzh/5055847#file-error-log-ok

@monadbobo
Copy link
Member

你好,现在的ngx tfs模块还不支持 sub request直接访问。

谢谢.

@lidaohang
Copy link

你好,能在lua里面取到文件然后通过lua 时时缩放图像吗?例如:GraphicsMagick,OpenCV

@toontong
Copy link

lua能调http请求就可以阿!

----------------------------- 华 丽 的 分 隔 线 -----------------------------
+------------------------------------------------------------------+
| ^^ 继续努力.....赶上.....然后超越....... ^^ |
+------------------------------------------------------------------+
----------------------------- 华 丽 的 分 隔 线 -----------------------------

2013/4/28 daohang [email protected]

你好,能在lua里面取到文件然后通过lua 时时缩放图像吗?例如:GraphicsMagick,OpenCV


Reply to this email directly or view it on GitHubhttps://github.com//issues/14#issuecomment-17129387
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants