<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:51:45 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-212] java driver hung when primary is killed</title>
                <link>https://jira.mongodb.org/browse/JAVA-212</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;1.7.2 servers.&lt;/p&gt;


&lt;p&gt;Code:&lt;/p&gt;

&lt;p&gt;	try {&lt;br/&gt;
			if (enable_debug) &lt;/p&gt;
{
				System.err.println(&quot;Info DbInsertListWorker: Insertion begin&quot;);
			}
&lt;p&gt;			try {&lt;br/&gt;
				if (mongo != null) {&lt;br/&gt;
					DB db = mongo.getDB(dbName);&lt;br/&gt;
					if (db != null) {&lt;br/&gt;
						db.requestStart();&lt;br/&gt;
						DBCollection collection = db&lt;br/&gt;
								.getCollection(collectionName);&lt;br/&gt;
						if (collection != null) {&lt;br/&gt;
							db.resetError();&lt;br/&gt;
							WriteConcern concern = new WriteConcern(2, 1000);&lt;br/&gt;
							collection.insert(list.toArray(new DBObject[list&lt;br/&gt;
									.size()]), concern);&lt;br/&gt;
							DBObject dbObject = db.getPreviousError();&lt;br/&gt;
							if (dbObject != null &amp;amp;&amp;amp; dbObject.get(&quot;err&quot;) != null) &lt;/p&gt;
{
								System.out
										.println(&quot;Info DbInsertListWorker preverror:&quot;
												+ dbObject.toString());
							}
&lt;p&gt;							dbObject = db&lt;br/&gt;
									.getLastError(WriteConcern.REPLICAS_SAFE);&lt;br/&gt;
							if (dbObject != null &amp;amp;&amp;amp; dbObject.get(&quot;err&quot;) != null) &lt;/p&gt;
{
								System.out
										.println(&quot;Info DbInsertListWorker lasterror:&quot;
												+ dbObject.toString());
							}
&lt;p&gt;						} else &lt;/p&gt;
{
							System.out
									.println(&quot;Info DbInsertListWorker: empty collection&quot;);
						}
&lt;p&gt;						db.requestDone();&lt;br/&gt;
					} else &lt;/p&gt;
{
						System.out.println(&quot;Info DbInsertListWorker: empty db&quot;);
					}
&lt;p&gt;				} else &lt;/p&gt;
{
					System.out.println(&quot;Info DbInsertListWorker: empty mongo&quot;);
				}
&lt;p&gt;			} catch (Exception ex) &lt;/p&gt;
{
				System.out.println(&quot;DbInsertListWorker: exception &quot; + ex);
				ex.printStackTrace();
			}
&lt;p&gt;			if (enable_debug) &lt;/p&gt;
{
				System.err.println(&quot;Info DbInsertListWorker: Insertion end&quot;);
			}
&lt;p&gt;		} catch (Exception ex) &lt;/p&gt;
{
			System.err.println(&quot;Error DbInsertListWorker:&quot; + ex.toString());
		}
&lt;p&gt;	}&lt;/p&gt;


&lt;p&gt;Have 1 primary, 1 slave, and 1 arbiter. Killed primary while running insertion test. The secondary&lt;br/&gt;
became the primary immediately. However, Java driver seems to hang.&lt;/p&gt;

&lt;p&gt;Nov 4, 2010 11:48:15 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
WARNING: node down: ip-10-166-59-166:20000 java.io.IOException: couldn&apos;t connect to &lt;span class=&quot;error&quot;&gt;&amp;#91;ip-10-166-59-166/10.166.59.166:20000&amp;#93;&lt;/span&gt; bc:java.net.ConnectException: Connection refused&lt;br/&gt;
Nov 4, 2010 11:48:20 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
WARNING: node down: ip-10-166-59-166:20000 java.io.IOException: couldn&apos;t connect to &lt;span class=&quot;error&quot;&gt;&amp;#91;ip-10-166-59-166/10.166.59.166:20000&amp;#93;&lt;/span&gt; bc:java.net.ConnectException: Connection refused&lt;br/&gt;
Nov 4, 2010 11:48:25 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
WARNING: node down: ip-10-166-59-166:20000 java.io.IOException: couldn&apos;t connect to &lt;span class=&quot;error&quot;&gt;&amp;#91;ip-10-166-59-166/10.166.59.166:20000&amp;#93;&lt;/span&gt; bc:java.net.ConnectException: Connection refused&lt;br/&gt;
Nov 4, 2010 11:48:30 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
WARNING: node down: ip-10-166-59-166:20000 java.io.IOException: couldn&apos;t connect to &lt;span class=&quot;error&quot;&gt;&amp;#91;ip-10-166-59-166/10.166.59.166:20000&amp;#93;&lt;/span&gt; bc:java.net.ConnectException: Connection refused&lt;br/&gt;
Nov 4, 2010 11:48:35 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
WARNING: node down: ip-10-166-59-166:20000 java.io.IOException: couldn&apos;t connect to &lt;span class=&quot;error&quot;&gt;&amp;#91;ip-10-166-59-166/10.166.59.166:20000&amp;#93;&lt;/span&gt; bc:java.net.ConnectException: Connection refused&lt;br/&gt;
Nov 4, 2010 11:48:40 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
WARNING: node down: ip-10-166-59-166:20000 java.io.IOException: couldn&apos;t connect to &lt;span class=&quot;error&quot;&gt;&amp;#91;ip-10-166-59-166/10.166.59.166:20000&amp;#93;&lt;/span&gt; bc:java.net.ConnectException: Connection refused&lt;br/&gt;
Nov 4, 2010 11:48:45 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
WARNING: node down: ip-10-166-59-166:20000 java.io.IOException: couldn&apos;t connect to &lt;span class=&quot;error&quot;&gt;&amp;#91;ip-10-166-59-166/10.166.59.166:20000&amp;#93;&lt;/span&gt; bc:java.net.ConnectException: Connection refused&lt;br/&gt;
...&lt;br/&gt;
Nov 4, 2010 11:48:50 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
WARNING: node down: ip-10-166-59-166:20000 java.io.IOException: couldn&apos;t connect to &lt;span class=&quot;error&quot;&gt;&amp;#91;ip-10-166-59-166/10.166.59.166:20000&amp;#93;&lt;/span&gt; bc:java.net.ConnectException: Connection refused&lt;br/&gt;
Nov 4, 2010 11:48:55 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
WARNING: node down: ip-10-166-59-166:20000 java.io.IOException: couldn&apos;t connect to &lt;span class=&quot;error&quot;&gt;&amp;#91;ip-10-166-59-166/10.166.59.166:20000&amp;#93;&lt;/span&gt; bc:java.net.ConnectException: Connection refused&lt;/p&gt;
</description>
                <environment></environment>
        <key id="13627">JAVA-212</key>
            <summary>java driver hung when primary is killed</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="antoine">Antoine Girbal</assignee>
                                    <reporter username="joseph.wang">Joseph Wang </reporter>
                        <labels>
                    </labels>
                <created>Fri, 5 Nov 2010 03:55:52 +0000</created>
                <updated>Tue, 25 Jun 2013 16:49:40 +0000</updated>
                            <resolved>Mon, 24 Oct 2011 11:37:36 +0000</resolved>
                                    <version>2.3</version>
                                                    <component>Cluster Management</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="62147" author="scotthernandez" created="Mon, 24 Oct 2011 11:37:36 +0000"  >&lt;p&gt;With the latest driver, soon to be 2.7, we cannot reproduce this. Please let us know if you can.&lt;/p&gt;</comment>
                            <comment id="23708" author="joseph.wang" created="Fri, 11 Feb 2011 20:41:42 +0000"  >&lt;p&gt;1) we&apos;ve not switched to 2.4 java driver.&lt;br/&gt;
2) don&apos;t remember. the ticket was open several months ago.&lt;/p&gt;</comment>
                            <comment id="23707" author="antoine" created="Fri, 11 Feb 2011 20:35:51 +0000"  >&lt;p&gt;output from sample test&lt;/p&gt;</comment>
                            <comment id="23706" author="antoine" created="Fri, 11 Feb 2011 20:34:34 +0000"  >&lt;p&gt;Looking into this issue.&lt;br/&gt;
First thing: note that the following error message is normal&lt;br/&gt;
&quot;Nov 4, 2010 11:48:15 PM com.mongodb.ReplicaSetStatus$Node update&lt;br/&gt;
WARNING: node down: ip-10-166-59-166:20000 java.io.IOException: couldn&apos;t connect to &lt;span class=&quot;error&quot;&gt;&amp;#91;ip-10-166-59-166/10.166.59.166:20000&amp;#93;&lt;/span&gt; bc:java.net.ConnectException: Connection refused&quot;&lt;br/&gt;
The driver will keep trying to test this server every 5s, since it is part of the replica set.&lt;/p&gt;

&lt;p&gt;I tried to reproduce this issue with driver 2.5.&lt;br/&gt;
I could not get the driver to hang.&lt;br/&gt;
I basically took your code, with an insert of 10,000 objects, and I repeat the insert 10 times.&lt;br/&gt;
During the 1st insert, before it calls getlasterror I added a short sleep and I kill the primary server.&lt;br/&gt;
The driver shows that it correctly switch over to a different master, and I end up with correct 100,000 documents in collection.&lt;br/&gt;
I attached the output log.&lt;/p&gt;

&lt;p&gt;Questions:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;do you still experience issue with 2.4 driver?&lt;/li&gt;
	&lt;li&gt;do you know when exactly you kill the primary server? I can will try to time it to kill server during the insert itself.&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="20086" author="joseph.wang" created="Fri, 5 Nov 2010 22:20:56 +0000"  >&lt;p&gt;It seems the only way to get around this is to close mongo instance and reestablish connection.&lt;/p&gt;</comment>
                            <comment id="20083" author="joseph.wang" created="Fri, 5 Nov 2010 21:23:18 +0000"  >&lt;p&gt;Killed the primary while running the insert. Even though the primary switched&lt;br/&gt;
from ip-10-166-59-166:20000 to ip-10-166-57-74:20000, the driver is still&lt;br/&gt;
connected to ip-10-166-59-166:20000. &lt;/p&gt;


&lt;p&gt;mongo.debugString() showed:&lt;br/&gt;
    DBTCPConnector: replica set : [ip-10-166-59-166:20000,&lt;br/&gt;
ip-10-166-57-74:20000]&lt;/p&gt;

&lt;p&gt;mongo.getConnectPoint() showed:&lt;br/&gt;
    ip-10-166-59-166:20000&lt;/p&gt;

</comment>
                            <comment id="20046" author="joseph.wang" created="Fri, 5 Nov 2010 04:00:37 +0000"  >&lt;p&gt;insert test script&lt;/p&gt;

&lt;p&gt;no=10000000&lt;br/&gt;
id=1&lt;br/&gt;
thread=10&lt;br/&gt;
version=0&lt;br/&gt;
option=1&lt;/p&gt;

&lt;p&gt;date &amp;gt; insert.log&lt;br/&gt;
java -cp &quot;/root/mongo-2.3.jar:/root/leadpoint.jar:.&quot; com.leadpoint.db.MongoDbInsert -no ${no} -thread ${thread} -id ${id} -version ${version} -option ${option} &amp;gt;&amp;gt; insert.log 2&amp;gt;&amp;amp;1&lt;br/&gt;
date &amp;gt;&amp;gt; insert.log&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="10581" name="DbInsertListWorker.java" size="2604" author="joseph.wang" created="Fri, 5 Nov 2010 04:00:37 +0000"/>
                            <attachment id="10582" name="MongoDbInsert.java" size="6521" author="joseph.wang" created="Fri, 5 Nov 2010 04:00:37 +0000"/>
                            <attachment id="10583" name="MortgageObject.java" size="2779" author="joseph.wang" created="Fri, 5 Nov 2010 04:00:37 +0000"/>
                            <attachment id="10816" name="java-212-output.txt" size="17846" author="antoine" created="Fri, 11 Feb 2011 20:35:51 +0000"/>
                    </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|hrhcmn:</customfieldvalue>

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