Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-4098

Sharding: Unable to Upsert when shard key is in an embedded doc

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.0.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Environment:
      Ubuntu 10.04 LTS (Lucid Lynx)
    • Operating System:
      Linux

      Description

      I am using 2.0 release of mongodb in a setup with 4 shards. I created a test collection with following data:
      mongos> db.test1.find()
      { "_id" :

      { "a" : 1, "b" : 1 }

      , "c" : 3 }
      { "_id" :

      { "a" : 1, "b" : 2 }

      , "c" : 3 }
      { "_id" :

      { "a" : 1, "b" : 3 }

      , "c" : 3 }
      { "_id" :

      { "a" : 1, "b" : 4 }

      , "c" : 3 }

      I sharded the collection with shard key: "_id" which worked fine. Even new inserts are working fine after sharding but "upserts" are not working.
      For example , following command:
      $collection->update(
      array('_id' => array('a' => 1, 'b' => 3)),
      array('c' => array('$inc' => 1)),
      array('upsert' => true, 'safe' => true)
      );

      results in this error: ** EXCEPTION: can't upsert something without valid shard key

      I am using PHP 1.2.3 extension to connect to mongodb.

      Above error can be reproduced also when I use "_id.a" as a shard key rather than "_id".

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              redbeard0531 Mathias Stearn
              Reporter:
              vinaykr Vinaykr
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: