<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:53:00 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-762] authentication problem on Replica Set</title>
                <link>https://jira.mongodb.org/browse/JAVA-762</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;*******&lt;b&gt;NOTE start&lt;/b&gt;*******&lt;br/&gt;
As i can&apos;t confirm that this is a driver problem &lt;br/&gt;
or tomcat problem &lt;br/&gt;
or just a misuse of driver.&lt;br/&gt;
Please just help me confirm that whether driver problem.&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;
	&lt;ul&gt;
		&lt;li&gt;
		&lt;ul&gt;
			&lt;li&gt;
			&lt;ul&gt;
				&lt;li&gt;
				&lt;ul&gt;
					&lt;li&gt;
					&lt;ul&gt;
						&lt;li&gt;
						&lt;ul&gt;
							&lt;li&gt;
							&lt;ul&gt;
								&lt;li&gt;NOTE end ********&lt;/li&gt;
							&lt;/ul&gt;
							&lt;/li&gt;
						&lt;/ul&gt;
						&lt;/li&gt;
					&lt;/ul&gt;
					&lt;/li&gt;
				&lt;/ul&gt;
				&lt;/li&gt;
			&lt;/ul&gt;
			&lt;/li&gt;
		&lt;/ul&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;attached code runs normally when access a single mongo server(NOT a replica set )&lt;br/&gt;
but when i try to access replica set server, it pop a exception:(40 thread test)&lt;br/&gt;
java.lang.IllegalStateException: can&apos;t authenticate twice on the same database&lt;/p&gt;

&lt;p&gt;i don&apos;t know why &lt;span class=&quot;error&quot;&gt;&amp;#91;m_DBAccess.isAuthenticated()&amp;#93;&lt;/span&gt;returns a false and &lt;span class=&quot;error&quot;&gt;&amp;#91;m_DBAccess.authenticate&amp;#93;&lt;/span&gt; pop this exception.&lt;br/&gt;
please help.&lt;/p&gt;

&lt;p&gt;PS:&lt;br/&gt;
This only appearred in win 7 server(env 1), it does not appearred in linux server(env 2)&lt;/p&gt;

&lt;p&gt;code backgroud&lt;br/&gt;
m_MongoDB is a static Mongo instance.&lt;br/&gt;
m_DBAccess is a DB instance that every thread will get a db instance by using &lt;span class=&quot;error&quot;&gt;&amp;#91;m_MongoDB.getDB(&amp;quot;db_image&amp;quot;)&amp;#93;&lt;/span&gt;&lt;br/&gt;
In my opinion, every thread has a different db object (although it point to the same db), so authentication of each thread is needed.&lt;br/&gt;
Am i right?&lt;/p&gt;
</description>
                <environment>test environment&#65306;&lt;br/&gt;
1)win7 x64 enterprise version&#65288;debug server&#65289;&lt;br/&gt;
eclipse(with plugin com.sysdeo.eclipse.tomcat_3.3.0) + apache-tomcat-7.0.19 &lt;br/&gt;
&lt;br/&gt;
2)ubunto linux 12.04 x64 server (test server)&lt;br/&gt;
apache-tomcat-7.0.19 &lt;br/&gt;
&lt;br/&gt;
3)ubunto linux 12.04 x64 server (mongo replica set server * 3)&lt;br/&gt;
mongo db ver 2.2&lt;br/&gt;
the following command is called after replica set is build (without keyfile)&lt;br/&gt;
use image_db&lt;br/&gt;
db.addUser(&amp;#39;testusr&amp;#39;,&amp;#39;testpwd&amp;#39;)&lt;br/&gt;
db.createCollection(&amp;#39;image_collection&amp;#39;,{autoIndexId:true})&lt;br/&gt;
db.image_db.ensureIndex({&amp;#39;name&amp;#39;:1, &amp;#39;userid&amp;#39;:1, &amp;#39;kind&amp;#39;:1},{backgroud:true})&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
</environment>
        <key id="65513">JAVA-762</key>
            <summary>authentication problem on Replica Set</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="9">Done</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="enchor">zhoumingyi</reporter>
                        <labels>
                            <label>driver</label>
                            <label>replication</label>
                    </labels>
                <created>Sat, 16 Feb 2013 04:22:59 +0000</created>
                <updated>Wed, 11 Sep 2019 19:10:39 +0000</updated>
                            <resolved>Thu, 21 Feb 2013 13:12:30 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="272037" author="jeff.yemin" created="Thu, 21 Feb 2013 13:12:30 +0000"  >&lt;p&gt;Yeah, I agree that the documentation on this is not stellar.  I&apos;ll work on a fix.&lt;/p&gt;</comment>
                            <comment id="271726" author="enchor" created="Thu, 21 Feb 2013 02:55:01 +0000"  >&lt;p&gt;thank you for your reply, i know how to modify my code now.&lt;br/&gt;
Just one more question:&lt;br/&gt;
I failed to find the following sentence &quot;All threads share the same DB instance for each unique database name.&quot; in java driver doc.&lt;br/&gt;
Am i ignore sth. while reading java docunment? &lt;br/&gt;
If so, please give me a the link of that. &lt;br/&gt;
Thanks~&lt;/p&gt;

</comment>
                            <comment id="270492" author="jeff.yemin" created="Tue, 19 Feb 2013 23:31:53 +0000"  >&lt;p&gt;Furthermore, it&apos;s possible that this is a race condition in your code (between the call to isAuthenticated and authenticate), which is another reason to authenticate in the same thread as creates the Mongo instance.&lt;/p&gt;</comment>
                            <comment id="270488" author="jeff.yemin" created="Tue, 19 Feb 2013 23:30:06 +0000"  >&lt;p&gt;All threads share the same DB instance for each unique database name.  So you only have to authenticate once.  It&apos;s best to do that right after you create your Mongo instance and before that instance is distributed to other threads. &lt;/p&gt;</comment>
                            <comment id="270485" author="jeff.yemin" created="Tue, 19 Feb 2013 23:26:39 +0000"  >&lt;p&gt;I moved this to the JAVA project since this is an issue with usage of the Java driver, not a server issue.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="24179" name="sample code.txt" size="1073" author="enchor" created="Sat, 16 Feb 2013 04:22:59 +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|hrm7if:</customfieldvalue>

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