<!-- 
RSS generated by JIRA (5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9) at Mon May 20 07:42:20 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/MB-4692/MB-4692.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>[MB-4692] Reduce view returns incorrect results</title>
                <link>http://www.couchbase.com/issues/browse/MB-4692</link>
                <project id="10010" key="MB">Couchbase Server</project>
                        <description>Created 10 node cluster. Created a view {&amp;quot;reduce&amp;quot;:{&amp;quot;map&amp;quot;:&amp;quot;function (doc) {\n  emit(doc._id, null);\n}&amp;quot;,&amp;quot;reduce&amp;quot;:&amp;quot;_count&amp;quot;} and uploaded 100k json items using mcsoda. Queried the view with stale=false. Result was correct. Started removing nodes one by one from a cluster while running view queries. After second node was removed the view started returning more than 100k items. I figured out that all duplicated rows come from a single node. And on this node all the duplicated rows come from three vbuckets: 215, 216, 217. There was a period of time when these vbuckets were reported by set views both as passive and replicas:&lt;br/&gt;
&lt;br/&gt;
&amp;nbsp;Set view `default`, main group `_design/dev_test`, partition states updated&lt;br/&gt;
active partitions before:  [73,74,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,101,102,103,240,241,242]&lt;br/&gt;
active partitions after:   [73,74,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,101,102,103,240,241,242]&lt;br/&gt;
passive partitions before: [215,216,217]&lt;br/&gt;
passive partitions after:  [215,216,217]&lt;br/&gt;
cleanup partitions before: []&lt;br/&gt;
cleanup partitions after:  []&lt;br/&gt;
replica partitions before:   [6,7,8,32,33,34,58,59,60,113,114,115,127,139,140,141,155,164,165,188,189,190,208,211,214,215,216,217,233,236,239,244,249]&lt;br/&gt;
replica partitions after:    [6,7,8,32,33,34,58,59,60,113,114,115,127,139,140,141,155,164,165,188,189,190,208,211,214,215,216,217,233,236,239,244,249]&lt;br/&gt;
replicas on transfer before: [215,216,217]&lt;br/&gt;
replicas on transfer after:  [215,216,217]&lt;br/&gt;
&lt;br/&gt;
Sequence of calls that was performed by ns_server seems to be correct. I&amp;#39;m attaching full logs and diag from this node.</description>
                <environment></environment>
            <key id="15997">MB-4692</key>
            <summary>Reduce view returns incorrect results</summary>
                <type id="1" iconUrl="http://www.couchbase.com/issues/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="1" iconUrl="http://www.couchbase.com/issues/images/icons/priorities/blocker.png">Blocker</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="karan">Karan Kumar</assignee>
                                <reporter username="Aliaksey Artamonau">Aliaksey Artamonau</reporter>
                        <labels>
                    </labels>
                <created>Tue, 24 Jan 2012 18:17:35 -0600</created>
                <updated>Mon, 23 Jul 2012 14:53:47 -0500</updated>
                    <resolved>Mon, 6 Feb 2012 19:56:12 -0600</resolved>
                            <version>2.0-developer-preview-4</version>
                                <fixVersion>2.0-developer-preview-4</fixVersion>
                                <component>ns_server</component>
                                <votes>0</votes>
                        <watches>0</watches>
                                                    <comments>
                    <comment id="23778" author="Aliaksey Artamonau" created="Thu, 26 Jan 2012 01:55:38 -0600"  >Following Filipe&amp;#39;s advice I added additional check on intersection between active partitions in main index and partitions from replica index to couch_set_view:modify_bitmasks. But these sets are disjoint even when view give an incorrect result.</comment>
                    <comment id="23800" author="Aliaksey Artamonau" created="Thu, 26 Jan 2012 17:03:22 -0600"  >&lt;a href=&quot;http://review.couchbase.org/#change,12711&quot;&gt;http://review.couchbase.org/#change,12711&lt;/a&gt; does not make any difference for me.</comment>
                    <comment id="23842" author="damien" created="Fri, 27 Jan 2012 17:56:01 -0600"  >This is a exact list of instructions how to reproduce bad views with discrete, non-concurrent steps (100% reproducible, no need to try to make race conditions happen).&lt;br/&gt;
&lt;br/&gt;
Get a fresh repo named couchbase, and copy the del.py and add.py files to couchbase/ep-engine/management/&lt;br/&gt;
&lt;br/&gt;
cd couchbase&lt;br/&gt;
make&lt;br/&gt;
cd ns_server&lt;br/&gt;
make dataclean&lt;br/&gt;
./cluster_run --nodes=2&lt;br/&gt;
&lt;br/&gt;
from another terminal:&lt;br/&gt;
&lt;br/&gt;
cd couchbase/ns_server&lt;br/&gt;
./cluster_connect -n 1&lt;br/&gt;
cd ../ep-engine/management&lt;br/&gt;
python add.py&lt;br/&gt;
&lt;br/&gt;
From the web ui, create a new view.&lt;br/&gt;
Click &amp;quot;Views&amp;quot; at top&lt;br/&gt;
Click &amp;quot;Create Development View&amp;quot; button&lt;br/&gt;
Enter in test names&lt;br/&gt;
Edit the view and change map function to:&lt;br/&gt;
function (doc) {&lt;br/&gt;
emit(doc._id, 1);&lt;br/&gt;
}&lt;br/&gt;
For the reduce, click _count:&lt;br/&gt;
Click &amp;quot;Save&amp;quot; button&lt;br/&gt;
Click &amp;quot;Full Cluster Data Set&amp;quot; button&lt;br/&gt;
Click the generated Url to open the raw json view in another browser window&lt;br/&gt;
Keep refreshing until Value is 100000 (or whatever you expect)&lt;br/&gt;
&lt;br/&gt;
From previous terminal window:&lt;br/&gt;
python del.py&lt;br/&gt;
&lt;br/&gt;
NOTE: DO NOT REFRESH THE VIEW FROM BROWSER YET!&lt;br/&gt;
From the web ui click &amp;quot;Server Nodes&amp;quot; at top.&lt;br/&gt;
Click &amp;quot;Add Server&amp;quot; button&lt;br/&gt;
Enter in same ip address, and increment the port by one:&lt;br/&gt;
Example:&lt;br/&gt;
Server:10.2.1.60:9001&lt;br/&gt;
Username:Administrator&lt;br/&gt;
Password: asdasd&lt;br/&gt;
&lt;br/&gt;
Click &amp;quot;Add Server&amp;quot; button&lt;br/&gt;
Click &amp;quot;Rebalance&amp;quot; button&lt;br/&gt;
&lt;br/&gt;
When rebalance finishes, go back to your raw JSON view in the browser, and refresh. Keep refreshing until the value stops changes.&lt;br/&gt;
&lt;br/&gt;
The value should be non-zero. BUG!!!!!&lt;br/&gt;
&lt;br/&gt;
Now go back to &amp;quot;Server Nodes&amp;quot; in web ui&lt;br/&gt;
Click the &amp;quot;Remove&amp;quot; button for the newly added node.&lt;br/&gt;
Click &amp;quot;Rebalance&amp;quot; button&lt;br/&gt;
&lt;br/&gt;
When rebalance finishes, go back to your raw JSON view in the browser, and refresh. The value should be the same as before. This indicates the bad values are coming from the first node.&lt;br/&gt;
&lt;br/&gt;
</comment>
                    <comment id="23843" author="damien" created="Fri, 27 Jan 2012 17:57:23 -0600"  >Used to reproduce steps from damien</comment>
                    <comment id="23844" author="damien" created="Fri, 27 Jan 2012 17:57:50 -0600"  >Used to reproduce steps from damien</comment>
                    <comment id="23849" author="Filipe Manana" created="Fri, 27 Jan 2012 23:46:57 -0600"  >&lt;a href=&quot;http://review.couchbase.org/#change,12767&quot;&gt;http://review.couchbase.org/#change,12767&lt;/a&gt; fixes it</comment>
                    <comment id="23860" author="Aliaksey Artamonau" created="Sat, 28 Jan 2012 18:59:45 -0600"  >Reproduced it with all the latest fixes using the same scenario (though it definitely happens less frequently). After another rebalance out view constantly returns more items than there are in bucket. I figured out that one of the nodes returns items from vbucket 250 that is not activated in the index. It used to be active but then set_partition_states with cleanup_partitions=[250] was called. Will attach full logs from this node soon.</comment>
                    <comment id="23862" author="farshid" created="Sat, 28 Jan 2012 19:33:16 -0600"  >./testrunner -i b/resources/dev-4-nodes.ini -t viewtests.ViewTests.test_count_reduce_100k_docs&lt;br/&gt;
&lt;br/&gt;
it happens even with a single node but less frequeent than before</comment>
                    <comment id="23869" author="Filipe Manana" created="Sun, 29 Jan 2012 10:03:10 -0600"  >@Aliaksey&lt;br/&gt;
&lt;br/&gt;
Need more info on how to reproduce this. Are the query results inconsistent during failover or rebalance (or both)? Are they temporary (only during rebalance or failover) or permanent?&lt;br/&gt;
&lt;br/&gt;
Please make sure all your nodes have the following couchdb commit:&lt;br/&gt;
&lt;a href=&quot;https://github.com/couchbase/couchdb/commit/43c6b744c8a110c5a1f6f9a2039fcc405cbff1a9&quot;&gt;https://github.com/couchbase/couchdb/commit/43c6b744c8a110c5a1f6f9a2039fcc405cbff1a9&lt;/a&gt;&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
@Farshid&lt;br/&gt;
&lt;br/&gt;
Farshid, I ran that test locally, sometimes fails for me too.&lt;br/&gt;
One thing I notice is that the test&amp;#39;s queries don&amp;#39;t specify ?stale=false. I think this is what making the test fail often.&lt;br/&gt;
I changed locally the test viewtests.ViewTests.test_count_reduce_100k_docs to add stale=false to all queries, and like this the test passes always for me:&lt;br/&gt;
&lt;br/&gt;
&lt;a href=&quot;http://friendpaste.com/5OUPCfOUHxEG4HBB0qU7r9&quot;&gt;http://friendpaste.com/5OUPCfOUHxEG4HBB0qU7r9&lt;/a&gt;&lt;br/&gt;
&lt;br/&gt;
Can you verify that?</comment>
                    <comment id="23878" author="Aliaksey Artamonau" created="Sun, 29 Jan 2012 13:25:31 -0600"  >Results where permanently inconsistent after rebalancing out several nodes. All the nodes where build with the commit you&amp;#39;re referring.</comment>
                    <comment id="24174" author="steve" created="Mon, 6 Feb 2012 19:29:44 -0600"  >need repro?</comment>
                    <comment id="24177" author="karan" created="Mon, 6 Feb 2012 19:56:12 -0600"  >Confirmed that test_count_reduce_x_docs passes. &lt;br/&gt;
</comment>
                </comments>
                    <attachments>
                    <attachment id="12077" name="add.py" size="160" author="damien" created="Fri, 27 Jan 2012 17:59:12 -0600" />
                    <attachment id="12078" name="del.py" size="145" author="damien" created="Fri, 27 Jan 2012 17:59:28 -0600" />
                    <attachment id="12093" name="incorrect_results.tar.bz2" size="14298819" author="Aliaksey Artamonau" created="Sat, 28 Jan 2012 19:06:37 -0600" />
                    <attachment id="12054" name="logs.tar.bz2" size="389576" author="Aliaksey Artamonau" created="Tue, 24 Jan 2012 18:17:35 -0600" />
                    <attachment id="12055" name="ns-diag-20120124155027.txt.bz2" size="811304" author="Aliaksey Artamonau" created="Tue, 24 Jan 2012 18:17:35 -0600" />
                </attachments>
            <subtasks>
        </subtasks>
                <customfields>
                                                                        <customfield id="customfield_10180" key="com.atlassian.jira.ext.charting:firstresponsedate">
                <customfieldname>Date of First Response</customfieldname>
                <customfieldvalues>
                    <customfieldvalue>Fri, 27 Jan 2012 17:56:01 -0600</customfieldvalue>

                </customfieldvalues>
            </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10081" key="com.pyxis.greenhopper.jira:gh-global-rank">
                <customfieldname>Rank</customfieldname>
                <customfieldvalues>
                    <customfieldvalue>5758</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>