[SERVER-35233] Powercycle remote collection validation does not skip views Created: 25/May/18  Updated: 29/Oct/23  Resolved: 29/May/18

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: 3.6.9, 4.0.3, 4.1.1

Type: Bug Priority: Major - P3
Reporter: Jonathan Abrahams Assignee: Jonathan Abrahams
Resolution: Fixed Votes: 0
Labels: read-only-views
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.0, v3.6
Sprint: TIG 2018-06-04
Participants:
Story Points: 1

 Description   

The remote collection validation can fail if a view exists.



 Comments   
Comment by Githook User [ 21/Sep/18 ]

Author:

{'name': 'Jonathan Abrahams', 'email': 'jonathan@mongodb.com', 'username': 'hptabster'}

Message: SERVER-35233 Fix remote collection validation by ignoring views

(cherry picked from commit 1e9a55f9bba4909732ba0b06bd3547df152864bf)
Branch: v3.6
https://github.com/mongodb/mongo/commit/301fc744b4f9fd05f16c05821c6acdb3ec4cb351

Comment by Githook User [ 20/Sep/18 ]

Author:

{'name': 'Jonathan Abrahams', 'email': 'jonathan@mongodb.com', 'username': 'hptabster'}

Message: SERVER-35233 Fix remote collection validation by ignoring views

(cherry picked from commit 1e9a55f9bba4909732ba0b06bd3547df152864bf)
Branch: v4.0
https://github.com/mongodb/mongo/commit/06df250cacc2fbf7b1669201e7ab7b03fab2c173

Comment by Githook User [ 29/May/18 ]

Author:

{'username': 'hptabster', 'name': 'Jonathan Abrahams', 'email': 'jonathan@mongodb.com'}

Message: SERVER-35233 Fix remote collection validation by ignoring views
Branch: master
https://github.com/mongodb/mongo/commit/1e9a55f9bba4909732ba0b06bd3547df152864bf

Comment by Jonathan Abrahams [ 25/May/18 ]

Improved method (requires PyMongo 3.6):

diff --git a/pytests/powertest.py b/pytests/powertest.py
index d59bbad819..d5df5aaab3 100755
--- a/pytests/powertest.py
+++ b/pytests/powertest.py
@@ -1503,7 +1503,8 @@ def mongo_validate_collections(mongo):
     invalid_colls = []
     ebusy_colls = []
     for db_name in mongo.database_names():
-        for coll_name in mongo[db_name].collection_names():
+        for coll in mongo[db_name].list_collections(filter={"type": "collection"}):
+            coll_name = coll["name"]
             res = mongo[db_name].command({"validate": coll_name, "full": True})
             LOGGER.info("Validating %s %s: %s", db_name, coll_name, res)
             ebusy = "EBUSY" in res["errors"] or "EBUSY" in res["warnings"]

Comment by Max Hirschhorn [ 25/May/18 ]

We could also switch to use the pymongo.Database.list_collections() method and specify {type: "collection"} like we do in the validate_collections.js hook.

Comment by Jonathan Abrahams [ 25/May/18 ]

Note - we currently do local validation, not remote. However a self-service user could run into this problem.

Comment by Jonathan Abrahams [ 25/May/18 ]

Fix:

diff --git a/pytests/powertest.py b/pytests/powertest.py
index d59bbad819..e6ad69e1f7 100755
--- a/pytests/powertest.py
+++ b/pytests/powertest.py
@@ -1504,6 +1504,9 @@ def mongo_validate_collections(mongo):
     ebusy_colls = []
     for db_name in mongo.database_names():
         for coll_name in mongo[db_name].collection_names():
+            # Skip validation of views.
+            if "viewOn" in mongo[db_name][coll_name].options():
+                continue
             res = mongo[db_name].command({"validate": coll_name, "full": True})
             LOGGER.info("Validating %s %s: %s", db_name, coll_name, res)
             ebusy = "EBUSY" in res["errors"] or "EBUSY" in res["warnings"]

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