File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -795,7 +795,14 @@ func (o *OplogRestore) handleNonTxnOp(op db.Oplog) error {
795
795
// PBM-921: ensure the collection exists before "creating" views or timeseries
796
796
err := o .dst .Database (dbName ).CreateCollection (context .TODO (), "system.views" )
797
797
if err != nil {
798
- return errors .Wrapf (err , "ensure %s.system.views collection" , dbName )
798
+ // MongoDB 5.0 and 6.0 returns NamespaceExists error.
799
+ // MongoDB 7.0 and 8.0 does not return error.
800
+ // https://github.com/mongodb/mongo/blob/v6.0/src/mongo/base/error_codes.yml#L84
801
+ const NamespaceExists = 48
802
+ var cmdError mongo.CommandError
803
+ if ! errors .As (err , & cmdError ) || cmdError .Code != NamespaceExists {
804
+ return errors .Wrapf (err , "ensure %s.system.views collection" , dbName )
805
+ }
799
806
}
800
807
}
801
808
You can’t perform that action at this time.
0 commit comments