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

QE fails with sharded upsert on non-shard key

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.1.0-rc0
    • Affects Version/s: None
    • Component/s: Queryable Encryption
    • Labels:
      None
    • Server Security
    • Fully Compatible
    • ALL
    • v7.0
    • Hide

      import {EncryptedClient} from "jstests/fle2/libs/encrypted_client_util.js";

      function runTest(conn) {

          let dbName = 'basic_update';

          let client = new EncryptedClient(conn, dbName);
          let edb = client.getDB();

          assert.commandWorked(client.createEncryptionCollection("basic", {
              encryptedFields:
                  {"fields": [{"path": "first", "bsonType": "string", "queries": {"queryType": "equality"}}]}
          }));

          let resShard = edb.adminCommand({enableSharding: edb.getName()});

          // enableSharding may only be called once for a database.
          if (resShard.code !== ErrorCodes.AlreadyInitialized)

      {         assert.commandWorked(             resShard, "enabling sharding on the '" + edb.getName() + "' db failed");     }

          let shardCollCmd =

      {         shardCollection: edb.getName() + ".basic",         key: \{_id: "hashed"}

      ,
              collation: {locale: "simple"}
          };

          resShard = edb.adminCommand(shardCollCmd);

          jsTestLog("Sharding: " + tojson(shardCollCmd));

          assert.commandWorked(edb.basic.insert({"_id": 1, "first": "mark", "last": "marco"}));
          assert.commandWorked(edb.basic.insert({"_id": 2, "first": "Mark", "last": "Marcus"}));

          // Add a document via upsert
          res = assert.commandWorked(edb.basic.runCommand({
              update: edb.basic.getName(),
              updates: [{q:

      {"last": "Marco"}

      , u: {"last": "Marco", "first": "Luke"}, upsert: true}]
          }));
      }

      jsTestLog("Sharding: Testing fle2 contention on update");

      {     const st = new ShardingTest(\{shards: 2, mongos: 1, config: 1}

      );

          runTest(st.s, st.shard0);

          st.stop();
      }

      Show
      import {EncryptedClient} from "jstests/fle2/libs/encrypted_client_util.js"; function runTest(conn) {     let dbName = 'basic_update';     let client = new EncryptedClient(conn, dbName);     let edb = client.getDB();     assert.commandWorked(client.createEncryptionCollection("basic", {         encryptedFields:             {"fields": [{"path": "first", "bsonType": "string", "queries": {"queryType": "equality"}}] }     }));     let resShard = edb.adminCommand({enableSharding: edb.getName()});     // enableSharding may only be called once for a database.     if (resShard.code !== ErrorCodes.AlreadyInitialized) {         assert.commandWorked(             resShard, "enabling sharding on the '" + edb.getName() + "' db failed");     }     let shardCollCmd = {         shardCollection: edb.getName() + ".basic",         key: \{_id: "hashed"} ,         collation: {locale: "simple"}     };     resShard = edb.adminCommand(shardCollCmd);     jsTestLog("Sharding: " + tojson(shardCollCmd));     assert.commandWorked(edb.basic.insert({"_id": 1, "first": "mark", "last": "marco"}));     assert.commandWorked(edb.basic.insert({"_id": 2, "first": "Mark", "last": "Marcus"}));     // Add a document via upsert     res = assert.commandWorked(edb.basic.runCommand({         update: edb.basic.getName(),         updates: [{q: {"last": "Marco"} , u: {"last": "Marco", "first": "Luke"}, upsert: true}]     })); } jsTestLog("Sharding: Testing fle2 contention on update"); {     const st = new ShardingTest(\{shards: 2, mongos: 1, config: 1} );     runTest(st.s, st.shard0);     st.stop(); }
    • Security 2023-08-21

      QE sharded upsert on a non-shard key goes though a different code path. As part of this code path, it does not set `encryptionInformation.setCrudProcessed` and so the upsert gets blocked.

            Assignee:
            erwin.pe@mongodb.com Erwin Pe
            Reporter:
            mark.benvenuto@mongodb.com Mark Benvenuto
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: