[SERVER-70139] listCollection returns duplicate view names Created: 30/Sep/22  Updated: 29/Oct/23  Resolved: 15/Dec/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.0.15, 6.0.4, 6.2.0-rc5, 6.3.0-rc0

Type: Bug Priority: Major - P3
Reporter: Tommaso Tocci Assignee: Yuhong Zhang
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File repro_multiple_views_same_nss.patch    
Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.2, v6.0, v5.0
Steps To Reproduce:

Applies the provided patch ( repro_multiple_views_same_nss.patch ) on top of r6.2.0-alpha-757-g5e64359d2af and run:

resmoke.py --jobs 1 --mongodSetParameters="{logComponentVerbosity: {sharding: 3, storage: 3}}" --suite=concurrency_sharded_replication jstests/concurrency/fsm_workloads/create_all_type_collections.js --repeatTests 50

Sprint: Execution Team 2022-11-14, Execution Team 2022-12-12, Execution Team 2022-11-28, Execution Team 2022-12-26
Participants:

 Description   

While experimenting with a new FSM test I ended up with two views in the local catalog that have the same name.
This is the output of listCollection command:

    {
        "name" : "coll_1",
        "type" : "timeseries",
        "options" : {
            "timeseries" : {
                "timeField" : "time",
                "granularity" : "seconds",
                "bucketMaxSpanSeconds" : 3600
            }
        },
        "info" : {
            "readOnly" : false
        }
    },
    {
        "name" : "coll_1",
        "type" : "view",
        "options" : {
            "viewOn" : "coll_6",
            "pipeline" : [
                {
                    "$match" : {
                    }
                }
            ]
        },
        "info" : {
            "readOnly" : true
        }
    },
    {
        "name" : "coll_6",
        "type" : "collection",
        "options" : {
        },
        "info" : {
            "readOnly" : false,
            "uuid" : UUID("f7762c48-df15-4ea0-8971-36451a74632b")
        },
        "idIndex" : {
            "v" : 2,
            "key" : {
                "_id" : 1
            },
            "name" : "_id_"
        }
    },
    {
        "name" : "system.buckets.coll_1",
        "type" : "collection",
        "options" : {
            "validator" : {
                "$jsonSchema" : {
                    "bsonType" : "object",
                    "required" : [
                        "_id",
                        "control",
                        "data"
                    ],
                    "properties" : {
                        "_id" : {
                            "bsonType" : "objectId"
                        },
                        "control" : {
                            "bsonType" : "object",
                            "required" : [
                                "version",
                                "min",
                                "max"
                            ],
                            "properties" : {
                                "version" : {
                                    "bsonType" : "number"
                                },
                                "min" : {
                                    "bsonType" : "object",
                                    "required" : [
                                        "time"
                                    ],
                                    "properties" : {
                                        "time" : {
                                            "bsonType" : "date"
                                        }
                                    }
                                },
                                "max" : {
                                    "bsonType" : "object",
                                    "required" : [
                                        "time"
                                    ],
                                    "properties" : {
                                        "time" : {
                                            "bsonType" : "date"
                                        }
                                    }
                                },
                                "closed" : {
                                    "bsonType" : "bool"
                                },
                                "count" : {
                                    "bsonType" : "number",
                                    "minimum" : 1
                                }
                            },
                            "additionalProperties" : false
                        },
                        "data" : {
                            "bsonType" : "object"
                        },
                        "meta" : {
                        }
                    },
                    "additionalProperties" : false
                }
            },
            "clusteredIndex" : true,
            "timeseries" : {
                "timeField" : "time",
                "granularity" : "seconds",
                "bucketMaxSpanSeconds" : 3600
            }
        },
        "info" : {
            "readOnly" : false,
            "uuid" : UUID("d4fb7f04-52bf-436c-b003-787e62d72cee")
        }
    },

There are two entries for coll_1 one of type timeseries and the other is of type view



 Comments   
Comment by Githook User [ 05/Jan/23 ]

Author:

{'name': 'Yuhong Zhang', 'email': 'yuhong.zhang@mongodb.com', 'username': 'YuhongZhang98'}

Message: SERVER-70139 Check a view's property before returning it as a time-series collection in the `listCollections` result

(cherry picked from commit 6fc43f3993103d5575cf798c829db59b35170f2e)
Branch: v5.0
https://github.com/mongodb/mongo/commit/91eeb971a0ee155f41f88a13940e2699778a70d6

Comment by Githook User [ 04/Jan/23 ]

Author:

{'name': 'Yuhong Zhang', 'email': 'yuhong.zhang@mongodb.com', 'username': 'YuhongZhang98'}

Message: SERVER-70139 Check a view's property before returning it as a time-series collection in the `listCollections` result

(cherry picked from commit 6fc43f3993103d5575cf798c829db59b35170f2e)
Branch: v6.0
https://github.com/mongodb/mongo/commit/f438adfc83076f28919bc9b9b55477b4994e9e71

Comment by Githook User [ 03/Jan/23 ]

Author:

{'name': 'Yuhong Zhang', 'email': 'yuhong.zhang@mongodb.com', 'username': 'YuhongZhang98'}

Message: SERVER-70139 Check a view's property before returning it as a time-series collection in the `listCollections` result

(cherry picked from commit 6fc43f3993103d5575cf798c829db59b35170f2e)
Branch: v6.2
https://github.com/mongodb/mongo/commit/3dc6cd2613648179059128a966ed887475f34290

Comment by Githook User [ 15/Dec/22 ]

Author:

{'name': 'Yuhong Zhang', 'email': 'yuhong.zhang@mongodb.com', 'username': 'YuhongZhang98'}

Message: SERVER-70139 Check a view's property before returning it as a time-series collection in the `listCollections` result
Branch: master
https://github.com/mongodb/mongo/commit/6fc43f3993103d5575cf798c829db59b35170f2e

Comment by Yuhong Zhang [ 14/Dec/22 ]

The issue was listCollection didn't check if a view with a matching name to a buckets collection is actually a time-series collection. As a result, we inserted the entry of the time-series view when we see the buckets collection, and the actual view itself again when we see the view.

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