roc230 / spymemcached

Automatically exported from code.google.com/p/spymemcached
0 stars 0 forks source link

Threaded Clients hang and never close #167

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of the product are you using? On what operating system?
Using Spymemcached 2.5 with Membase 1.6.5 on Windows 2003 64-bit

Full Story:
We use Membase for our Jboss Cluster for caching information that changes 
rarely. We have been using Membase with Spymemcached for a few months now and 
it works great.

Recently we wanted to start warming the cache every say 10 minutes. We wrote a 
java program that runs on a command prompt that connects to our databases, 
fills the cache, and is suppose to exit. We have found that one MemcachedClient 
is initialized and a connection is created, unless we call .shutdown() the 
program hangs indefinitely and does not complete. When we add .shutdown() it 
flushes the membase cluster cache. 

I have checked many many forum posts and threads and this seems to be a common 
issue. There has to be a way to disconnect the client and leave the data. 

Original issue reported on code.google.com by benjamin...@gmail.com on 16 Mar 2011 at 5:33

GoogleCodeExporter commented 9 years ago
That's how threads work in java.  The MemcachedClient IO thread is not a daemon 
thread by default.  You can make it one if you like, but you risk data loss if 
you exit without shutting down and what-not.

It sounds like you have a few workarounds.  I don't think it's unreasonable to 
ensure that the client has properly finished its work before exiting the VM 
altogether.

Original comment by dsalli...@gmail.com on 20 Mar 2011 at 7:54

GoogleCodeExporter commented 9 years ago
After fiddling with it a lot more you are right, although i had to add a 
shutdown delay because I was getting shutdown while trying to write error.

I will say that the 2.5.x client we put into production and what was working 
fine for months...all of a sudden we were getting tcp/ip port leaks. Everytime 
the cache was created, even though the client we created was a singleton with a 
single connection...it always created a new connection. We upgraded to 2.6 and 
it works great with no connection leaks. 

Original comment by benjamin...@gmail.com on 20 Mar 2011 at 11:55