# Transport-memcached gives ClosedChannelException if query takes too long

**URL:** <https://discuss.elastic.co/t/transport-memcached-gives-closedchannelexception-if-query-takes-too-long/11357>\
**Category:** Elasticsearch\
**Created:** [March 28, 2013, 2:07pm UTC](https://discuss.elastic.co/t/transport-memcached-gives-closedchannelexception-if-query-takes-too-long/11357 "2013-03-28T14:07:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serge\_Meunier](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Serge\_Meunier](https://discuss.elastic.co/u/Serge_Meunier)\
**Post date:** [March 28, 2013, 2:07pm UTC](https://discuss.elastic.co/t/transport-memcached-gives-closedchannelexception-if-query-takes-too-long/11357/1 "2013-03-28T14:07:53Z")

</div>

Hi,

I am using Elasticsearch 0.20.5 with the transport-memcached plugin.

When I try running a long-running search request (in my estimate anything  
over 5 seconds or so) using a memcached request, the request fails with the  
message [ERROR][memcached.netty] caught exception on memcached  
decoder.

On further investigation, I found that the problem was being caused by a  
ClosedChannelException being triggered on a channel.write() command when  
trying to process the sendResponse in  
org.elasticsearch.memcached.netty.MemcachedRestChannel.sendResponse. It  
appears that at this point, the channel has been closed by some other  
process.

The exact same request works correctly, if it completes quickly enough.  
For example, I am able to get a successful call giving me the results I  
want if I make the request a second time, with elasticsearch then getting  
the results out of the cache, and thus making the request much quicker.

Has anyone else seen this problem, and does anyone know what I can do to  
fix it?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [March 28, 2013, 8:42pm UTC](https://discuss.elastic.co/t/transport-memcached-gives-closedchannelexception-if-query-takes-too-long/11357/2 "2013-03-28T20:42:01Z")

</div>

Is your issue perhaps this one?

> <https://github.com/elastic/elasticsearch/issues/2733>
>
> For some reason, it seems like netty will not always fire up a proper close even…t on a channel, thus causing us to propagate it up the stack to treat a node as disconnected. It does throw a failure up the networking handlers in that case, which we catch. We should try and disconnect on those events as well...

--  
Ivan

On Thu, Mar 28, 2013 at 7:07 AM, Serge Meunier [sjmeunier@gmail.com](mailto:sjmeunier@gmail.com) wrote:

> Hi,
> 
> I am using Elasticsearch 0.20.5 with the transport-memcached plugin.
> 
> When I try running a long-running search request (in my estimate anything  
> over 5 seconds or so) using a memcached request, the request fails with the  
> message [ERROR][memcached.netty] caught exception on memcached  
> decoder.
> 
> On further investigation, I found that the problem was being caused by a  
> ClosedChannelException being triggered on a channel.write() command when  
> trying to process the sendResponse in  
> org.elasticsearch.memcached.netty.MemcachedRestChannel.sendResponse. It  
> appears that at this point, the channel has been closed by some other  
> process.
> 
> The exact same request works correctly, if it completes quickly enough.  
> For example, I am able to get a successful call giving me the results I  
> want if I make the request a second time, with elasticsearch then getting  
> the results out of the cache, and thus making the request much quicker.
> 
> Has anyone else seen this problem, and does anyone know what I can do to  
> fix it?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Serge\_Meunier](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Serge\_Meunier](https://discuss.elastic.co/u/Serge_Meunier)\
**Post date:** [April 2, 2013, 6:23am UTC](https://discuss.elastic.co/t/transport-memcached-gives-closedchannelexception-if-query-takes-too-long/11357/3 "2013-04-02T06:23:23Z")

</div>

Hi Ivan,

I had seen that issue previously, but while it seems to be a similar issue,  
I am not sure it is same issue. The issue in the link shows that it has  
been resolved in versions 0.20.6 and 0.90.0.RC1. I have since tried running  
both of these versions of Elasticsearch, and I get the exact same result,  
so I think there is something else causing this.

On Thursday, March 28, 2013 9:42:01 PM UTC+1, Ivan Brusic wrote:

> Is your issue perhaps this one?  
> [Network: A closed channel might not always fire up a close event · Issue #2733 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2733)
> 
> --  
> Ivan
> 
> On Thu, Mar 28, 2013 at 7:07 AM, Serge Meunier \<[sjme...@gmail.com](mailto:sjme...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi,
> > 
> > I am using Elasticsearch 0.20.5 with the transport-memcached plugin.
> > 
> > When I try running a long-running search request (in my estimate anything  
> > over 5 seconds or so) using a memcached request, the request fails with the  
> > message [ERROR][memcached.netty] caught exception on memcached  
> > decoder.
> > 
> > On further investigation, I found that the problem was being caused by a  
> > ClosedChannelException being triggered on a channel.write() command when  
> > trying to process the sendResponse in  
> > org.elasticsearch.memcached.netty.MemcachedRestChannel.sendResponse. It  
> > appears that at this point, the channel has been closed by some other  
> > process.
> > 
> > The exact same request works correctly, if it completes quickly enough.  
> > For example, I am able to get a successful call giving me the results I  
> > want if I make the request a second time, with elasticsearch then getting  
> > the results out of the cache, and thus making the request much quicker.
> > 
> > Has anyone else seen this problem, and does anyone know what I can do to  
> > fix it?
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:43am UTC](https://discuss.elastic.co/t/transport-memcached-gives-closedchannelexception-if-query-takes-too-long/11357/4 "2017-07-06T02:43:17Z")

</div>


