[SERVER-79520] QE fails with sharded upsert on non-shard key Created: 31/Jul/23  Updated: 29/Oct/23  Resolved: 18/Aug/23

Status: Closed
Project: Core Server
Component/s: Queryable Encryption
Affects Version/s: None
Fix Version/s: 7.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Mark Benvenuto Assignee: Erwin Pe
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
is depended on by SERVER-79889 Issue with FLE2 update (with upsert: ... Closed
Duplicate
duplicates SERVER-79889 Issue with FLE2 update (with upsert: ... Closed
Assigned Teams:
Server Security
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.0
Steps To Reproduce:

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();
}

Sprint: Security 2023-08-21
Participants:

 Description   

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.



 Comments   
Comment by Githook User [ 18/Aug/23 ]

Author:

{'name': 'Erwin Pe', 'email': 'erwin.pe@mongodb.com', 'username': 'erwee'}

Message: SERVER-79520 Fix QE sharded upsert on non-shard key
Branch: master
https://github.com/mongodb/mongo/commit/14b93cc215af024871f2b530a313706574a684b8

Generated at Thu Feb 08 06:41:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.