[SERVER-40026] Blacklist distinct in sharded collections in transactions Created: 07/Mar/19  Updated: 29/Oct/23  Resolved: 20/May/19

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.1.12

Type: Improvement Priority: Major - P3
Reporter: Gregory McKeon (Inactive) Assignee: Ilan Cohen
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
is documented by DOCS-12725 Docs for SERVER-40026: Blacklist dist... Closed
Related
related to SERVER-41239 Link to recommended alternative in er... Closed
Backwards Compatibility: Fully Compatible
Sprint: Sharding 2019-05-06, Sharding 2019-05-20, Sharding 2019-06-03
Participants:

 Description   

Per alyson.cabral, we should do this.

This is because distinct is the only command currently allowed in a sharded transaction that does not filter orphaned documents.



 Comments   
Comment by Githook User [ 20/May/19 ]

Author:

{'email': 'jack.mulrow@mongodb.com', 'name': 'Jack Mulrow', 'username': 'jsmulrow'}

Message: SERVER-40026 Don't allow distinct on sharded collections in multi document transactions
Branch: master
https://github.com/mongodb/mongo/commit/1c9d985ab77b53a5cdaa755515b0bd0fb24fa1e0

Comment by Alyson Cabral (Inactive) [ 16/May/19 ]

To reiterate the in-person conversation, we should just disallow for now. kay.kim will work on making a docs page similar to count with known workarounds. Will you create a docs ticket for this Kay? And then we will link (as depends on) the follow-up ticket that adds that docs link to the error message. The idea is that we would implement syntactic sugar for this in agg in the long term.

db.runCommand({distinct:"foo", key:"a"})
{
        "values" : [
                1,
                2,
                11
        ],
        "ok" : 1,
        "$gleStats" : {
                "lastOpTime" : {
                        "ts" : Timestamp(1558026610, 2),
                        "t" : NumberLong(16)
                },
                "electionId" : ObjectId("7fffffff0000000000000010")
        },
        "lastCommittedOpTime" : Timestamp(1558026911, 1),
        "$configServerState" : {
                "opTime" : {
                        "ts" : Timestamp(1558026901, 2),
                        "t" : NumberLong(16)
                }
        },
        "$clusterTime" : {
                "clusterTime" : Timestamp(1558026911, 1),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        },
        "operationTime" : Timestamp(1558026911, 1)
}
MongoDB Enterprise shard01:PRIMARY> db.foo.aggregate({$group:{_id:0, values:{$addToSet:"$a"}}},{$project:{_id:0}})
{ "values" : [ 1, 11, 2 ] }

Comment by Jack Mulrow [ 02/May/19 ]

alyson.cabral, do you have a preference on the error message we should return to a user who tries to run "distinct" in a transaction on a sharded collection?

For count (which isn't allowed in a transaction at all), we return an error with: "Cannot run 'count' in a multi-document transaction. Please see http://dochub.mongodb.org/core/transaction-count for a recommended alternative." Do we have a similar alternative to recommend here? Or is it fine to return something like "Cannot run 'distinct' in a multi-document transaction on a sharded collection" with no alternative?

CC kaloian.manassiev

Comment by Jack Mulrow [ 25/Apr/19 ]

Yeah I can take this.

Comment by Gregory McKeon (Inactive) [ 25/Apr/19 ]

jack.mulrow can you pick this up?

Generated at Thu Feb 08 04:53:49 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.