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

findAndModify hits collator mismatch invariant when collection has non-simple default collation

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.4.0-rc0, 4.7.0
    • Affects Version/s: None
    • Component/s: Write Ops
    • None
    • Fully Compatible
    • ALL
    • v4.4
    • Hide
      function reproBF16515() {
          const coll = db.reproBF16515;
          coll.drop();
      
          assert.commandWorked(db.createCollection("reproBF16515", {collation: { locale: 'en_US' }}));
      
          // Works
          coll.findAndModify({query: {_id: 1}, update: {}});
          print("Succeeded: fAM with _id query");
          // Works
          coll.findAndModify({query: {a: 1}, update: {}, fields: {a: 1}});
          print("Succeeded: fAM with non-_id query + projection");
          // Invariant
          print("About to run: fAM with _id query + projection");
          coll.findAndModify({
              query: { _id: 3 },
              update: {},
              fields: { a: 1 }
          });
          print("Unreachable: fAM with _id query + projection");
      }
      
      Show
      function reproBF16515() { const coll = db.reproBF16515; coll.drop(); assert .commandWorked(db.createCollection( "reproBF16515" , {collation: { locale: 'en_US' }})); // Works coll.findAndModify({query: {_id: 1}, update: {}}); print( "Succeeded: fAM with _id query" ); // Works coll.findAndModify({query: {a: 1}, update: {}, fields: {a: 1}}); print( "Succeeded: fAM with non-_id query + projection" ); // Invariant print( "About to run: fAM with _id query + projection" ); coll.findAndModify({ query: { _id: 3 }, update: {}, fields: { a: 1 } }); print( "Unreachable: fAM with _id query + projection" ); }
    • Query 2020-04-06
    • 5

      A findAndModify with an equality query on _id, an update, a projection, and no explicit collation will hit an invariant when run on a collection with a non-simple default collation, due to a mismatch between the collator set on the ExpressionContext and the collator parsed by CanonicalQuery from the QueryRequest.

      When running findAndModify under the conditions outlined above:

      This bug was introduced in SERVER-45406.

            Assignee:
            ian.boros@mongodb.com Ian Boros
            Reporter:
            bernard.gorman@mongodb.com Bernard Gorman
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: