Re: RunCommand fsync using C# driver

413 views
Skip to first unread message

craiggwilson

unread,
Nov 19, 2012, 8:39:22 AM11/19/12
to mongod...@googlegroups.com
Are you using authentication?  You only need to use credentials if using authentication...  

The admin database is simply a database called "admin".
   var adminDatabase = server.GetDatabase("admin");

May I ask why you need to flush to disk immediately?  What is your use case for this particular operation?


On Monday, November 19, 2012 3:06:59 AM UTC-6, wolfysan wrote:
Hello,

I am developing an application using .Net 4.0 that uses Mongo as DB storage. What I am trying to do is flush all the data the the disk when the user does a certain operation. I found this thread:
I was wondering how do I connect to the AdminDatabase? Is the AdminDatabase my database with MongoCredentials("admin","")?

Best regards,
Silviu.

Robert Stam

unread,
Nov 20, 2012, 8:36:51 AM11/20/12
to mongod...@googlegroups.com
The fsync command must be sent to the admin database.

Simply use "admin" as the parameter to GetDatabase.

On Tue, Nov 20, 2012 at 7:16 AM, wolfysan <wolf...@gmail.com> wrote:
And the code that generated the error:

 MongoDatabase database = MongoServer.GetDatabase(databaseName);
                if (database != null)
                {
                    var fsync = new CommandDocument { { "fsync", 1 } };//, { "async", 1 } };
                    database.RunCommand(fsync); -> error thrown here
                }

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

wolfysan

unread,
Nov 21, 2012, 4:23:06 AM11/21/12
to mongod...@googlegroups.com
Hello,

Thank you very much. It seems to have fixed my problem. Now fsync works.

I been meaning to ask: How do I close mongo process from C#, without Process.Kill? Server.Shutdown() throws exceptions (something was reading beyond the end of the stream).

Best regards,
Silviu.

craiggwilson

unread,
Nov 21, 2012, 9:29:20 AM11/21/12
to mongod...@googlegroups.com
Server.Shutdown() is the correct method.  It will throw an error because it is looking for a response, but the server has shutdown, so no response will be given.  You just need to catch the exception as it is expected.

wolfysan

unread,
Nov 21, 2012, 9:34:40 AM11/21/12
to mongod...@googlegroups.com
Hello Craig,

Thank you for clearing this up also.

Have a nice day/morning,
Reply all
Reply to author
Forward
0 new messages