[SERVER-27059] copyDatabase() fails due to document validation Created: 16/Nov/16  Updated: 16/Nov/16  Resolved: 16/Nov/16

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

Type: Bug Priority: Major - P3
Reporter: Richard Bibb Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
is documented by DOCS-9333 commands that write take a bypassDocu... Closed
Operating System: ALL
Steps To Reproduce:
  • Create a database
  • Create a collection with one structure
  • Define a validator on the collection that enforces a different structure, throwing an error if the structure is incorrect.
  • Add new documents that observe the new structure
  • Use the copyDatabase() to copy this database to a new location
  • This copy should fail due to validation
Participants:

 Description   

when calling the command db.copyDatabase() the command will fail if one of the documents in a collection fails document validation. This probably isn't a bug but it is undesirable behaviour. When requesting a copy of a database that is what I want, a copy, warts and all.

In my case this problem comes about because in the early days of my database I didn't have document validation in place. Later on I put validation in place and enforced it strictly.



 Comments   
Comment by Richard Bibb [ 16/Nov/16 ]

Thanks Dan for your very speedy response

Comment by Daniel Pasette (Inactive) [ 16/Nov/16 ]

You can run the copydb command using the bypassDocumentValidation flag.

In the mongo shell:

db.adminCommand({copydb: 1, fromdb: dbName, todb: copyDbName, bypassDocumentValidation: true});

However, I checked the copydb documentation and I see that the flag is missing. Thanks for pointing this out. Also, please note that the shell helper does not support this flag, you must use the command itself. I'll raise a DOCS ticket.

Dan

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