-
Type:
Bug
-
Resolution: Cannot Reproduce
-
Priority:
Major - P3
-
None
-
Affects Version/s: 1.8.0-rc0
-
Component/s: Sharding
-
None
-
Environment:C# Driver, running against Mongo 1.8.rc0
-
ALL
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Replace command problems on a sharded database. We've previously had problems where the Replace command would fail, saying Shard Key doesn't match. Now we have cases where a call to the Replace command will create a new record instead of updating the current record. This might be a problem with the parameters we are passing.
Here's a code snippet (It uses externally defined items, so it won't run as is, but does show the options for the calls we are using).
public static MongoCollection<ContentItem> GetCollection(MongoServer oServer, IdentifierItem oItem)
{ return oServer .GetDatabase(new MongoDatabaseSettings("customer" + oItem.CustomerID.ToString(), null, GuidRepresentation.Standard, new SafeMode(true), true)) .GetCollection<ContentItem>("namespace" + oItem.NamespaceID.ToString()); }var oServer = MongoServer.Create(m_sUri);
var oCollection = MongoDbFactory.GetCollection(oServer, oItem);
var oQuery = Query.And(Query.EQ("ContentID", oItem.ContentID.ToString()), Query.EQ("ShardID", oItem.ShardID.ToString()));
oCollection.Update(oQuery,
MongoDB.Driver.Builders.Update.Replace(oItem),
UpdateFlags.Upsert,
SafeMode.True);