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

Insert of document with duplicate _id fields should be forbidden

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.7, 3.1.9
    • Component/s: Write Ops
    • Labels:
    • Backwards Compatibility:
      Minor Change
    • Operating System:
      ALL
    • Backport Completed:
    • Steps To Reproduce:
      Hide

      Construct a BSON document with multiple _id fields and send it to the server.

      E.g. with MongoDB Perl driver v0.708.2.0:

      #!/usr/bin/env perl
      use v5.10;
      use strict;
      use warnings;
      use MongoDB;
      use Tie::IxHash;
       
      my $client = MongoDB::MongoClient->new;
      my $database = $client->get_database('test');
      my $collection = $database->get_collection('duptest');
      $collection->drop;
       
      $collection->insert( Tie::IxHash->new( _id => 1 ) );
      $collection->insert( [ _id => 2 ] );
      

      Then look at the test.duptest collection in the mongo shell.

      Show
      Construct a BSON document with multiple _id fields and send it to the server. E.g. with MongoDB Perl driver v0.708.2.0: #!/usr/bin/env perl use v5.10; use strict; use warnings; use MongoDB; use Tie::IxHash;   my $client = MongoDB::MongoClient->new; my $database = $client->get_database('test'); my $collection = $database->get_collection('duptest'); $collection->drop;   $collection->insert( Tie::IxHash->new( _id => 1 ) ); $collection->insert( [ _id => 2 ] ); Then look at the test.duptest collection in the mongo shell.
    • Sprint:
      Quint 9 09/18/15

      Description

      (At Bernie Hackett's suggestion, I'm opening this separate from SERVER-6439 to highlight the impact on _id, specifically.)

      A bug in the Perl driver revealed that it's possible to insert a document with duplicate/multiple _id fields.

      > db.duptest.find()
      { "_id" : NumberLong(1), "_id" : NumberLong(1) }
      { "_id" : NumberLong(2), "_id" : NumberLong(2) }
      

      I reproduced this against 3.1.5, 3.0.4, 2.6.10, and 2.4.14.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: