[SERVER-81057] Writes without shard key doesn't work with constants defined in 'let' Created: 13/Sep/23  Updated: 29/Oct/23  Resolved: 09/Oct/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: Lingzhi Deng Assignee: Jason Zhang
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-81952 Remove temporarily added shard keys f... Closed
Related
related to SERVER-76037 Write commands using updateOne withou... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.1
Steps To Reproduce:

For update: change the cmdObj for this test case to

cmdObj: {
            update: collName,
            updates: [{q: {$expr: {$eq: ["$y", "$$myVal"]}}, u: {$set: {z: setFieldVal}}}],
            let : {myVal: yFieldVal},
},

For delete: change the cmdObj for this test case to

cmdObj: {
            delete: collName,
            deletes: [{q: {$expr: {$eq: ["$y", "$$myVal"]}}, limit: 1}],
            let : {myVal: yFieldVal},
},

And they will fail with

{
    "index" : 0,
    "code" : 17276,
    "errmsg" : "Write results unavailable from failing to target a host in the shard updateOne_without_shard_key_basic-rs0 :: caused by :: Use of undefined variable: myVal"
}

Sprint: Sharding NYC 2023-09-18, Sharding NYC 2023-10-02, Sharding NYC 2023-10-16
Participants:

 Description   

I think the read phase doesn't take into account the 'let' (and probably 'c' as well) fields when constructing the read query.



 Comments   
Comment by Githook User [ 07/Oct/23 ]

Author:

{'name': 'Jason Zhang', 'email': 'jason.zhang@mongodb.com', 'username': 'jz1242'}

Message: SERVER-81057 Include 'let' parameters in writes without shard key
Branch: master
https://github.com/mongodb/mongo/commit/77a2568550245228336c0f33917a65d10ad820bb

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