[CSHARP-614] Change default WriteConcern behavior to acknowledge writes Created: 27/Oct/12  Updated: 20/Mar/14  Resolved: 08/Nov/12

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.6.1
Fix Version/s: 1.7

Type: Improvement Priority: Major - P3
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
related to CSHARP-627 Remove FireAndForget and use magic va... Closed
related to CSHARP-615 Replace SafeMode with WriteConcern Closed
Backwards Compatibility: Major Change

 Description   

This JIRA was edited to remove mention of the FireAndForget keyword. See also CSHARP-627.

In the past the default WriteConcern for all drivers has been to not acknowledge writes. In the future this will no longer be the default WriteConcern, and the default behavior will be for drivers to send a simple

{ getlasterror : 1 }

command after every insert/update operation. Additional arguments to the getLastError command can be configured using WriteConcern properties.

Because existing code may depend on the previous default, we are introducing a new root object (called MongoClient). When you use the new root object, acknowledging writes will be the new default.

Of course, if your connection string includes any WriteConcern related settings they will override the default (regardless of what the default is).

Currently, C# applications begin using MongoDB like this:

var connectionString = "mongodb://hostname";
var server = MongoServer.Create(connectionString);

In the future, the correct way to begin using MongoDB is:

var connectionString = "mongodb://hostname";
var client = new MongoClient(connectionString);
var server = client.GetServer();

If you don't plan to call any methods from MongoServer (usually you won't) you can navigate directly from the client object to a database object:

var database = client.GetDatabase("test");

Except for replacing the call to MongoServer.Create with instantiating a MongoClient and calling GetServer, from then on your application will continue to use the existing API unchanged (although see the related JIRA where we are replacing SafeMode with WriteConcern).

The existing MongoServer.Create methods will continue to exist for a few releases, but they are being marked Obsolete to generate warnings to remind you to use MongoClient instead. Therefore this change is slightly backward breaking in the short term (because warnings are introduced) and backward breaking in the long term since the MongoServer.Create methods will eventually be removed.



 Comments   
Comment by auto [ 10/Dec/12 ]

Author:

{u'date': u'2012-11-20T04:16:56Z', u'email': u'robert@10gen.com', u'name': u'rstam'}

Message: CSHARP-614: Remove GetDatabase method from MongoClient (use GetDatabase in MongoServer instead).

Conflicts:
MongoDB.Driver/MongoClient.cs
Branch: x2.0
https://github.com/mongodb/mongo-csharp-driver/commit/132f686303bada3ab7fcf69a8a48a1a158280635

Comment by auto [ 26/Nov/12 ]

Author:

{u'date': u'2012-11-20T04:16:56Z', u'email': u'robert@10gen.com', u'name': u'rstam'}

Message: CSHARP-614: Remove GetDatabase method from MongoClient (use GetDatabase in MongoServer instead).
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/d8fede5694738a50d443d893be7bfa08e35c4882

Comment by auto [ 06/Nov/12 ]

Author:

{u'date': u'2012-11-02T15:48:16Z', u'email': u'robert@10gen.com', u'name': u'rstam'}

Message: CSHARP-614, CSHARP-615: better unit tests.

Conflicts:
Driver/Core/MongoConnectionStringBuilder.cs
DriverUnitTests/Core/MongoConnectionStringBuilderTests.cs
MongoDB.Driver/MongoUrlBuilder.cs
MongoDB.Driver/ReadPreference.cs
MongoDB.DriverUnitTests/GridFS/MongoGridFSSettingsTests.cs
MongoDB.DriverUnitTests/Jira/CSharp269Tests.cs
MongoDB.DriverUnitTests/Jira/CSharp471Tests.cs
MongoDB.DriverUnitTests/MongoCollectionSettingsTests.cs
MongoDB.DriverUnitTests/MongoDB.DriverUnitTests.csproj
MongoDB.DriverUnitTests/MongoDatabaseSettingsTests.cs
MongoDB.DriverUnitTests/MongoUrlBuilderTests.cs
MongoDB.DriverUnitTests/MongoUrlTests.cs
Branch: x2.0
https://github.com/mongodb/mongo-csharp-driver/commit/eaffcde68079a6641fb32c6dc5cb081de1ef4ce4

Comment by auto [ 06/Nov/12 ]

Author:

{u'date': u'2012-10-28T17:02:29Z', u'email': u'robert@10gen.com', u'name': u'rstam'}

Message: CSHARP-614, CSHARP-615: Added MongoClient and replaced SafeMode with WriteConcern and related changes.

Conflicts:
Driver/Core/MongoCollectionSettings.cs
Driver/Core/MongoConnectionStringBuilder.cs
DriverUnitTests/Core/MongoConnectionStringBuilderTests.cs
MongoDB.Driver/GridFS/MongoGridFS.cs
MongoDB.Driver/GridFS/MongoGridFSSettings.cs
MongoDB.Driver/MongoDB.Driver.csproj
MongoDB.Driver/MongoDatabase.cs
MongoDB.Driver/MongoDatabaseSettings.cs
MongoDB.Driver/MongoServer.cs
MongoDB.Driver/MongoServerSettings.cs
MongoDB.Driver/MongoUrl.cs
MongoDB.Driver/MongoUrlBuilder.cs
MongoDB.DriverUnitTests/Jira/CSharp231Tests.cs
Branch: x2.0
https://github.com/mongodb/mongo-csharp-driver/commit/c32cf97e0577458e68aba80c543d4e5fc8680167

Comment by auto [ 06/Nov/12 ]

Author:

{u'date': u'2012-11-02T15:48:16Z', u'email': u'robert@10gen.com', u'name': u'rstam'}

Message: CSHARP-614, CSHARP-615: better unit tests.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/4d353d47d2828c1f3cb393251e80c79538c7c71b

Comment by auto [ 29/Oct/12 ]

Author:

{u'date': u'2012-10-28T10:02:29-07:00', u'name': u'rstam', u'email': u'robert@10gen.com'}

Message: CSHARP-614, CSHARP-615: Added MongoClient and replaced SafeMode with WriteConcern and related changes.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/740c2488baa282da59815f074e9f4cf4accbcb27

Generated at Wed Feb 07 21:37:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.