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

Issue with FLE2 update (with upsert: true) on sharded_collections_jscore_passthrough.

    • Type: Icon: Task Task
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Queryable Encryption
    • None
    • Server Security
    • Security 2023-09-04

      This comes from a bulkWrite test but still fails when I moved from a bulkWrite update to a normal update like below:

      /**
       * Test that bulkWrite update works with FLE2.
       *
       * Some of the tests are incompatible with the transaction overrides since any failure
       * will cause a transaction abortion which will make the overrides infinite loop.
       *
       * The test runs commands that are not allowed with security token: bulkWrite.
       * @tags: [
       *   not_allowed_with_security_token,
       *   command_not_supported_in_serverless,
       *   does_not_support_transactions,
       *   # TODO SERVER-52419 Remove this tag.
       *   featureFlagBulkWriteCommand,
       * ]
       */
      import {
      	assertIsIndexedEncryptedField,
      	assertIsUnindexedEncryptedField,
      	EncryptedClient,
      	kSafeContentField
      } from "jstests/fle2/libs/encrypted_client_util.js";
      import {cursorEntryValidator} from "jstests/libs/bulk_write_utils.js";
      
      let dbName = 'basic_update';
      let dbTest = db.getSiblingDB(dbName);
      dbTest.dropDatabase();
      
      let client = new EncryptedClient(db.getMongo(), dbName);
      
      assert.commandWorked(client.createEncryptionCollection("basic", {
      	validator: {$jsonSchema: {required: ["first", "aka"]}},
      	encryptedFields: {
      		"fields": [
      			{"path": "first", "bsonType": "string", "queries": {"queryType": "equality"}},
      			{"path": "middle", "bsonType": "string"},
      			{"path": "aka", "bsonType": "string", "queries": {"queryType": "equality"}},
      		]
      	}
      }));
      
      let edb = client.getDB();
      
      let res = assert.commandWorked(edb.runCommand({
      	update: "basic",
      	updates: [{
      		q: {_id: 2},
      		u: {$set: {"first": "bob", "middle": "belcher", "aka": "bobs burgers"}},
      		upsert: true
      	}]
      }));
      

      Error is:

      2023-08-07T20:23:31.770Z assert: command failed: {
      	"nModified" : 0,
      	"n" : 0,
      	"opTime" : Timestamp(1691439811, 12),
      	"writeErrors" : [
      		{
      			"index" : 0,
      			"code" : 2,
      			"errmsg" : "Cannot insert a document with field name __safeContent__"
      		}
      	],
      	"ok" : 1,
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1691439811, 14),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	},
      	"operationTime" : Timestamp(1691439811, 12)
      } with original command request: {
      	"update" : "basic",
      	"updates" : [
      		{
      			"q" : {
      				"_id" : 2
      			},
      			"u" : {
      				"$set" : {
      					"first" : "bob",
      					"middle" : "belcher",
      					"aka" : "bobs burgers"
      				}
      			},
      			"upsert" : true
      		}
      	],
      	"lsid" : {
      		"id" : UUID("abff21cc-6b61-4105-b0f3-2bad233a713a")
      	},
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1691439811, 9),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      } on connection: connection to localhost:20003
      

      The same test has no issue on fle2_sharding.

      The original patch failure is here.

            Assignee:
            erwin.pe@mongodb.com Erwin Pe
            Reporter:
            frederic.vitzikam@mongodb.com Frederic Vitzikam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: