<!-- 
RSS generated by JIRA (5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9) at Sat May 18 07:04:47 CDT 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.couchbase.com/issues/si/jira.issueviews:issue-xml/CCBC-62/CCBC-62.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Couchbase</title>
    <link>http://www.couchbase.com/issues</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>5.2.4</version>
        <build-number>845</build-number>
        <build-date>26-12-2012</build-date>
    </build-info>

<item>
            <title>[CCBC-62] hang in libcouchbase_wait() after get timeout</title>
                <link>http://www.couchbase.com/issues/browse/CCBC-62</link>
                <project id="10070" key="CCBC">Couchbase C client library libcouchbase</project>
                        <description>When one node is down and dropping packets, a store op trying to write to that node times out (OK) but libcouchbase_wait doesn&amp;#39;t return (not OK).&lt;br/&gt;
&lt;br/&gt;
[&lt;a href=&apos;mailto:root@localhost&apos;&gt;root@localhost&lt;/a&gt; cb-crank]# gcc -g -Wall -W -I$I/include -L$I/lib t.c -lcouchbase -o t&lt;br/&gt;
[&lt;a href=&apos;mailto:root@localhost&apos;&gt;root@localhost&lt;/a&gt; cb-crank]# export LD_LIBRARY_PATH=$I/lib&lt;br/&gt;
[&lt;a href=&apos;mailto:root@localhost&apos;&gt;root@localhost&lt;/a&gt; cb-crank]# ./t&lt;br/&gt;
Stored: hello (6)&lt;br/&gt;
Got: hellow (7) = world! (7)&lt;br/&gt;
[&lt;a href=&apos;mailto:root@localhost&apos;&gt;root@localhost&lt;/a&gt; cb-crank]# ./t hellow foo&lt;br/&gt;
Stored: hellow (7)&lt;br/&gt;
Got: hellow (7) = foo (4)&lt;br/&gt;
[&lt;a href=&apos;mailto:root@localhost&apos;&gt;root@localhost&lt;/a&gt; cb-crank]# ./t xyz&lt;br/&gt;
Got: hellow (7) = foo (4)&lt;br/&gt;
Failed during store &amp;#39;xyz&amp;#39;: Operation timed out&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
Setup:  Start two nodes of Couchbase Server. In my test, they&amp;#39;re on 10.4.2.13 and 10.4.2.14. Client (see attached code) is being run on host 10.4.2.14.&lt;br/&gt;
&lt;br/&gt;
On one node (10.4.2.13), simulate a network problem with iptables:&lt;br/&gt;
&lt;br/&gt;
iptables -I INPUT 1 -p tcp --sport 1000:60000 -j DROP&lt;br/&gt;
iptables -I INPUT 2 -p tcp --dport 1000:60000 -j DROP&lt;br/&gt;
&lt;br/&gt;
Run the sample app a few times with different keys until you hit one that needs to access the down node. As seen in the output above, the storage callback is called with a timeout error, but the libcouchbase_wait() call never returns. Attach debugger to the client and view thread stacks:&lt;br/&gt;
&lt;br/&gt;
# gdb -p 21746&lt;br/&gt;
GNU gdb (GDB) CentOS (7.0.1-42.el5.centos)&lt;br/&gt;
Copyright (C) 2009 Free Software Foundation, Inc.&lt;br/&gt;
License GPLv3+: GNU GPL version 3 or later &amp;lt;&lt;a href=&quot;http://gnu.org/licenses/gpl.html&quot;&gt;http://gnu.org/licenses/gpl.html&lt;/a&gt;&amp;gt;&lt;br/&gt;
This is free software: you are free to change and redistribute it.&lt;br/&gt;
There is NO WARRANTY, to the extent permitted by law.  Type &amp;quot;show copying&amp;quot;&lt;br/&gt;
and &amp;quot;show warranty&amp;quot; for details.&lt;br/&gt;
This GDB was configured as &amp;quot;x86_64-redhat-linux-gnu&amp;quot;.&lt;br/&gt;
For bug reporting instructions, please see:&lt;br/&gt;
&amp;lt;&lt;a href=&quot;http://www.gnu.org/software/gdb/bugs/&quot;&gt;http://www.gnu.org/software/gdb/bugs/&lt;/a&gt;&amp;gt;.&lt;br/&gt;
Attaching to process 21746&lt;br/&gt;
Reading symbols from /root/code/cb-crank/t...done.&lt;br/&gt;
Reading symbols from /root/code/install/lib/libcouchbase.so.1...done.&lt;br/&gt;
Loaded symbols for /root/code/install/lib/libcouchbase.so.1&lt;br/&gt;
Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.&lt;br/&gt;
Loaded symbols for /lib64/libc.so.6&lt;br/&gt;
Reading symbols from /root/code/install/lib/libvbucket.so.1...done.&lt;br/&gt;
Loaded symbols for /root/code/install/lib/libvbucket.so.1&lt;br/&gt;
Reading symbols from /lib64/libdl.so.2...(no debugging symbols found)...done.&lt;br/&gt;
Loaded symbols for /lib64/libdl.so.2&lt;br/&gt;
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.&lt;br/&gt;
Loaded symbols for /lib64/ld-linux-x86-64.so.2&lt;br/&gt;
Reading symbols from /lib64/libm.so.6...(no debugging symbols found)...done.&lt;br/&gt;
Loaded symbols for /lib64/libm.so.6&lt;br/&gt;
Reading symbols from /root/code/install/lib/libcouchbase_libevent.so.1...done.&lt;br/&gt;
Loaded symbols for /root/code/install/lib/libcouchbase_libevent.so.1&lt;br/&gt;
Reading symbols from /opt/couchbase/lib/libevent-2.0.so.5...(no debugging symbols found)...done.&lt;br/&gt;
Loaded symbols for /opt/couchbase/lib/libevent-2.0.so.5&lt;br/&gt;
Reading symbols from /lib64/librt.so.1...(no debugging symbols found)...done.&lt;br/&gt;
Loaded symbols for /lib64/librt.so.1&lt;br/&gt;
Reading symbols from /lib64/libpthread.so.0...(no debugging symbols found)...done.&lt;br/&gt;
[Thread debugging using libthread_db enabled]&lt;br/&gt;
Loaded symbols for /lib64/libpthread.so.0&lt;br/&gt;
&lt;br/&gt;
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7fff822c0000&lt;br/&gt;
0x0000003407cd3603 in __epoll_wait_nocancel () from /lib64/libc.so.6&lt;br/&gt;
(gdb) where&lt;br/&gt;
#0  0x0000003407cd3603 in __epoll_wait_nocancel () from /lib64/libc.so.6&lt;br/&gt;
#1  0x00002b0211713c28 in ?? () from /opt/couchbase/lib/libevent-2.0.so.5&lt;br/&gt;
#2  0x00002b0211702a4c in event_base_loop () from /opt/couchbase/lib/libevent-2.0.so.5&lt;br/&gt;
#3  0x0000000000400d60 in main (argc=1, argv=0x7fff822027f0) at t.c:113&lt;br/&gt;
(gdb) thread apply all bt&lt;br/&gt;
&lt;br/&gt;
Thread 1 (Thread 0x2b02114eeaf0 (LWP 21746)):&lt;br/&gt;
#0  0x0000003407cd3603 in __epoll_wait_nocancel () from /lib64/libc.so.6&lt;br/&gt;
#1  0x00002b0211713c28 in ?? () from /opt/couchbase/lib/libevent-2.0.so.5&lt;br/&gt;
#2  0x00002b0211702a4c in event_base_loop () from /opt/couchbase/lib/libevent-2.0.so.5&lt;br/&gt;
#3  0x0000000000400d60 in main (argc=1, argv=0x7fff822027f0) at t.c:113&lt;br/&gt;
(gdb) quit&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
Line t.c:113 is libcouchbase_wait().&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
Client compiled as:&lt;br/&gt;
&lt;br/&gt;
gcc -g -Wall -W -I$I/include -L$I/lib t.c -lcouchbase -o t&lt;br/&gt;
&lt;br/&gt;
</description>
                <environment>libcouchbase built from &lt;a href=&quot;git://github.com/couchbase/libcouchbase.git&quot;&gt;git://github.com/couchbase/libcouchbase.git&lt;/a&gt; master branch at commit 9cfda9d40a270fc3dd05018eb16a2089c83bf24a&lt;br/&gt;
&lt;br/&gt;
CentOS 5.6, couchbase server 1.8.0, 2-node cluster </environment>
            <key id="16834">CCBC-62</key>
            <summary>hang in libcouchbase_wait() after get timeout</summary>
                <type id="1" iconUrl="http://www.couchbase.com/issues/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.couchbase.com/issues/images/icons/priorities/major.png">Major</priority>
                    <status id="6" iconUrl="http://www.couchbase.com/issues/images/icons/statuses/closed.png">Closed</status>
                    <resolution id="1">Fixed</resolution>
                    <security id="10011">Public</security>
                        <assignee username="avsej">Sergey Avseyev</assignee>
                                <reporter username="TimSmith">Tim Smith</reporter>
                        <labels>
                    </labels>
                <created>Tue, 1 May 2012 17:31:42 -0500</created>
                <updated>Tue, 13 Nov 2012 04:21:33 -0600</updated>
                    <resolved>Tue, 15 May 2012 17:48:07 -0500</resolved>
                                            <fixVersion>1.0.4</fixVersion>
                                <component>library</component>
                                <votes>0</votes>
                        <watches>1</watches>
                                                    <comments>
                    <comment id="27023" author="TimSmith" created="Thu, 10 May 2012 17:31:09 -0500"  >I forgot to re-enable packets, so I was unable to log in the machine. So I made this little script to hopefully avoid that mistake. Might be handy for you. Just save it, and run:&lt;br/&gt;
&lt;br/&gt;
./drop-packets 90&lt;br/&gt;
./drop-packets 2m&lt;br/&gt;
./drop-packets 1h30m&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
#! /usr/bin/env perl&lt;br/&gt;
&lt;br/&gt;
use strict;&lt;br/&gt;
use warnings;&lt;br/&gt;
&lt;br/&gt;
my $time = shift || &amp;#39;10m&amp;#39;;&lt;br/&gt;
my $seconds = fromNiceTime($time);&lt;br/&gt;
&lt;br/&gt;
$| = 1;  # Auto-flush STDOUT&lt;br/&gt;
&lt;br/&gt;
die &amp;quot;Usage: $0 TIME\n\n  TIME looks like:  30m or 1m30s, etc.\n&amp;quot; unless $time;&lt;br/&gt;
&lt;br/&gt;
print &amp;quot;Dropping for $time ($seconds seconds), in 5 seconds (Hit ^C to abort) &amp;quot;;&lt;br/&gt;
sleep(5);&lt;br/&gt;
print &amp;quot;\n&amp;quot;;&lt;br/&gt;
&lt;br/&gt;
startDroppingPackets();&lt;br/&gt;
&lt;br/&gt;
sleep($seconds);&lt;br/&gt;
&lt;br/&gt;
stopDroppingPackets();&lt;br/&gt;
&lt;br/&gt;
exit 0;&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
sub fromNiceTime {&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;my ($str) = @_;&lt;br/&gt;
&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;my $seconds = 0;&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($str =~ s/^(\d+)d//) {&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$seconds += $1 * 24 * 60 * 60;&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($str =~ s/^(\d+)h//) {&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$seconds += $1 * 60 * 60;&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($str =~ s/^(\d+)m//) {&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$seconds += $1 * 60;&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($str =~ s/^(\d+)s?$//) {&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$seconds += $1;&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br/&gt;
&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return $seconds if $str eq &amp;#39;&amp;#39;;&lt;br/&gt;
&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return undef;&lt;br/&gt;
}&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
sub startDroppingPackets {&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &amp;quot;Dropping...\n&amp;quot;;&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;execute(qw(iptables -I INPUT 1 -p tcp --sport 1000:60000 -j DROP));&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;execute(qw(iptables -I INPUT 2 -p tcp --dport 1000:60000 -j DROP));&lt;br/&gt;
}&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
sub stopDroppingPackets {&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;execute(qw(iptables -D INPUT 1));&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;execute(qw(iptables -D INPUT 1));&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print &amp;quot;Stopped.\n&amp;quot;;&lt;br/&gt;
}&lt;br/&gt;
&lt;br/&gt;
sub execute {&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;my @args = @_;&lt;br/&gt;
&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;my $rc = system(@args);&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return 1 if $rc == 0;&lt;br/&gt;
&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;warn &amp;quot;Failed running [@args]: Code &amp;quot;, ($rc &amp;gt;&amp;gt; 8), &amp;quot;: $!\n&amp;quot;;&lt;br/&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return undef;&lt;br/&gt;
}&lt;br/&gt;
</comment>
                    <comment id="27027" author="TimSmith" created="Thu, 10 May 2012 17:44:24 -0500"  >A lesser problem happens when the host is not dropping packets, but just the couchbase-server service is stopped.&lt;br/&gt;
&lt;br/&gt;
In this case, there&amp;#39;s a 2.5-sec wait after the get callback hits the error, until libcouchbase_wait() call returns. I&amp;#39;d expect it to return right away, because there&amp;#39;s no more work to be done.&lt;br/&gt;
&lt;br/&gt;
To reproduce, start a cluster with 2 or 3 nodes. Ensure everything&amp;#39;s working OK. Then shut down one of the nodes:&lt;br/&gt;
&lt;br/&gt;
service couchbase-server stop&lt;br/&gt;
&lt;br/&gt;
Now run the client, try with a few different keys until you find one for the down server:&lt;br/&gt;
&lt;br/&gt;
&lt;a href=&apos;mailto:root@localhost&apos;&gt;root@localhost&lt;/a&gt; cb-crank]# time ./cbget 10.4.2.14:8091 Administrator password default hello&lt;br/&gt;
Got: hello: 776f726c642100&lt;br/&gt;
&lt;br/&gt;
real    0m0.017s&lt;br/&gt;
user    0m0.005s&lt;br/&gt;
sys     0m0.002s&lt;br/&gt;
[&lt;a href=&apos;mailto:root@localhost&apos;&gt;root@localhost&lt;/a&gt; cb-crank]# time ./cbget 10.4.2.14:8091 Administrator password default xyz&lt;br/&gt;
Failed during get &amp;#39;xyz&amp;#39;: 23 (Connection failure)&lt;br/&gt;
&lt;br/&gt;
real    0m2.517s&lt;br/&gt;
user    0m0.005s&lt;br/&gt;
sys     0m0.001s&lt;br/&gt;
[&lt;a href=&apos;mailto:root@localhost&apos;&gt;root@localhost&lt;/a&gt; cb-crank]# &lt;br/&gt;
&lt;br/&gt;
Note tha the &amp;quot;Failed during get&amp;quot; message appears immediately, and then there is a 2.5-second wait before the client exits.&lt;br/&gt;
&lt;br/&gt;
Complete client code (a bit simpler than the first one) is attached as cbget.c, compiled as:&lt;br/&gt;
&lt;br/&gt;
gcc -g -Wall -W -I/root/code/install/include  -L/root/code/install/lib -Wl,-rpath,/root/code/install/lib   cbget.c  -lcouchbase  -o cbget&lt;br/&gt;
&lt;br/&gt;
</comment>
                    <comment id="27030" author="TimSmith" created="Thu, 10 May 2012 17:47:48 -0500"  >Simple cbget command to just get a single key.</comment>
                    <comment id="27034" author="ingenthr" created="Thu, 10 May 2012 18:40:11 -0500"  >This could be related to the issue found and fixed today.</comment>
                    <comment id="27067" author="avsej" created="Fri, 11 May 2012 05:36:43 -0500"  >1. it is better not to use Administrator account to connect to cluster (default bucket should be accessible)&lt;br/&gt;
2. looks like your cbget.c has typo, but it depends how you are storing the key (I&amp;#39;ve used &amp;#39;cbc cp&amp;#39; command which doesn&amp;#39;t send zero byte for key, and therefore &amp;#39;nkey[0]&amp;#39; should be &amp;#39;strlen(key)&amp;#39;)&lt;br/&gt;
3. interesting, but my ruby gem (based on libcouchbase) fails fast if some node (which should receive the key) is down</comment>
                    <comment id="27068" author="avsej" created="Fri, 11 May 2012 05:54:11 -0500"  >This is because your program ignores errors in the callback, the libcouchbase call your get callback with the error immediately, I&amp;#39;m looking for why libcouchbase continue waiting then</comment>
                    <comment id="27069" author="avsej" created="Fri, 11 May 2012 09:00:22 -0500"  >Looks like it isn&amp;#39;t possible to get notification from libevent regarding socket closed (if address is valid), this is why we are using timeouts to check when to breakout the event loop.&lt;br/&gt;
&lt;br/&gt;
You are free to use libcouchbase_wait(), the libcouchbase allows event loops, executed by user (this is how I handle it in ruby client). In this case you should build IO object and breakout event loop immediately when you received the error. Take a look at couchview.c example &lt;a href=&quot;https://github.com/couchbase/libcouchbase/blob/master/example/couchview.c#L289&quot;&gt;https://github.com/couchbase/libcouchbase/blob/master/example/couchview.c#L289&lt;/a&gt;</comment>
                    <comment id="27153" author="avsej" created="Mon, 14 May 2012 03:20:57 -0500"  >I think I found the issue, and it is indeed bug in the libcouchbase. It has enough information to breakout event loop and release wait() function. The problem in releasing one of the internal buffers and I&amp;#39;m working on fix now</comment>
                    <comment id="27164" author="avsej" created="Mon, 14 May 2012 08:32:47 -0500"  >Fixed here &lt;a href=&quot;http://review.couchbase.org/15966&quot;&gt;http://review.couchbase.org/15966&lt;/a&gt; and awaiting for review</comment>
                    <comment id="27287" author="avsej" created="Tue, 15 May 2012 17:48:07 -0500"  >&lt;a href=&quot;https://github.com/couchbase/libcouchbase/commit/3d101adff79725dcad0f6e374733f4f593e6c980&quot;&gt;https://github.com/couchbase/libcouchbase/commit/3d101adff79725dcad0f6e374733f4f593e6c980&lt;/a&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="13163" name="cbget.c" size="2835" author="TimSmith" created="Thu, 10 May 2012 17:47:48 -0500" />
                    <attachment id="12969" name="t.c" size="8564" author="TimSmith" created="Tue, 1 May 2012 17:31:42 -0500" />
                </attachments>
            <subtasks>
        </subtasks>
                <customfields>
                                                                                                                                                                                                                    <customfield id="customfield_10081" key="com.pyxis.greenhopper.jira:gh-global-rank">
                <customfieldname>Rank</customfieldname>
                <customfieldvalues>
                    <customfieldvalue>10743</customfieldvalue>
                </customfieldvalues>
            </customfield>
                                                                                    <customfield id="customfield_10181" key="com.atlassian.jira.ext.charting:timeinstatus">
                <customfieldname>Time In Status</customfieldname>
                <customfieldvalues>
                    
                </customfieldvalues>
            </customfield>
                                                </customfields>
    </item>
</channel>
</rss>