<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51:39 UTC 2024

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 append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-168] WriteConcern constructor sets getlasterror incorrectly for w&lt;1</title>
                <link>https://jira.mongodb.org/browse/JAVA-168</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Creating a WriteConcern with a w value of 0 or -1 incorrectly sets getlasterror to 1 instead of 0.&lt;/p&gt;

&lt;p&gt;The callGetLastError method correctly returns true only if w &amp;gt; 0.&lt;/p&gt;

&lt;p&gt;It appears that this line in the constructor WriteConcern( int w , int wtimeout , boolean fsync):&lt;br/&gt;
    _command = new BasicDBObject( &quot;getlasterror&quot; , 1 );&lt;br/&gt;
should be change to:&lt;br/&gt;
    _command = new BasicDBObject( &quot;getlasterror&quot; , _w &amp;gt; 0 ? 1 : 0 );&lt;/p&gt;</description>
                <environment></environment>
        <key id="13207">JAVA-168</key>
            <summary>WriteConcern constructor sets getlasterror incorrectly for w&lt;1</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="5">Cannot Reproduce</resolution>
                                        <assignee username="eliot">Eliot Horowitz</assignee>
                                    <reporter username="dan.flye@hp.com">Dan Flye</reporter>
                        <labels>
                    </labels>
                <created>Tue, 28 Sep 2010 01:24:10 +0000</created>
                <updated>Wed, 8 Feb 2023 13:07:51 +0000</updated>
                            <resolved>Mon, 22 Nov 2010 01:12:53 +0000</resolved>
                                    <version>2.1</version>
                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="20564" author="eliot" created="Mon, 22 Nov 2010 01:12:53 +0000"  >&lt;p&gt;This is working exactly as expected for me.&lt;br/&gt;
I see errors in the log - but no error is thrown.&lt;/p&gt;</comment>
                            <comment id="18621" author="dan.flye@hp.com" created="Tue, 28 Sep 2010 02:28:34 +0000"  >&lt;p&gt;The code in question is a junit test that attempts to exercise the various persistency layers in our app, with Morphia used for pojo/bson conversion.&lt;/p&gt;

&lt;p&gt;Chunk of pseudo code after wading through a bunch of classes is below.&lt;/p&gt;

&lt;p&gt;My scenario was to fire up the test with mongo running, stop the instance part way through, hope to observe a lack of errors, then restart the mongo instance.  With original code, errors thrown each iteration; revised code, no errors thrown.&lt;/p&gt;

&lt;p&gt;// setup code: instantiate initial user object and insert in mongo&lt;br/&gt;
defaultWriteConcern = new WriteConcern(-1, 0, false);&lt;br/&gt;
for (int i = 0; i &amp;lt; 1000000; i++) {&lt;br/&gt;
	DBCollection coll = db.getCollection(&quot;user&quot;);&lt;br/&gt;
	WriteResult wr = null;&lt;br/&gt;
	db.requestStart();&lt;br/&gt;
	try &lt;/p&gt;
{
		user.setPassword(TEST_NEW_PASSWORD + &quot;_&quot; + i);
		// use Morphia to convert user pojo to DBObject obj
		wr = coll.update(query, obj, false, false, defaultWriteConcern)
	}
&lt;p&gt; catch (Exception e) &lt;/p&gt;
{
		logger.info(&quot;defaultWriteConcern: &quot; + defaultWriteConcern);
	}
&lt;p&gt; finally &lt;/p&gt;
{
		db.requestDone():
	}
&lt;p&gt;}&lt;/p&gt;</comment>
                            <comment id="18620" author="eliot" created="Tue, 28 Sep 2010 02:08:19 +0000"  >&lt;p&gt;The value of the &quot;getlasterror&quot; field shouldn&apos;t matter at all.&lt;br/&gt;
Can you describe your test?&lt;/p&gt;</comment>
                            <comment id="18619" author="dan.flye@hp.com" created="Tue, 28 Sep 2010 02:01:48 +0000"  >&lt;p&gt;I&apos;m going by what the Java API docs state:&lt;/p&gt;

&lt;p&gt;&quot;WriteConcern control the write behavior for with various options, as well as exception raising on error conditions.&lt;/p&gt;

&lt;p&gt;w&lt;/p&gt;

&lt;p&gt;-1 = don&apos;t even report network errors&lt;br/&gt;
0 = default, don&apos;t call getLastError by default&lt;br/&gt;
1 = basic, call getLastError, but don&apos;t wait for slaves&lt;br/&gt;
2+= wait for slaves&quot;&lt;/p&gt;

&lt;p&gt;My testing was done passing -1 for w; I was still seeing backtraces when my test mongo instance was off while attempting to call update... after changing the driver code as suggested above, the driver ignored network errors as I&apos;d expected when w was -1.&lt;/p&gt;</comment>
                            <comment id="18617" author="eliot" created="Tue, 28 Sep 2010 01:49:31 +0000"  >&lt;p&gt;w=0 and w=1 should be the same.&lt;br/&gt;
what are you seeing that&apos;s wrong?&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrhcv3:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14884</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>