[SERVER-4813] Problems with Replace command on sharded servers. Created: 30/Jan/12  Updated: 15/Aug/12  Resolved: 09/Apr/12

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 1.8.0-rc0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Donny Bailey Assignee: Randolph Tan
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

C# Driver, running against Mongo 1.8.rc0


Operating System: ALL
Participants:

 Description   

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);



 Comments   
Comment by Randolph Tan [ 08/Mar/12 ]

Hi,

I was not able to reproduce it using the 1.3.1 version of the C# driver. Can you give us more details on how the oItem document actually looks like? Is it also possible to include a verbose logs from mongos? Can you also give us more details about the setup of your cluster and what are your shard keys + indexes?

Thanks!

Comment by Eliot Horowitz (Inactive) [ 31/Jan/12 ]

Can you send a full example showing the issue?

Generated at Thu Feb 08 03:07:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.