<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:37:35 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>[CSHARP-698] Shutdown occasionally failing erroneously reporting not using localhost</title>
                <link>https://jira.mongodb.org/browse/CSHARP-698</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;We get this error message about 30% of the time&lt;/p&gt;

&lt;p&gt;Command &apos;shutdown&apos; failed: unauthorized: this command must run from localhost when running db without auth (response: &lt;/p&gt;
{ &quot;errmsg&quot; : &quot;unauthorized: this command must run from localhost when running db without auth&quot;, &quot;ok&quot; : 0.0 }
&lt;p&gt;)&lt;/p&gt;

&lt;p&gt;We do not use authentication in the database.&lt;/p&gt;

&lt;p&gt;This is the C# code we use to connect to the database for this command. This worked for fine when we were using an earlier version of the database.&lt;/p&gt;

&lt;p&gt;MongoServer.Create(string.Format(&quot;mongodb://localhost:&lt;/p&gt;
{0}
&lt;p&gt;/?slaveOk=true&quot;, MongoHostPortSetting.GetMongoHostPortSettings().Port));&lt;/p&gt;


&lt;p&gt;This is the stack trace:&lt;/p&gt;

&lt;p&gt;MongoDB.Driver.MongoCommandException: Command &apos;shutdown&apos; failed: unauthorized: this command must run from localhost when running db without auth (response: &lt;/p&gt;
{ &quot;errmsg&quot; : &quot;unauthorized: this command must run from localhost when running db without auth&quot;, &quot;ok&quot; : 0.0 }
&lt;p&gt;)&lt;br/&gt;
   at MongoDB.Driver.MongoDatabase.RunCommandAs(Type commandResultType, IMongoCommand command) in C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 978&lt;br/&gt;
   at MongoDB.Driver.MongoDatabase.RunCommandAs&lt;span class=&quot;error&quot;&gt;&amp;#91;TCommandResult&amp;#93;&lt;/span&gt;(String commandName) in C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 962&lt;br/&gt;
   at MongoDB.Driver.MongoServer.Shutdown(MongoCredentials adminCredentials) in C:\work\rstam\mongo-csharp-driver\Driver\Core\MongoServer.cs:line 1008&lt;br/&gt;
   at MongoWorker.WorkerRole.OnStop() in c:\Sources\iQmetrix\Service\MongoWorker\WorkerRole.cs:line 250&lt;/p&gt;


&lt;p&gt;Because the database does not shutdown cleanly it has to do a full recovery when we bring it back up which takes quite a while.&lt;/p&gt;</description>
                <environment>Windows Azure, C# worker role, 3 Replica set databases, no shards.</environment>
        <key id="66529">CSHARP-698</key>
            <summary>Shutdown occasionally failing erroneously reporting not using localhost</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="craig.wilson@mongodb.com">Craig Wilson</assignee>
                                    <reporter username="woaksie">John Woakes</reporter>
                        <labels>
                    </labels>
                <created>Tue, 26 Feb 2013 22:20:15 +0000</created>
                <updated>Tue, 16 Jul 2013 15:57:28 +0000</updated>
                            <resolved>Tue, 16 Jul 2013 15:57:21 +0000</resolved>
                                    <version>1.6</version>
                                                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="284525" author="sridhar" created="Fri, 8 Mar 2013 18:03:02 +0000"  >&lt;p&gt;What version of mongod are you running?&lt;/p&gt;</comment>
                            <comment id="284512" author="woaksie" created="Fri, 8 Mar 2013 17:45:04 +0000"  >&lt;p&gt;Note: We are running version 1.6 of the C# driver &lt;span class=&quot;error&quot;&gt;&amp;#91;issue says 1.7&amp;#93;&lt;/span&gt;&lt;/p&gt;</comment>
                            <comment id="284503" author="woaksie" created="Fri, 8 Mar 2013 17:41:37 +0000"  >&lt;p&gt;Sounds like a plan. The urgency of this issue is less now for us but it would be nice to get to the bottom of this. If you want us to test anything let me know.&lt;/p&gt;</comment>
                            <comment id="284266" author="craiggwilson" created="Fri, 8 Mar 2013 14:04:55 +0000"  >&lt;p&gt;John, I move this over to a C# issue.  We&apos;ll continue examining it here.&lt;/p&gt;

&lt;p&gt;I&apos;m very surprised that works.  Basically, that starts everything over, so somewhere, the you were getting a cached connection that wasn&apos;t pointing at localhost, which means your connection pooling thought seems to be right on.  &lt;/p&gt;</comment>
                            <comment id="283825" author="woaksie" created="Thu, 7 Mar 2013 23:21:39 +0000"  >&lt;p&gt;Ok, we have it working now. We added MongoServer.UnregisterAllServers() before creating a localhost server and calling shutdown on it.&lt;/p&gt;</comment>
                            <comment id="283640" author="craiggwilson" created="Thu, 7 Mar 2013 19:46:39 +0000"  >&lt;p&gt;That shouldn&apos;t interfere because the client settings for a replica set will be different than the ones you are using (seed list vs. loopback) and we pool based on the client settings.  I&apos;ll keep poking around but good thought.  I&apos;ll keep it in mind in case we have a bug in our &quot;hashing&quot; logic.&lt;/p&gt;</comment>
                            <comment id="283630" author="woaksie" created="Thu, 7 Mar 2013 19:37:04 +0000"  >&lt;p&gt;Yes, if we RDP into one of the Azure boxes and start up Mongo.exe we can execute a shutdown.&lt;/p&gt;

&lt;p&gt;We are wondering if it has something to do with connection pooling? We normally access the database via regular replica set connection, and only for shutdown do we fire up a new server with local host and slave=ok&lt;/p&gt;</comment>
                            <comment id="283484" author="craiggwilson" created="Thu, 7 Mar 2013 16:27:15 +0000"  >&lt;p&gt;John, we are having some trouble reproducing this problem.  Sridhar has attempted to replicate in Azure with vmAliases, but was unable to.  &lt;/p&gt;

&lt;p&gt;Are you able to shutdown the server from the shell?&lt;/p&gt;</comment>
                            <comment id="282783" author="woaksie" created="Wed, 6 Mar 2013 19:01:23 +0000"  >&lt;p&gt;P.S. This seems to be happening every time we shutdown now.&lt;/p&gt;</comment>
                            <comment id="282782" author="woaksie" created="Wed, 6 Mar 2013 19:00:14 +0000"  >&lt;p&gt;Yes we are using the vmName feature of Azure for our Mongo replica set configuration. We have for a while now.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/windowsazure/jj156077&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://msdn.microsoft.com/en-us/library/windowsazure/jj156077&lt;/a&gt;&lt;/p&gt;
</comment>
                            <comment id="282772" author="sridhar" created="Wed, 6 Mar 2013 18:49:45 +0000"  >&lt;p&gt;I cannot reproduce in my testing. John are you using VMAlias on these nodes. That is the one item I have not tested.&lt;/p&gt;</comment>
                            <comment id="281991" author="woaksie" created="Tue, 5 Mar 2013 19:19:49 +0000"  >&lt;p&gt;Running the db.isMaster() command on the first instance &lt;span class=&quot;error&quot;&gt;&amp;#91;Primary&amp;#93;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;{ setName:iq,&lt;br/&gt;
  ismaster:true,&lt;br/&gt;
  secondary:false,&lt;br/&gt;
  hosts:[MongoDB0:27017,&lt;br/&gt;
         MongoDB2:27017,&lt;br/&gt;
         MongoDB1:27017],&lt;br/&gt;
  primary:MongoDB0:27017,&lt;br/&gt;
  me:MongoDB0:27017,&lt;br/&gt;
  maxBsonObjectSize:16777216,&lt;br/&gt;
  localTime:ISODate(2013-03-05T19:14:04.127Z),&lt;br/&gt;
  ok:1&lt;br/&gt;
}&lt;/p&gt;</comment>
                            <comment id="281980" author="woaksie" created="Tue, 5 Mar 2013 19:10:16 +0000"  >&lt;p&gt;A bit more detail - we run 3 mongo databases in a replica set on 3 Worker Role instances &lt;span class=&quot;error&quot;&gt;&amp;#91;think VMs&amp;#93;&lt;/span&gt;. When Azure shuts down an instance, we run our custom shutdown code. This process does;&lt;/p&gt;

&lt;p&gt;1) Step Down via localhost connection if Primary &lt;span class=&quot;error&quot;&gt;&amp;#91;use replSetGetStatus to find out&amp;#93;&lt;/span&gt;&lt;br/&gt;
2) Call MongoServer.Shutdown() method in the C# driver via localhost connection and slave ok.&lt;br/&gt;
3) Unmount the Cloud drive Mongod.exe is using to persist the database&lt;/p&gt;

&lt;p&gt;You should see these steps in the log I attached.&lt;/p&gt;

&lt;p&gt;It is possible that the shutdown command is always failing. I will dig into that a bit deeper and get an accurate % failure rate.&lt;/p&gt;</comment>
                            <comment id="281971" author="woaksie" created="Tue, 5 Mar 2013 18:57:55 +0000"  >&lt;p&gt;These are logs of our 3 Azure Replica Set instances shutting down last night. All 3 shutdowns failed.&lt;/p&gt;</comment>
                            <comment id="281398" author="craiggwilson" created="Tue, 5 Mar 2013 00:46:35 +0000"  >&lt;p&gt;Sorry about asking questions you provided in your report.&lt;/p&gt;

&lt;p&gt;3) Can you call db.isMaster() on the server you are running?  I&apos;m specifically looking for what is returned in the &quot;me&quot; field.  &lt;br/&gt;
3b) Perhaps &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-6591&quot; title=&quot;Localhost authentication exception doesn&amp;#39;t work right on sharded cluster&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-6591&quot;&gt;&lt;del&gt;SERVER-6591&lt;/del&gt;&lt;/a&gt; is the culprit in this one. We have fixed this in our upcoming 2.4 release.  &lt;/p&gt;

&lt;p&gt;What has me a little confused is why this only happens every once in a while, which wouldn&apos;t be explained as above.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=sridhar&quot; class=&quot;user-hover&quot; rel=&quot;sridhar&quot;&gt;sridhar&lt;/a&gt;, do you know of anything in Azure that might cause this?  When resolving the loopback address in an Azure replica set, does it resolve differently than on a normal machine?&lt;/p&gt;</comment>
                            <comment id="281206" author="woaksie" created="Mon, 4 Mar 2013 21:03:44 +0000"  >&lt;p&gt;1) We are NOT using auth.&lt;br/&gt;
2) 1.6&lt;br/&gt;
3) We are running localhost on the server.&lt;br/&gt;
4) This is our current code:&lt;br/&gt;
        internal static void ShutdownMongoServer()&lt;/p&gt;
        {
            var server = CreateServer(ServerConnectionType.LocalSlaveOkConnection);
            server.Shutdown();
        }

&lt;p&gt;	public static MongoServer CreateServer(ServerConnectionType connectionType)&lt;br/&gt;
        {&lt;br/&gt;
            switch (connectionType)&lt;br/&gt;
            {&lt;br/&gt;
                case ServerConnectionType.LocalConnection:&lt;br/&gt;
                    return MongoServer.Create(string.Format(&quot;mongodb://&lt;/p&gt;
{0}:{1}&quot;, System.Net.IPAddress.Loopback, MongoHostPortSetting.GetMongoHostPortSettings().Port));&lt;br/&gt;
&lt;br/&gt;
                case ServerConnectionType.LocalSlaveOkConnection:&lt;br/&gt;
                    return MongoServer.Create(string.Format(&quot;mongodb://{0}
&lt;p&gt;:&lt;/p&gt;
{1}
&lt;p&gt;/?slaveOk=true&quot;, System.Net.IPAddress.Loopback, MongoHostPortSetting.GetMongoHostPortSettings().Port));&lt;/p&gt;

&lt;p&gt;                case ServerConnectionType.ReplicaSetNearestConnection:&lt;br/&gt;
                    var settings = MongoDBAzureHelper.GetReplicaSetSettings();&lt;br/&gt;
                    settings.ReadPreference = new ReadPreference(ReadPreferenceMode.Nearest);&lt;br/&gt;
                    return MongoServer.Create(settings);&lt;/p&gt;

&lt;p&gt;                case ServerConnectionType.ReplicaSetConnection:&lt;br/&gt;
                    return MongoServer.Create(MongoDBAzureHelper.GetReplicaSetSettings());&lt;br/&gt;
            }&lt;/p&gt;

&lt;p&gt;            return null;&lt;br/&gt;
        }&lt;/p&gt;


&lt;p&gt;We also tried &quot;localhost&quot; instead of System.Net.IPAddress.Loopback but that has the same behaviour.&lt;/p&gt;</comment>
                            <comment id="281021" author="craiggwilson" created="Mon, 4 Mar 2013 17:49:29 +0000"  >&lt;p&gt;Hi John,&lt;br/&gt;
  Thanks for reporting.  Couple of questions:&lt;/p&gt;

&lt;p&gt;1) Are you using auth with your database and have you supplied credentials to the driver?&lt;br/&gt;
2) What version of the driver are you running?&lt;br/&gt;
3) Are you running from localhost or against a remote server?&lt;br/&gt;
4) How exactly are you calling shutdown from the driver?&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="24705" name="Logs.csv" size="46412" author="woaksie" created="Tue, 5 Mar 2013 18:57:55 +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|hrmdmv:</customfieldvalue>

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