[SERVER-4539] erroneous error message "valid shard key must be in update object for collection" when updating sharded collection Created: 21/Dec/11 Updated: 19/Apr/12 Resolved: 23/Dec/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding |
| Affects Version/s: | 1.8.2, 2.0.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Joseph Shraibman | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Fedora 16 x86_64 |
||
| Operating System: | ALL |
| Participants: |
| Description |
|
On an unsharded database you can update a document without having to pass in the _id as a value in the update document. The new document will retain the old _id. For sharded collections if you want to update a document you have to include the _id (or whatever your shard key is) or you will get an error. use admin ); use test ) , {"num" : 2}) results in: valid shard key must be in update object for collection: test.coll |
| Comments |
| Comment by Lynn Hsu [ 19/Apr/12 ] | ||||||||||||||||
|
I saw Joseph's case above. Looks like he already included a valid shard key in the upsert, why it still failed? mongos> db.foo.update( { _id : 1 }, { x : 3 }, true ) Thanks | ||||||||||||||||
| Comment by Joseph Shraibman [ 23/Dec/11 ] | ||||||||||||||||
|
That's not what happens for me. On an unsharded collection:
On a sharded collection:
| ||||||||||||||||
| Comment by Eliot Horowitz (Inactive) [ 23/Dec/11 ] | ||||||||||||||||
|
This is by design.
|