Issue with 3rd-party memc and eval modules

Markus Jelsma markus at buyways.nl
Tue Feb 16 13:53:32 MSK 2010


Hi,


There is an issue with the 3rd-party memc module for Nginx [1] where it 
doesn't close the connection when it resides in an eval [2] block.


Consider the following with memc in eval:

       eval $memc_return
       {
         set $memc_cmd 'set';
         set $memc_key 'key';
         set $memc_value 'value';

         memc_pass memcache_cluster;
       }

      echo 'hello!';
      echo_flush;

When this location is called via curl, you'll get to see the following:
* About to connect() to localhost port 81 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 81 (#0)
> GET 
/session/synchronize/da39a3ee5e6b4b0d3255bfef95601890afd80709/da39a3ee5e6b4b0d3255bfef95601890afd80709/abc 
HTTP/1.1
> User-Agent: curl/7.19.5 (i486-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g 
zlib/1.2.3.3 libidn/1.15
> Host: localhost:81
> Accept: */*
>
^C
markus at zealand:/opt/nginx#

You can see i have to close the connection manually. I have also got a verbose 
memcache server log which exactly closes the connection at the point i press 
CTRL+C.




Now consider the following with memcached in eval, i have changed the above 
configuration to use memcached instead of memc:

* About to connect() to localhost port 81 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 81 (#0)
> GET 
/session/synchronize/da39a3ee5e6b4b0d3255bfef95601890afd80709/da39a3ee5e6b4b0d3255bfef95601890afd80709/abc 
HTTP/1.1
> User-Agent: curl/7.19.5 (i486-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g 
zlib/1.2.3.3 libidn/1.15
> Host: localhost:81
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx
< Date: Tue, 16 Feb 2010 10:46:22 GMT
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Connection: close
<
hello!
* Closing connection #0


You can clearly see what's going on: this is what it should look like. Now, 
also consider using the memc module with the eval lines commented out. I also 
had to comment out the echo lines because otherwise it won't pass to memcache:


* About to connect() to localhost port 81 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 81 (#0)
> GET 
/session/synchronize/da39a3ee5e6b4b0d3255bfef95601890afd80709/da39a3ee5e6b4b0d3255bfef95601890afd80709/abc 
HTTP/1.1
> User-Agent: curl/7.19.5 (i486-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g 
zlib/1.2.3.3 libidn/1.15
> Host: localhost:81
> Accept: */*
>
< HTTP/1.1 201 Created
< Server: nginx
< Date: Tue, 16 Feb 2010 10:50:31 GMT
< Content-Type: text/plain
< Content-Length: 8
< Connection: close
<
STORED
* Closing connection #0



There is also a difference in HTTP response code and body if only using set, 
here is what i found:

memc returns code=HTTP 201 body=STORED
memcached returns code=HTTP 200 body=   <-- this is empty


Can the contributers of the modules please tell us something about this 
behaviour? I'm using the latest stable 0.7 nginx and modules.


Many many thanks in advance


[1]: http://wiki.nginx.org/NginxHttpMemcModule
[2]: http://www.grid.net.ru/nginx/eval.en.html

Cheers,


Markus Jelsma - Technisch Architect - Buyways BV
http://www.linkedin.com/in/markus17
050-8536620 / 06-50258350




More information about the nginx mailing list